<html><head><style>pre,code,address {
margin: 0px;
}
h1,h2,h3,h4,h5,h6 {
margin-top: 0.2em;
margin-bottom: 0.2em;
}
ol,ul {
margin-top: 0em;
margin-bottom: 0em;
}
blockquote {
margin-top: 0em;
margin-bottom: 0em;
}
</style></head><body><div>Le mercredi 23 août 2023 à 00:38 +0200, Regine Issan a écrit :</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="auto">Ps: regarding vivid</div><div dir="auto"><div><a href="https://www.kernel.org/doc/html/v4.8/media/v4l-drivers/vivid.html#webcam-input">https://www.kernel.org/doc/html/v4.8/media/v4l-drivers/vivid.html#webcam-input</a></div><br></div><div dir="auto">I see that the frame size is limited.</div><div dir="auto"><br></div><div dir="auto"><div><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;background-color:rgba(0,0,0,0);border-color:rgb(0,0,0);color:rgb(0,0,0)">Why does the limitation exist ?</span></div></div></blockquote><div><br></div><div>To better simulate a camera ?</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="auto"><br></div><div dir="auto">What is gstreamer limitation ? </div></blockquote><div><br></div><div>Hard to say, anything we don't support ?</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="auto"><br></div><div dir="auto">What would you recommend if I need bigger sizes ?</div></blockquote><div><br></div><div>There is an "input", I think you get different set of resolutions for different input. Otherwise, modify the code, its a software driver, no hw involved.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="auto"><br></div><div dir="auto"> <br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 23, 2023 at 00:20 Regine Issan <<a href="mailto:regine.issan@gmail.com">regine.issan@gmail.com</a>> wrote:<br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div dir="auto">Hello Nicolas !</div><div dir="auto">Thank you ,again , for your kind replay.</div><div dir="auto"><br></div><div dir="auto">Would you be so kind to see my comments/questions below (with “=>comment2 “ prefix)</div><div><br></div></div><div><div><div><div><div dir="ltr" class="gmail_attr">On Tue, Aug 22, 2023 at 21:03 Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca" target="_blank">nicolas@ndufresne.ca</a>> wrote:<br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div>Le mardi 22 août 2023 à 12:14 +0300, Regine Issan via gstreamer-devel a écrit :</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr">Hello Everyone,<br><br>I have an app that captures frames from a video device using v4l2.<br>the app should support all i-o modes.<br>I am mostly interested in userptr mode.<br><br>when i run the code with physical camera it works (with userptr mode).<br>when i run the same code with v4l2loopback camera and gstreamer, <br>it fails. calling VIDIOC_REQBUFS with V4L2_MEMEORY_USERPTR returns not supported.<br><br><div>in in link: <a href="https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/1028" target="_blank">https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/1028</a><br> <a href="https://gitlab.freedesktop.org/ndufresne" target="_blank"><span>Nicolas Dufresne</span></a> pointed me out that v4l2loopback does not support userptr.<br></div><div>I find his anser very helpful and consider my next steps.<br><br><br></div><div>several questions:<br></div><div><br></div><div>1. can i count that gstreamer works with user ptr ?<br><p> the link below suggests it sohuld work, correct ?<br> <a href="https://developer.ridgerun.com/wiki/index.php/GStreamer1.0_and_V4L2_UserPtr" rel="nofollow noreferrer noopener" target="_blank">https://developer.ridgerun.com/wiki/index.php/GStreamer1.0_and_V4L2_UserPt<br><br></a></p></div><div><p>2. </p><p> clearly, i am looking for simple stable solution.<br></p><p> as much as I love code, clearly it is preferable to use existing tools<br></p><p> to get fast and stable simulator.<br></p><p> if you could please advise ,which of the following options would you recommend ?<br></p><p> option1: use gstreamer\v4l2sink without v4l2loopback<br></p><p> my question here: which tool can i use instead v4l2loopback ?</p></div></div></blockquote><div><br></div><div>For testing purpose, you can build vivid virtual driver, it sumulates a camera, and implements USRPTR.</div></div></blockquote></div></div></div></div><div><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><br></span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:begin<br> Thanks, that seems the simplest solution.</span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> I will have a look at vivid. </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:end</span></div> </span></div><br></div></div><div><div><div><div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div><p> which tool did v4l2sink develpers used to check the usertpr mode ? </p></div></div></blockquote><div>Its has been added over 15 years ago, so I cannot say for sure. These days we prefer DMABuf importation instead, though its not yet automatically using it. Validation is difficult and mistakes will lead to error and garbled images.</div></div><br></blockquote><div dir="auto"><br></div></div></div></div></div><div><div dir="auto"><div dir="auto"><div><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"></span><div><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:begin</span></div></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> I read about </span>DMABuf here</div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> <span> </span><a href="https://stackoverflow.com/questions/66962795/what-is-the-use-of-mmap-userptr-and-dmabuf-in-video-streaming-using-v4l2-drive" style="color:rgb(66,133,244)" target="_blank">https://stackoverflow.com/questions/66962795/what-is-the-use-of-mmap-userptr-and-dmabuf-in-video-streaming-using-v4l2-drive</a></span></div></div><div dir="auto"><br></div><div dir="auto"> The consumer reading dmabufs must run</div><div dir="auto"> In kernel mode . Correct ?</div></span></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>No, you can mmap() the dmabuf for CPU access. The GstMemory/GstBuffer abstract this for you.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div class="gmail_quote"><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div dir="auto"><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div dir="auto"> </div><div dir="auto"> Vslidation using userptr and dmabufs</div><div dir="auto"> Are equally complicated ? </div></span></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>DMAbufs object in the kernel have state that helps a lot. It also allow identifying the exporter. Finally, DMABuf are guarantied page aligned.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div class="gmail_quote"><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div dir="auto"><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> </span></div><div dir="auto"> </div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:end</span></div> </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> </span></div></div></div></div><div><div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div><p> option2:any other gstreamer alternative for v4l2sink\v4l2loopback ?<br></p></div></div></blockquote><div>I'm not aware of equivalent of v4l2sink.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div> option3: changing v4l2loopback to support userptr <br> i am not video expert, in fact, quite new.<br> I wonder whyv4l2loopback did not support userptr mode<br></div><div> dou you think this is a hude task ?<br></div><div> can you see Any specific challenge ? I<br></div><div><br></div><div> PS: my userptr works with shared memeory<br></div><div> it should be accessible in user and kernel mode <br></div><div> (as the code worked with physical camera)</div></div></blockquote><div><br></div><div>v4l2loopback is an out of tree driver that does not use the videobuf2 helpers, so adding something like userptr is for sure a bit of work and you have to understand how strides and plane offset calculation works.</div></div></blockquote></div></div><div><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><br></span></div><div><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:begin</span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> I though the only difference </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> Between mmap and userptr </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> should only be </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> on requestbufs and cleanup .</span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div><div dir="auto" style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;color:rgb(0,0,0)"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">Mmmm…am I missing anything ?</span></div><div dir="auto" style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;color:rgb(0,0,0)"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> </span> strides and plane offset ? </div></div></span></div></div></div></blockquote></div></div></blockquote><div><br></div><div>When you import foreign buffers, the foreign chosen padding may differ. Not all driver can adapt to any foreign padding. The padding is set in S_FMT width/height, and bytesperline. If you have complicated plane offsets, you have to use the MPLANE interface.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div class="gmail_quote"><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><br></span></div></div><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:end</span></div></div></div><div><div><div><div><div><div class="gmail_quote"><div dir="auto"><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div><div><div dir="auto"> option4: writing a tool that replace v4l2loopback and gstramer <br></div></div></div><div> My single goal is to mimic A camera driver<br> that reads images from disk and writes it to v4l2 using userptr.</div><div>
<p dir="auto"> so maybe I should just write an app,<br> that declares the device and writes to v4l2 directly , just like driver do ?<br> </p></div></div></blockquote><div><br></div><div>Also seems like quite some coding, but if you go that way, have a look at libv4l2, you could make an LD_PRELOAD library that simulate a camera. Note that vivid have a "loop" control, which just like v4l2loopback allow passing data over. The only tricky bit is that the v4l2src needs to be configured to match the v4l2sink resolution and format, otherwise it will give you a test pattern.</div></div><br></blockquote><div dir="auto"><div><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:begin</span></div><div dir="auto">Thanks ! </div><div dir="auto">Perhaps I should dig into it if vivid won’t work.</div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:end</span></div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><div><br></div><div>Nicolas</div><div><span></span></div></div></blockquote></div></div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div><span></span></div></body></html>