Quantcast
Channel: Harry – etc. etc.
Viewing all articles
Browse latest Browse all 48

Hardware-accelerated transcoding on the Raspberry Pi 4 Model B with DietPi

$
0
0

8 years after buying a Raspberry Pi Model 1B, I finally bit the bullet and invested in an upgrade, this time to the 8GB model of the Raspberry Pi 4 Model B (at the time on sale from Okdo for £62). This was largely because I wanted it to do video transcoding using ffmpeg. More specifically, I wanted to concatenate some H.264 files together and compress them at the same time.

Having installed DietPi as my distro of choice, my first attempt at this went something like:

ffmpeg -f concat -i /root/tapo/batch.txt -c:v h264 -c:a aac output.mp4

The problem with this is that it’s very slow (even when using -profile ultrafast). The CPU in the 4B, while much better than the 1B, is just not capable enough to encode H264 video very quickly. In particular, I needed it to transcode at a rate greater than 1x (i.e. to transcode more than one second of video per second) – a target it was missing by some way. I was just about to despair when I realised that the 4B supports hardware acceleration for H264, as set out in this excellent blog post by Will Usher.

Suitably enthused, but expecting something bright green, I switched to h264_v4l2m2m:

ffmpeg -f concat -i /root/tapo/batch.txt -c:v h264_v4l2m2m -c:a aac output.mp4

and… it didn’t work:

[h264_v4l2m2m @ 0x55913ffa00] Could not find a valid device

To cut a (very) long story short, the probem I was having was with DietPi and its reduced driver set. In particular, bcm2835-v4l2 is hidden behind a config option (“RPI Camera” under “Display options”). Without bcm2835-v4l2, h264_v4l2m2m can’t access the necessary video devices. To fix this problem, simply enable RPI Camera and reboot.

Oh, and I still had to build my own version of ffmpeg, as Will did, but he’d done the hard detective work there.


Viewing all articles
Browse latest Browse all 48

Latest Images

Trending Articles





Latest Images