Hi all
I have made some more performance test.
I'm using a record from DVB-T so we are 100% aligned with the video source we have to deal with, when transcoding with tvheadend and this are the results (all test with mp2 to aac transcoding):
1) native(sw) -> no deinterlace -> h264_omx
pi@raspberrypi:/media/tvrec $ ffmpeg -i Prova.ts -c:a aac -c:v h264_omx -sn -b:v 128k prova_sw_nodeinterlace.mkv
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --prefix=/usr --enable-mmal --enable-omx --enable-omx-rpi --enable-decoder=h264_mmal --enable-encoder=h264_omx --enable-encoder=h264_omx --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-avresample
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mpeg2video @ 0x2def800] Invalid frame dimensions 0x0.
Last message repeated 14 times
[mpegts @ 0x2deb2b0] PES packet size mismatch
Last message repeated 2 times
Input #0, mpegts, from 'Prova.ts':
Duration: 09:56:08.63, start: 117669.938122, bitrate: 6 kb/s
Program 4005
Metadata:
service_name : Canale5
service_provider: Mediaset
Stream #0:0[0x64a]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x64b](ita): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:2[0x64c](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:3[0x653](ita,ita): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
[h264_omx @ 0x2e27e20] Using OMX.broadcom.video_encode
Output #0, matroska, to 'prova_sw_nodeinterlace.mkv':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_omx) (H264 / 0x34363248), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 128 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 h264_omx
Stream #0:1(ita): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.64.101 aac
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[mpegts @ 0x2deb2b0] PES packet size mismatchme=00:00:38.28 bitrate= 258.3kbits/s speed=1.72x
[mpeg2video @ 0x2e303a0] ac-tex damaged at 35 33
[mpeg2video @ 0x2e303a0] Warning MVs not available
[mpeg2video @ 0x2e303a0] concealing 135 DC, 135 AC, 135 MV errors in P frame
frame= 961 fps= 42 q=-0.0 Lsize= 1242kB time=00:00:39.24 bitrate= 259.2kbits/s speed=1.73x
video:605kB audio:614kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.860181%
[aac @ 0x2e29450] Qavg: 777.114
2) native(sw) -> deinterlace -> h264_omx
pi@raspberrypi:/media/tvrec $ ffmpeg -i Prova.ts -vf yadif -c:a aac -c:v h264_omx -sn -b:v 128k prova_sw_deinterlace.mkv
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --prefix=/usr --enable-mmal --enable-omx --enable-omx-rpi --enable-decoder=h264_mmal --enable-encoder=h264_omx --enable-encoder=h264_omx --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-avresample
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mpeg2video @ 0x239d780] Invalid frame dimensions 0x0.
Last message repeated 14 times
[mpegts @ 0x23992d0] PES packet size mismatch
Last message repeated 2 times
Input #0, mpegts, from 'Prova.ts':
Duration: 09:56:08.63, start: 117669.938122, bitrate: 6 kb/s
Program 4005
Metadata:
service_name : Canale5
service_provider: Mediaset
Stream #0:0[0x64a]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x64b](ita): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:2[0x64c](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:3[0x653](ita,ita): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
[h264_omx @ 0x2423e40] Using OMX.broadcom.video_encode
Output #0, matroska, to 'prova_sw_deinterlace.mkv':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_omx) (H264 / 0x34363248), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, 128 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 h264_omx
Stream #0:1(ita): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.64.101 aac
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[mpegts @ 0x23992d0] PES packet size mismatchme=00:00:38.88 bitrate= 258.0kbits/s speed=1.07x
[mpeg2video @ 0x23a0c90] ac-tex damaged at 35 33
[mpeg2video @ 0x23a0c90] Warning MVs not available
[mpeg2video @ 0x23a0c90] concealing 135 DC, 135 AC, 135 MV errors in P frame
frame= 961 fps= 26 q=-0.0 Lsize= 1240kB time=00:00:39.24 bitrate= 258.9kbits/s speed=1.08x
video:603kB audio:614kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.866869%
[aac @ 0x2425500] Qavg: 777.114
3) mpeg2_mmal(hw) -> no deinterlace -> h264_omx
pi@raspberrypi:/media/tvrec $ ffmpeg -vcodec mpeg2_mmal -i Prova.ts -c:a aac -c:v h264_omx -sn -b:v 128k prova2.mkv
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --prefix=/usr --enable-mmal --enable-omx --enable-omx-rpi --enable-decoder=h264_mmal --enable-encoder=h264_omx --enable-encoder=h264_omx --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-avresample
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mpegts @ 0x153c2e0] PES packet size mismatch
Last message repeated 2 times
Input #0, mpegts, from 'Prova.ts':
Duration: 09:56:08.63, start: 117669.938122, bitrate: 6 kb/s
Program 4005
Metadata:
service_name : Canale5
service_provider: Mediaset
Stream #0:0[0x64a]: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p(top first), 320x240, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x64b](ita): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:2[0x64c](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:3[0x653](ita,ita): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
File 'prova2.mkv' already exists. Overwrite ? [y/N] y
[h264_omx @ 0x1695980] Using OMX.broadcom.video_encode
Output #0, matroska, to 'prova2.mkv':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_omx) (H264 / 0x34363248), yuv420p, 320x240, q=2-31, 128 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 h264_omx
Stream #0:1(ita): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.64.101 aac
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (mpeg2_mmal) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[mpeg2_mmal @ 0x15445e0] Changing output format.
Input stream #0:0 frame changed from size:320x240 fmt:yuv420p to size:720x576 fmt:yuv420p53x
[mpegts @ 0x153c2e0] PES packet size mismatchme=00:00:38.84 bitrate= 258.0kbits/s speed=1.44x
frame= 961 fps= 35 q=-0.0 Lsize= 1240kB time=00:00:39.24 bitrate= 258.9kbits/s speed=1.45x
video:603kB audio:614kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.906249%
[aac @ 0x16bea00] Qavg: 777.114
4) mpeg2_mmal(hw) -> deinterlace -> h264_omx
pi@raspberrypi:/media/tvrec $ ffmpeg -vcodec mpeg2_mmal -i Prova.ts -vf yadif -c:a aac -c:v h264_omx -sn -b:v 128k prova2.mkv
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --prefix=/usr --enable-mmal --enable-omx --enable-omx-rpi --enable-decoder=h264_mmal --enable-encoder=h264_omx --enable-encoder=h264_omx --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-avresample
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mpegts @ 0x185a300] PES packet size mismatch
Last message repeated 2 times
Input #0, mpegts, from 'Prova.ts':
Duration: 09:56:08.63, start: 117669.938122, bitrate: 6 kb/s
Program 4005
Metadata:
service_name : Canale5
service_provider: Mediaset
Stream #0:0[0x64a]: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p(top first), 320x240, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x64b](ita): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:2[0x64c](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:3[0x653](ita,ita): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
File 'prova2.mkv' already exists. Overwrite ? [y/N] y
[h264_omx @ 0x19b4440] Using OMX.broadcom.video_encode
Output #0, matroska, to 'prova2.mkv':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_omx) (H264 / 0x34363248), yuv420p, 320x240, q=2-31, 128 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 h264_omx
Stream #0:1(ita): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.64.101 aac
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (mpeg2_mmal) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[mpeg2_mmal @ 0x19ca8f0] Changing output format.
Input stream #0:0 frame changed from size:320x240 fmt:yuv420p to size:720x576 fmt:yuv420p48x
[mpegts @ 0x185a300] PES packet size mismatchme=00:00:38.55 bitrate= 256.8kbits/s speed=0.987x
frame= 961 fps= 24 q=-0.0 Lsize= 1240kB time=00:00:39.24 bitrate= 259.0kbits/s speed=0.989x
video:603kB audio:614kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.905568%
[aac @ 0x19f05a0] Qavg: 777.114
So in summary
1) sw->hw no deinterlace: speed 1.73x
2) sw->hw deinterlace: speed 1.08x
3) hw->hw no deinterlace: speed 1.45x
4) hw->hw deinterlace: speed 0.97x
So, we can clearly see that the deinterlace put an huge impact on the performance, but also it seems that the hw decoding doesn't help. However looking better at the logs, you can see that the mpeg2_mmal seems to output a fixed 720x576 size despite of the input, that in this case is 320x240, so the encoder has more to do and also the output of the encoder is even scaled back to 320x240
So I have tried to put a scaling before the encoding:
5) mpeg2_mmal(hw) -> deinterlace -> scale-> h264_omx
pi@raspberrypi:/media/tvrec $ ffmpeg -vcodec mpeg2_mmal -i Prova.ts -vf yadif -vf scale=320:240 -c:a aac -c:v h264_omx -sn -b:v 128k prova_hw_deinterlace_scaled.mkv
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --prefix=/usr --enable-mmal --enable-omx --enable-omx-rpi --enable-decoder=h264_mmal --enable-encoder=h264_omx --enable-encoder=h264_omx --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-avresample
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[mpegts @ 0x31de310] PES packet size mismatch
Last message repeated 2 times
Input #0, mpegts, from 'Prova.ts':
Duration: 09:56:08.63, start: 117669.938122, bitrate: 6 kb/s
Program 4005
Metadata:
service_name : Canale5
service_provider: Mediaset
Stream #0:0[0x64a]: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p(top first), 320x240, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x64b](ita): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:2[0x64c](eng): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 128 kb/s
Stream #0:3[0x653](ita,ita): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
[h264_omx @ 0x3338450] Using OMX.broadcom.video_encode
Output #0, matroska, to 'prova_hw_deinterlace_scaled.mkv':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Video: h264 (h264_omx) (H264 / 0x34363248), yuv420p, 320x240, q=2-31, 128 kb/s, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 h264_omx
Stream #0:1(ita): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc57.64.101 aac
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (mpeg2_mmal) -> h264 (h264_omx))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
[mpeg2_mmal @ 0x334e900] Changing output format.
Input stream #0:0 frame changed from size:320x240 fmt:yuv420p to size:720x576 fmt:yuv420p
[mpegts @ 0x31de310] PES packet size mismatchme=00:00:38.57 bitrate= 256.6kbits/s speed=1.48x
frame= 961 fps= 36 q=-0.0 Lsize= 1240kB time=00:00:39.24 bitrate= 258.9kbits/s speed=1.48x
video:603kB audio:614kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.906249%
[aac @ 0x33745a0] Qavg: 777.114
It's quite better now, this speed, 1.48x is possible that makes the math to fill a real time transcoding on Rpi3, even if there is little margin.
Still it needs to be understood why the MMAL error when attempting to use this encoder in tvheadend, I'm building a custom ffmpeg for trying to understand what the error ""2" means.