[FFmpeg-devel] [PATCH][RFC] avcodec: disallow hwaccel with frame threads

Andy Furniss adf.lists at gmail.com
Wed Jan 20 12:13:55 CET 2016


wm4 wrote:
> On Wed, 20 Jan 2016 09:59:12 +0000 Andy Furniss <adf.lists at gmail.com>
> wrote:
>
>> wm4 wrote:
>>> On Wed, 20 Jan 2016 00:42:18 +0000 Andy Furniss
>>> <adf.lists at gmail.com> wrote:
>>>
>>>> Hendrik Leppkes wrote:
>>>>
>>>>>>> I do not agree that it should be a warning. As outlined
>>>>>>> in the commit message and this thread, there are serious
>>>>>>> flaws with frame threading and hwaccel.
>>>>>>
>>>>>> I'm fine with it being an error, but since it is an API
>>>>>> change, it should follow the usual deprecation period to
>>>>>> allow downstream users time to fix it. Meanwhile it can be
>>>>>> a warning so that people notice the problem.
>>>>>
>>>>> Its fundamentally broken, and making it a warning would
>>>>> re-introduce known crashes. So no.
>>>>
>>>> So are the flaws in ffmpeg or particular drivers?
>>>>
>>>> It does seem a shame perf wise, I've been testing my AMD UVD
>>>> decode recently and for 500 UHD frames in a really high
>>>> bitrate h264 file it's like -
>>>>
>>>> ffmpeg threaded = 16 sec.
>>>>
>>>> ffmpeg single thread = 20 sec.
>>>
>>> With or without hwaccel?
>>
>> Both are with hwaccel. ffmpeg 2.8.4 cli
>>
>> Admittedly a very concocted benchmark with a very high bitrate
>> sample.
>>
>> I know on normal x264 stuff my CPU could beat GPU anyway as the
>> copy back seems to hurt quite a lot/UVD is for playing.
>>
>> For future GPUs that will do hevc I guess it could be more
>> relevant.
>>
>>>> gstreamer vaapi 14 sec.
>>>>
>>>> gstreamer omx 10 sec.
>>>>
>>>> the omx is a faster as the others do nv12 -> I420 on cpu
>>>> (AFAICT)
>>>>
>>>> Maybe -threads 1 hurts perf by limiting the format conversion
>>>> as well?
>>>>
>>>> Is there a way to get whatever the h/w spits out (nv12)
>>>> directly? Trying to ask for nv12 seemed to get a double
>>>> conversion.
>>>
>>> Both vdpau and vaapi can retrieve image data as nv12.
>>
>> With ffmpeg cli?
>
> ffmpeg cli doesn't support vaapi.

I know, but it does do vdpau: so to restate my question in a clearer way -

Is it possible with ffmpeg cli -hwaccel vdpau to avoid nv12 -> I420
conversion?

> With what hardware was this? What were the command lines you used?

GPU is AMD R9285 TONGA (drivers are still new/experemental) but results
for this test seem consistent.

Rest of system is older Phenom II x4 3.4GHz (cpufreq forced for tests).
Mobo is PCIE 2.0 *Gig ram @ 1333.

Here's a paste I made a few days ago - includes s/w test (which by
chance for this sample comes out the same as multithread h/w) You can
see from the time cpu use output I really do get h/w decode as requested.

andy [vce-tests]$ time ffmpeg -hwaccel vdpau -i 
/mnt/ramdisk/x264-otc-2160p60-220M.mkv -f rawvideo /mnt/ramdisk/raw
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --enable-gpl --enable-version3 
--enable-nonfree --disable-static --enable-shared --disable-debug 
--enable-libass --enable-libfdk-aac --enable-libfreetype 
--enable-libmp3lame --enable-libopus --enable-libtheora 
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 
--enable-x11grab --docdir=/usr/share/doc/ffmpeg-2.8.4
   libavutil      54. 31.100 / 54. 31.100
   libavcodec     56. 60.100 / 56. 60.100
   libavformat    56. 40.101 / 56. 40.101
   libavdevice    56.  4.100 / 56.  4.100
   libavfilter     5. 40.101 /  5. 40.101
   libswscale      3.  1.101 /  3.  1.101
   libswresample   1.  2.101 /  1.  2.101
   libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from '/mnt/ramdisk/x264-otc-2160p60-220M.mkv':
   Metadata:
     ENCODER         : Lavf57.19.100
   Duration: 00:00:08.33, start: 0.000000, bitrate: 218593 kb/s
     Stream #0:0: Video: h264 (High), yuv420p, 3840x2160 [SAR 1:1 DAR 
16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default)
     Metadata:
       ENCODER         : Lavc57.16.101 libx264
       DURATION        : 00:00:08.334000000
Output #0, rawvideo, to '/mnt/ramdisk/raw':
   Metadata:
     encoder         : Lavf56.40.101
     Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 
3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc 
(default)
     Metadata:
       DURATION        : 00:00:08.334000000
       encoder         : Lavc56.60.100 rawvideo
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=  500 fps= 30 q=-0.0 Lsize= 6075000kB time=00:00:08.33 
bitrate=5971968.2kbits/s
video:6075000kB audio:0kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: 0.000000%

