h264_omx = mostly black videos, libx264 too slow, audio slows everything down

By Brendan Grant

I’m attempting to port a live tv transcoding app from Windows (on .net core) to work on a Raspberry Pi 3.

Under the hood I uses ffmpeg to take in an mpeg2 stream from a local networked tv tuner and spit out a local HLS stream which is exposed via a custom http server.

FFmpeg on Linux is configured for build as following:

sudo ./configure --arch=armhf --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-mmal --enable-omx --enable-omx-rpi

Seeing perf issues early on, I tried to boil it down to a simpler form and started using a VOB from a DVD (also mpeg2), take the following example:

ffmpeg -i VTS_01_2.VOB -c:a aac -c:v h264_omx -b:v 256k -hls_time 3 -hls_wrap 30 "/media/usb1/foo.m3u8"

Within a matter of seconds, this drops to not only under 30 FPS, but down to the low teens.

The following runs plenty fast, and is able to keep up when pointed to the tv stream… only all but the first ts file will end up being black (but with audio)… which it turns out the previous line also suffers from:

ffmpeg -i VTS_01_2.VOB -c:a copy -c:v h264_omx -b:v 256k -hls_time 3 -hls_wrap 30 "/media/usb1/foo.m3u8"

Aside from the oddity of my choice of audio codecs (ie accepting what is already there vs choosing something else) would so slow down the stream, I also discovered that in order to have visible video… I have to go without hardware assistance.

ffmpeg -i VTS_01_2.VOB -c:a aac -c:v libx264 -b:v 256k -hls_time 3 -hls_wrap 30 "/media/usb1/foo.m3u8"

and

ffmpeg -i VTS_01_2.VOB -c:a copy -c:v libx264 -b:v 256k -hls_time 3 -hls_wrap 30 "/media/usb1/foo.m3u8"

both turn out video which shows up… and with good audio, except both are too slow in terms of FPS to be able to keep up with a live tv stream.

Is there something I am missing here to be able to get ffmpeg to be able to handle turning an mpeg2 stream into an h.264 one… and have the resulting files have video?

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273