Hardware video transcoding with FFMEG

Break it down, and split the tasks in three and see where the CPU is being chewed up.
Read 60 fps from the the camera for for 5 seconds (Because 5 seconds x 60 fps x 1920x1080 x 16 bits per pixel for yuyv422 would be ~1187 MiB. Writing data at about ~237 MiB/sec, maybe make a quick 2 GiB RAM disk just for the 5 second test!).

$ mkdir /tmp/ramdisk
$ sudo mount -t tmpfs -o size=2g tmpfs /tmp/ramdisk
$ sudo chmod 1777 /tmp/ramdisk

$ ffmpeg -t 5 -f v4l2 -input_format yuyv422 -video_size 1920x1080 -y -r 60 -i /dev/video4 /tmp/ramdisk/test_60.yuyv422
$ ffmpeg -s 1920x1080 -y -r 60 -i /tmp/ramdisk/test_60.yuyv422 -r 30 /tmp/ramdisk/test_30.yuyv422
$ ffmpeg -s 1920x1080 -y -r 30 -i /tmp/ramdisk/test_30.yuyv422 -c:v hevc_omx /tmp/ramdisk/test_30.mp4
$ sudo umount /tmp/ramdisk
$ sudo rmdir /tmp/ramdisk

The above ffmpeg commands probably have mistakes in them, but they should be close enough that you can work out where I messed up. The RAM disk stuff should be fine, just do not forget to move any files you want to keep to real storage before you power off or umount. umount gives back the RAM to the OS.

1 Like