Why is connecting vaapi decoder to v4l2sink stuttering?

Nicolas Dufresne nicolas at ndufresne.ca
Tue Nov 8 01:03:39 UTC 2022


Le lun. 7 nov. 2022, 10 h 50, Christian Hattenberger <
christian.hattenberger at gmail.com> a écrit :

> Thnx I understand now the dmabuff problem with the v4l2loopback driver,
> but why is vaapi decode slower than sw decoder with memcopy?
>

>
> gst-launch-1.0 filesrc location=/mnt/DATA/tearing.mp4 ! qtdemux !
> vaapih264dec ! queue ! fpsdisplaysink video-sink="xvimagesink" sync=false
> text-overlay=true
>
> is playing with 9fps
>
>
>
> gst-launch-1.0 filesrc location=/mnt/DATA/tearing.mp4 ! qtdemux !
> avdec_h264 ! queue ! fpsdisplaysink video-sink="xvimagesink" sync=false
> text-overlay=true
>
> is playing with 45fps
>

There is more the one possible explanation. One is that GPU memory is often
setup without cpu cache, so they stay coherent. Read and writes are then
over 20x slower.

avdec_h264 do direct decoder into xv allocated memory, this gives an
important boost. The decoder is multithreaded, so it can be very fast. He
decoders are steady, but they are not fast.

The fallback in your va driver to download the images and convert the to a
linear representation might be entirely software, and possibly using
uncached read/writes.


>
>
>
> *Von:* Nicolas Dufresne <nicolas at ndufresne.ca>
> *Gesendet:* Montag, 7. November 2022 02:56
> *An:* Christian Hattenberger <christian.hattenberger at gmail.com>
> *Cc:* Discussion of the development of and with GStreamer <
> gstreamer-devel at lists.freedesktop.org>
> *Betreff:* Re: Why is connecting vaapi decoder to v4l2sink stuttering?
>
>
>
>
>
> Le dim. 6 nov. 2022, 10 h 22, Christian Hattenberger <
> christian.hattenberger at gmail.com> a écrit :
>
> If I use vaapipostproc in the chain with vaapisink it seems ok, so I think
> it does dmabuff,
>
> but when I use  io-mode=dmabuf-import with v4l2sink I get “Failed to
> allocated required memory”
>
>
>
> gst-launch-1.0 filesrc location=/mnt/DATA/tearing.mp4 ! decodebin !
> v4l2sink io-mode=dmabuf-import device=/dev/video10
>> 0:00:00.376954941 18843 0x7f4d44041460 ERROR          v4l2allocator
> gstv4l2allocator.c:740:gst_v4l2_allocator_start:<v4l2sink0:pool1:sink:allocator>
> error requesting 2 buffers: Invalid argument
>
> 0:00:00.377023310 18843 0x7f4d44041460 ERROR         v4l2bufferpool
> gstv4l2bufferpool.c:920:gst_v4l2_buffer_pool_start:<v4l2sink0:pool1:sink>
> we received 0 buffer from device '/dev/video10', we want at least 2
>
> 0:00:00.377052711 18843 0x7f4d44041460 ERROR             bufferpool
> gstbufferpool.c:559:gst_buffer_pool_set_active:<v4l2sink0:pool1:sink> start
> failed
>
>>
>
>
> v4l2-ctl -d /dev/video0 --all
>
> Driver Info:
>
>         Driver name      : v4l2 loopback
>
>         Card type        : Dummy video device (0x0000)
>
> This out-of-tree driver is incomplete, it does not support dmabuf. You are
> out of luck here, unless you have time to improve it.
>
>
>
>
>
>         Bus info         : platform:v4l2loopback-000
>
>         Driver version   : 5.15.49
>
>         Capabilities     : 0x85208003
>
>                 Video Capture
>
>                 Video Output
>
>                 Video Memory-to-Memory
>
>                 Read/Write
>
>                 Streaming
>
>                 Extended Pix Format
>
>                 Device Capabilities
>
>         Device Caps      : 0x05208003
>
>                 Video Capture
>
>                 Video Output
>
>                 Video Memory-to-Memory
>
>                 Read/Write
>
>                 Streaming
>
>                 Extended Pix Format
>
> Priority: 2
>
> Video input : 0 (loopback: ok)
>
> Video output: 0 (loopback in)
>
> Format Video Output:
>
>         Width/Height      : 1920/1080
>
>         Pixel Format      : 'NV12' (Y/CbCr 4:2:0)
>
>         Field             : None
>
>         Bytes per Line    : 1920
>
>         Size Image        : 3110400
>
>         Colorspace        : Rec. 709
>
>         Transfer Function : sRGB
>
>         YCbCr/HSV Encoding: ITU-R 601
>
>         Quantization      : Limited Range
>
>         Flags             :
>
> Streaming Parameters Video Capture:
>
>         Frames per second: 30.000 (30/1)
>
>         Read buffers     : 2
>
> Streaming Parameters Video Output:
>
>         Frames per second: 30.000 (30/1)
>
>         Write buffers    : 2
>
>
>
> User Controls
>
>
>
>                     keep_format 0x0098f900 (bool)   : default=0 value=0
>
>               sustain_framerate 0x0098f901 (bool)   : default=0 value=0
>
>                         timeout 0x0098f902 (int)    : min=0 max=100000
> step=1 default=0 value=0
>
>                timeout_image_io 0x0098f903 (bool)   : default=0 value=0
>
>
>
>
>
> *Von:* Nicolas Dufresne <nicolas at ndufresne.ca>
> *Gesendet:* Sonntag, 6. November 2022 14:32
> *An:* Discussion of the development of and with GStreamer <
> gstreamer-devel at lists.freedesktop.org>
> *Cc:* Christian Hattenberger <christian.hattenberger at gmail.com>
> *Betreff:* Re: Why is connecting vaapi decoder to v4l2sink stuttering?
>
>
>
>
>
> Le sam. 5 nov. 2022, 13 h 16, Christian Hattenberger via gstreamer-devel <
> gstreamer-devel at lists.freedesktop.org> a écrit :
>
> When I connect a vaapi decoder to v4l2sink the result is not as expected,
> same happens if I use autovideosink, I know for this I have to use
> vaapisink and it is working as expected, but is there a solution for
> v4l2sink? Can someone explain me the reason, is there a solution?
>
>
>
> gst-launch-1.0 filesrc location=/tmp/video.mp4 ! decodebin ! vaapipostproc
> ! video/x-raw,format=YUY2 ! v4l2sink device=/dev/video10
>
>
>
> Its experimental, and I am not sure if vaapipostproc does produce dmabuf
> in this case, but you can enable dmabuf-import on v4l2sink with property
> io-mode=dmabuf-import . By default, the frames are cpu copied from VA
> allocated memory into V4L2 allocated memory.
>
>
>
> Nicolas
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20221107/541c2656/attachment.htm>


More information about the gstreamer-devel mailing list