<div dir="ltr">Hi Nicolas,<div><br></div><div>Thank you very much!! </div><div><br></div><div>I removed <span style="color:rgb(80,0,80)">output-io-mode=dmabuf-import from </span><span style="color:rgb(80,0,80)">v4l2video8convert and </span><span style="color:rgb(80,0,80)">v4l2h264enc elements and got the <b>pipeline working</b>!</span></div><div><span style="color:rgb(80,0,80)">This pipeline worked for me: </span><font face="monospace">gst-launch-1.0 -vvv v4l2src device="/dev/video9" num-buffers=1000 ! "video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)45/1, colorimetry=bt709" ! v4l2video8convert ! v4l2h264enc ! h264parse ! mp4mux ! filesink location=aha.mp4</font></div><div><font face="monospace"><br></font></div><div>I get about 15% CPU usage with the above pipeline, though I get few dropped frames in the output file.<br></div><div><br></div><div>So, the next step I want to perform few optimizations.</div><div>1) I set the io-mode=dmabuf-import on the v4l2src element though I get this error: </div><div><font face="monospace">ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate required memory.<br>Additional debug info:<br>gstv4l2src.c(658): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:<br>Buffer pool activation failed</font><br></div><div><br></div><div>So, I presume 0memcopy is not possible?</div><div><br></div><div>2) I would like to drop frames as close as possible to the v4l2 source to achieve 10 fps at the input of the encoder. Though my v4l2 src accepts only 45 and 60 fps configuration. Is there an elegant way to reduce the frame rate this way?</div><div><br></div><div>3) Any other recommendations I can pursue to optimize the pipeline?</div><div><br></div><div>Thank you very very much,</div><div>  -- Constantine.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 19, 2020 at 7:57 PM Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca">nicolas@ndufresne.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Le dimanche 19 janvier 2020 à 15:12 +0200, Constantine Elster a écrit :<br>
> Thank you very much Milian! Looks better with h264parse. Still getting an error, though now different one.<br>
> <br>
> I added h264parse to the pipeline:<br>
> gst-launch-1.0 -vvv v4l2src device="/dev/video9" num-buffers=200 ! "video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, colorimetry=bt709" ! v4l2video8convert output-io-mode=dmabuf-import ! v4l2h264enc output-io-mode=dmabuf-import ! h264parse ! mp4mux ! filesink location=aha.mp4<br>
> <br>
> Output:<br>
> Setting pipeline to PAUSED ...<br>
> Pipeline is live and does not need PREROLL ...<br>
> Setting pipeline to PLAYING ...<br>
> New clock: GstSystemClock<br>
> /GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, colorimetry=(string)bt709, interlace-mode=(string)progressive<br>
> /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, colorimetry=(string)bt709, interlace-mode=(string)progressive<br>
> /GstPipeline:pipeline0/v4l2video8convert:v4l2video8convert0.GstPad:src: caps = video/x-raw, framerate=(fraction)60/1, interlace-mode=(string)progressive, format=(string)I420, width=(int)640, height=(int)480, colorimetry=(string)bt709<br>
> /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)4, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, interlace-mode=(string)progressive, colorimetry=(string)bt709<br>
> /GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, profile=(string)baseline, level=(string)4, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, interlace-mode=(string)progressive, colorimetry=(string)bt709<br>
> Redistribute latency...<br>
> /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0.GstPad:sink: caps = video/x-raw, framerate=(fraction)60/1, interlace-mode=(string)progressive, format=(string)I420, width=(int)640, height=(int)480, colorimetry=(string)bt709<br>
> /GstPipeline:pipeline0/v4l2video8convert:v4l2video8convert0.GstPad:sink: caps = video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, colorimetry=(string)bt709, interlace-mode=(string)progressive<br>
> /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)60/1, colorimetry=(string)bt709, interlace-mode=(string)progressive<br>
> ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.<br>
> Additional debug info:<br>
> gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:<br>
> streaming stopped, reason error (-5)<br>
<br>
Looks like the real error was not propagated (let me know which version you are<br>
using, Ubuntu tends to be far behind, or only cherry-picking fixes rather then<br>
tracking stable branches).<br>
<br>
To find our more, set GST_DEBUG="v4l2*:7" env. That will give you a lot more<br>
details. By experience, I suspect that your output-io-mode=dmabuf-import is<br>
faulty on the v4l2convert element (on newer GStreamer, we now have a fix name<br>
for converter too). <br>
<br>
IMX.6 platform (and IMX.8 too) didn't include an IOMMU in their platform. On the<br>
other side, USB cameras (like UVC) produces scattered memory (virtual memory).<br>
That makes importation of dmabuf from UVC to v4l2convert impossible in this<br>
case. You may want to try the other way around, to set io-mode=dmabuf-import on<br>
the v4l2src element. If that does not work, you'll have no choice but to let the<br>
pipelein makes a copy (default setting). Normally, I suggest to first try<br>
without touching these advance settings, to make it work, and then tweak to gain<br>
more performance.<br>
<br>
> Execution ended after 0:00:00.436501205<br>
> Setting pipeline to PAUSED ...<br>
> Setting pipeline to READY ...<br>
> Setting pipeline to NULL ...<br>
> Freeing pipeline ...<br>
> <br>
> Any hint on debugging would be appreciated!<br>
> Thank you,<br>
>   -- Constantine.<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> On Sun, Jan 19, 2020 at 2:13 PM Milian Wolff <<a href="mailto:milian.wolff@kdab.com" target="_blank">milian.wolff@kdab.com</a>> wrote:<br>
> > On Sonntag, 19. Januar 2020 11:06:55 CET Constantine Elster wrote:<br>
> > > Hi devs,<br>
> > > <br>
> > > I'm trying to construct a pipeline that captures frames from a USB camera<br>
> > > (YUV) and encodes them with HW encoder and saves into a file. My setup is<br>
> > > iMX6 board running Ubuntu 18.04 on 4.20 mainline kernel.<br>
> > > <br>
> > > When I try a sw encoder, it works okay albeit I get very high 100% CPU<br>
> > > usage. The working pipeline based on software plugins:<br>
> > > gst-launch-1.0 -v v4l2src device="/dev/video2" num-buffers=200 !<br>
> > > "video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480,<br>
> > > pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)45/1,<br>
> > > colorimetry=bt709" ! videoconvert ! x264enc ! mp4mux ! filesink<br>
> > > location=aha.mp4<br>
> > > <br>
> > > My attempt to replace sw based plugins by HW based with efficient memory<br>
> > > management:<br>
> > > gst-launch-1.0 -v v4l2src device="/dev/video9" num-buffers=200 !<br>
> > > "video/x-raw, format=(string)UYVY, width=(int)640, height=(int)480,<br>
> > > pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)45/1,<br>
> > > colorimetry=bt709" ! *v4l2video8convert* *output-io-mode=dmabuf-import* !<br>
> > > *v4l2h264enc* *output-io-mode=dmabuf-import* ! mp4mux ! filesink<br>
> > > location=aha.mp4<br>
> > > <br>
> > > I get the following error: "WARNING: erroneous pipeline: could not link<br>
> > > v4l2h264enc0 to mp4mux0"<br>
> > > <br>
> > > Would appreciate any ideas how to understand what's wrong, how to debug and<br>
> > > make it work.<br>
> > <br>
> > To debug, I suggest you compare the SRC of `gst-inspect-1.0 v4l2h264enc` with <br>
> > the SINK of `gst-inspect-1.0 mp4mux`. My guess is that you may be able to fix <br>
> > the issue by adding a `h264parse` element in the middle to fix the alignment <br>
> > since `mp4mux` requires `au` alignment, whereas the encoder may output `nal` <br>
> > frames?<br>
> > <br>
> > Good luck<br>
> > <br>
> > -- <br>
> > Milian Wolff | <a href="mailto:milian.wolff@kdab.com" target="_blank">milian.wolff@kdab.com</a> | Senior Software Engineer<br>
> > KDAB (Deutschland) GmbH, a KDAB Group company<br>
> > Tel: +49-30-521325470<br>
> > KDAB - The Qt, C++ and OpenGL Experts<br>
> <br>
> <br>
> _______________________________________________<br>
> gstreamer-devel mailing list<br>
> <a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><font color="#666666"><br></font></div><font color="#666666">Director, Software Engineering</font><div><font color="#666666"><i><a href="http://www.valerann.com" target="_blank">www.valerann.com</a></i></font><div><font color="#888888"><br></font><span style="color:rgb(136,136,136)"><div dir="ltr"><img src="https://drive.google.com/a/valerann.com/uc?id=1cUa5VQGZCb9MrjxREFelyMkD3jH9H2Yx&export=download" width="96" height="96" style="color: rgb(34, 34, 34);"><span style="color:rgb(153,153,153);font-size:12.8px">       </span><span style="color:rgb(153,153,153);font-size:x-small;font-family:arial,helvetica,sans-serif"><a href="https://www.ces.tech/Innovation-Awards/Honorees/2020/Best-Of/T/The-Valerann-Smart-Roads-System.aspx" style="color:rgb(17,85,204)" target="_blank"><img src="https://drive.google.com/a/valerann.com/uc?id=1Oz_UDdgdrtleGGbfg5QoGBcrqC5Ni-Et&export=download" width="69" height="96"></a></span><br></div></span></div></div></div></div>