Bad Movie Playback On Your Raspberry Pi? Time To Re-Encode Your Videos

While I regret purchasing a Raspberry Pi 2 for use as a media centre (more on that another time), it’s still more than serviceable if you want to use OpenELEC, OSMC or other home theatre distro. That is until you run up against videos encoded in H.265 / HEVC, which even the Pi 3 can struggle with.

H.264 is definitely the most popular video codec right now, but it won’t be long before the majority of online media is using the more efficient HEVC. If you’re planning to stick with your Raspberry Pi 2 or 3, you’ll want to convert these files to H.264, which the Pi’s GPU has hardware decoding support for.

Fortunately, conversion is straightforward with FFmpeg. Because the video stream has to be re-encoded, it’ll take more time than a simple container switch to get the job done.

Grab the latest Windows binaries for FFmpeg and install them to a directory accessible from the PATH environment settings. Then create a batch file in the directory containing the HEVC-encoded files and paste the following code into it.

mkdir output
for %%i in (*.mkv) do ffmpeg -i "%%i" -c:a copy -sn -map 0:0 -map 0:1 -vcodec libx264 "output%%i"

Note you’ll need to change the *.mkv to match the extension of the video files you’re converting.

Basically, this command does the minimum work needed to transform the videos from H.265 to H.264. The audio is copied directly, so the only cost is the video re-encoding. If there are a lot of files to encode, you’ll be in for a wait.

FFmpeg can take advantage of multiple cores by default, so running extra instances to speed-up the conversion will have the opposite effect. Optionally, you can reduce the resolution — say, 1080p to 720p — to improve speeds.

The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.


9 responses to “Bad Movie Playback On Your Raspberry Pi? Time To Re-Encode Your Videos”