real    0m16.958s
user    0m7.333s
sys     0m3.062s
andy [vce-tests]$ rm /mnt/ramdisk/raw
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$ time ffmpeg -threads 1 -hwaccel vdpau -i 
/mnt/ramdisk/x264-otc-2160p60-220M.mkv -f rawvideo /mnt/ramdisk/raw
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --enable-gpl --enable-version3 
--enable-nonfree --disable-static --enable-shared --disable-debug 
--enable-libass --enable-libfdk-aac --enable-libfreetype 
--enable-libmp3lame --enable-libopus --enable-libtheora 
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 
--enable-x11grab --docdir=/usr/share/doc/ffmpeg-2.8.4
   libavutil      54. 31.100 / 54. 31.100
   libavcodec     56. 60.100 / 56. 60.100
   libavformat    56. 40.101 / 56. 40.101
   libavdevice    56.  4.100 / 56.  4.100
   libavfilter     5. 40.101 /  5. 40.101
   libswscale      3.  1.101 /  3.  1.101
   libswresample   1.  2.101 /  1.  2.101
   libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from '/mnt/ramdisk/x264-otc-2160p60-220M.mkv':
   Metadata:
     ENCODER         : Lavf57.19.100
   Duration: 00:00:08.33, start: 0.000000, bitrate: 218593 kb/s
     Stream #0:0: Video: h264 (High), yuv420p, 3840x2160 [SAR 1:1 DAR 
16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default)
     Metadata:
       ENCODER         : Lavc57.16.101 libx264
       DURATION        : 00:00:08.334000000
Output #0, rawvideo, to '/mnt/ramdisk/raw':
   Metadata:
     encoder         : Lavf56.40.101
     Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 
3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc 
(default)
     Metadata:
       DURATION        : 00:00:08.334000000
       encoder         : Lavc56.60.100 rawvideo
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=  500 fps= 24 q=-0.0 Lsize= 6075000kB time=00:00:08.33 
bitrate=5971968.2kbits/s
video:6075000kB audio:0kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: 0.000000%

real    0m20.743s
user    0m6.938s
sys     0m3.013s
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$ rm /mnt/ramdisk/raw
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$ time ffmpeg -i /mnt/ramdisk/x264-otc-2160p60-220M.mkv 
-f rawvideo /mnt/ramdisk/raw
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
   built with gcc 5.3.0 (GCC)
   configuration: --prefix=/usr --enable-gpl --enable-version3 
--enable-nonfree --disable-static --enable-shared --disable-debug 
--enable-libass --enable-libfdk-aac --enable-libfreetype 
--enable-libmp3lame --enable-libopus --enable-libtheora 
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 
--enable-x11grab --docdir=/usr/share/doc/ffmpeg-2.8.4
   libavutil      54. 31.100 / 54. 31.100
   libavcodec     56. 60.100 / 56. 60.100
   libavformat    56. 40.101 / 56. 40.101
   libavdevice    56.  4.100 / 56.  4.100
   libavfilter     5. 40.101 /  5. 40.101
   libswscale      3.  1.101 /  3.  1.101
   libswresample   1.  2.101 /  1.  2.101
   libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from '/mnt/ramdisk/x264-otc-2160p60-220M.mkv':
   Metadata:
     ENCODER         : Lavf57.19.100
   Duration: 00:00:08.33, start: 0.000000, bitrate: 218593 kb/s
     Stream #0:0: Video: h264 (High), yuv420p, 3840x2160 [SAR 1:1 DAR 
16:9], 60 fps, 60 tbr, 1k tbn, 120 tbc (default)
     Metadata:
       ENCODER         : Lavc57.16.101 libx264
       DURATION        : 00:00:08.334000000
Output #0, rawvideo, to '/mnt/ramdisk/raw':
   Metadata:
     encoder         : Lavf56.40.101
     Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 
3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc 
(default)
     Metadata:
       DURATION        : 00:00:08.334000000
       encoder         : Lavc56.60.100 rawvideo
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=  500 fps= 31 q=-0.0 Lsize= 6075000kB time=00:00:08.33 
bitrate=5971968.2kbits/s
video:6075000kB audio:0kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: 0.000000%

real    0m16.528s
user    1m1.201s
sys     0m2.659s
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$ rm /mnt/ramdisk/raw
andy [vce-tests]$
andy [vce-tests]$ time gst-launch-1.0 -f filesrc 
location=/mnt/ramdisk/x264-otc-2160p60-220M.mkv ! matroskademux ! 
h264parse ! vaapidecode ! filesink location=/mnt/ramdisk/raw
Setting pipeline to PAUSED ...
error: XDG_RUNTIME_DIR not set in the environment.
libva info: VA-API version 0.38.1
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_38
libva info: va_openDriver() returns 0
Pipeline is PREROLLING ...
Got context from element 'vaapidecode0': gst.vaapi.Display=context, 
gst.vaapi.Display=(GstVaapiDisplay)NULL;
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:13.822498897
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

real    0m14.301s
user    0m3.153s
sys     0m3.232s
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$ rm /mnt/ramdisk/raw
andy [vce-tests]$
andy [vce-tests]$
andy [vce-tests]$ time gst-launch-1.0 -f filesrc 
location=/mnt/ramdisk/x264-otc-2160p60-220M.mkv ! matroskademux ! 
h264parse ! omxh264dec ! filesink location=/mnt/ramdisk/raw
Setting pipeline to PAUSED ...
OMX-library /usr/lib/omxloaders/libomxdynamicloader.so dlopen error: 
/usr/lib/omxloaders/libomxdynamicloader.so: undefined symbol: RM_Deinit
Pipeline is PREROLLING ...
OMX-In RM_getResource No resource to be handled
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:09.786770762
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
OMX-In RM_releaseResource No resource to be handled
Setting pipeline to NULL ...
Freeing pipeline ...

real    0m10.803s
user    0m3.198s
sys     0m5.325s


More information about the ffmpeg-devel mailing list