This post was updated on .
My USB camera has 2 pixel formats, MJPG & YUYV
jai@jai:~$ v4l2-ctl -d /dev/video0 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'MJPG' (compressed) Name : Motion-JPEG Size: Discrete 1920x1080 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 1280x720 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 640x480 Interval: Discrete 0.017s (60.000 fps) Index : 1 Type : Video Capture Pixel Format: 'YUYV' Name : YUYV 4:2:2 Size: Discrete 1920x1080 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 1280x720 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 640x480 Interval: Discrete 0.017s (60.000 fps) But v4l2src is able to except YUV2, YV12 as well as I420. How? gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw, format=YV12,width=1280, height=720, framerate=60/1' ! fpsdisplaysink video-sink=fakesink text-overlay=false -v Above pipeline works fine. Actually it's a positive aspect for me. I am worried because if I connect camera to jetson, v4l2src can only take mjpg and YUV2. I want jetson also to take YV12 and I420. Intel computer's GStreamer 1.8.3. Jetson's GStreamer 1.14.5 -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list gstreamer-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le jeudi 14 novembre 2019 à 12:12 -0600, jeyp4 a écrit :
> My USB camera has 2 pixel formats, MJPG & YUYV > > jai@jai:~$ v4l2-ctl -d /dev/video0 --list-formats-ext > ioctl: VIDIOC_ENUM_FMT > Index : 0 > Type : Video Capture > Pixel Format: 'MJPG' (compressed) > Name : Motion-JPEG > Size: Discrete 1920x1080 > Interval: Discrete 0.017s (60.000 fps) > Size: Discrete 1280x720 > Interval: Discrete 0.017s (60.000 fps) > Size: Discrete 640x480 > Interval: Discrete 0.017s (60.000 fps) > > Index : 1 > Type : Video Capture > Pixel Format: 'YUYV' > Name : YUYV 4:2:2 > Size: Discrete 1920x1080 > Interval: Discrete 0.017s (60.000 fps) > Size: Discrete 1280x720 > Interval: Discrete 0.017s (60.000 fps) > Size: Discrete 640x480 > Interval: Discrete 0.017s (60.000 fps) > > > But v4l2src is able to except YUV2, YV12 as well as I420. How? You have libv4l2 enabled, which integrate a software color converter. The library has many known issues, and no maintainer. So we have dropped it in newer GStreamer version. You can regain the same by using videoconvert, or jpegdec ! videoconvert, with the difference that GStreamer will be aware of the costy operation. Note that to not let down valid usage of that lib, we have introduced the environment variable GST_V4L2_USE_LIBV4L2=1, which enabled the lib at run-time. We have made good effort to workaround most of the known libv4l2 issues, but it is advised to avoid io-mode=dmabuf (default) and force io-mode=mmap. > gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw, > format=YV12,width=1280, height=720, framerate=60/1' ! fpsdisplaysink > video-sink=fakesink text-overlay=false -v > > Above pipeline works fine. > > Actually it's a positive aspect for me. I am worried because if I connect > camera to jetson, v4l2src can only take mjpg and YUV2. I want jetson also to > take YV12 and I420. > > Intel computer's GStreamer 1.8.3. > Jetson's GStreamer 1.14.5 New NVidia SDK depends heavily on libv4l2, so they have enabled it by default. So you might not have to care too much there. That being said, if you have a battery oriented device, I would recommend to try and use the HW accelerated color converter on that target. Nicolas _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Wow, wonderful answer.
I have 2 queries: 1. In version < 1.14, How format=YV12 was working? I mean my usb device capability is MJPG 1280x720@60fps and YUYV 1280x720@5fps (in USB2 connection). Although if I set v4l2src video/x-raw, format=YV12 in pipeline, it can work at 60 fps even in USB2 connection. So what I can infer is, pipeline is performing jpegdec ! videoconvert inherently. Am i correct? 2. How to see current value of GST_V4L2_USE_LIBV4L2 in any system? How to modify current value of GST_V4L2_USE_LIBV4L2 in any system? -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le vendredi 15 novembre 2019 à 05:36 -0600, jeyp4 a écrit :
> Wow, wonderful answer. > > I have 2 queries: > > 1. In version < 1.14, How format=YV12 was working? > > I mean my usb device capability is MJPG 1280x720@60fps and YUYV > 1280x720@5fps (in USB2 connection). Although if I set > v4l2src video/x-raw, format=YV12 > in pipeline, it can work at 60 fps even in USB2 connection. > > So what I can infer is, pipeline is performing > jpegdec ! videoconvert > inherently. Am i correct? working through an equivalent, but hidden in libv4l2 of: v4l2src ! image/jpeg,framerate=60/1 ! jpegdec ! videoconvert ! ... USB2 does not have the bandwidth to reach that framerate/resolution uncompressed. We also have code in v4l2src that favours higher framerate, so I supposed that it decided that using the "emulated" format at 60fps was better then native format at 5fps. Your app can always override this decision with caps filter of course. > > 2. How to see current value of > GST_V4L2_USE_LIBV4L2 > in any system? On Linux, in a terminal: echo $GST_V4L2_USE_LIBV4L2 When programming in C you can use g_getenv(). > How to modify current value of > GST_V4L2_USE_LIBV4L2 > in any system? In shell, export GST_V4L2_USE_LIBV4L2=1, or prior to gst_init() you can do g_setenv(), see GLib documentation for more details. There is some effort to ensure the decision remains the same, if not, let me know. Nicolas _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel signature.asc (201 bytes) Download Attachment |
I modified GST_V4L2_USE_LIBV4L2=1 in a shell. But still v4l2src can't take
YV12 format? nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 nvidia@jetson:~$ GST_V4L2_USE_LIBV4L2=1 nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 1 nvidia@jetson:~$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw,format=(string)YV12,width=1280,height=720' ! xvimagesink Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error. Additional debug info: gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: streaming stopped, reason not-negotiated (-4) Execution ended after 0:00:00.000127687 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... nvidia@jetson:~$ gst-inspect-1.0 --version gst-inspect-1.0 version 1.14.5 GStreamer 1.14.5 https://launchpad.net/distros/ubuntu/+source/gstreamer1.0 -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le lundi 18 novembre 2019 à 07:39 -0600, jeyp4 a écrit :
> I modified GST_V4L2_USE_LIBV4L2=1 in a shell. But still v4l2src can't take > YV12 format? > > nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 > > nvidia@jetson:~$ GST_V4L2_USE_LIBV4L2=1 > nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 > 1 > nvidia@jetson:~$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! > 'video/x-raw,format=(string)YV12,width=1280,height=720' ! xvimagesink > Setting pipeline to PAUSED ... > Pipeline is live and does not need PREROLL ... > Setting pipeline to PLAYING ... > ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal > data stream error. > Additional debug info: > gstbasesrc.c(3055): gst_base_src_loop (): > /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: > streaming stopped, reason not-negotiated (-4) > Execution ended after 0:00:00.000127687 > Setting pipeline to PAUSED ... > Setting pipeline to READY ... > Setting pipeline to NULL ... > Freeing pipeline ... > nvidia@jetson:~$ gst-inspect-1.0 --version > gst-inspect-1.0 version 1.14.5 > GStreamer 1.14.5 > https://launchpad.net/distros/ubuntu/+source/gstreamer1.0 On master, it throws an error about colorimetry. I suspect libv4l2 does not emulate that very well. Try commenting out that check, might work for you, works for me on master. I'll need to investigate for a proper workaround. https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/master/sys/v4l2/gstv4l2object.c#L3627 > > > > > -- > Sent from: http://gstreamer-devel.966125.n4.nabble.com/ > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le lundi 18 novembre 2019 à 12:54 -0500, Nicolas Dufresne a écrit :
> Le lundi 18 novembre 2019 à 07:39 -0600, jeyp4 a écrit : > > I modified GST_V4L2_USE_LIBV4L2=1 in a shell. But still v4l2src can't take > > YV12 format? > > > > nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 > > > > nvidia@jetson:~$ GST_V4L2_USE_LIBV4L2=1 > > nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 > > 1 > > nvidia@jetson:~$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! > > 'video/x-raw,format=(string)YV12,width=1280,height=720' ! xvimagesink > > Setting pipeline to PAUSED ... > > Pipeline is live and does not need PREROLL ... > > Setting pipeline to PLAYING ... > > ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal > > data stream error. > > Additional debug info: > > gstbasesrc.c(3055): gst_base_src_loop (): > > /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: > > streaming stopped, reason not-negotiated (-4) > > Execution ended after 0:00:00.000127687 > > Setting pipeline to PAUSED ... > > Setting pipeline to READY ... > > Setting pipeline to NULL ... > > Freeing pipeline ... > > nvidia@jetson:~$ gst-inspect-1.0 --version > > gst-inspect-1.0 version 1.14.5 > > GStreamer 1.14.5 > > https://launchpad.net/distros/ubuntu/+source/gstreamer1.0 > > On master, it throws an error about colorimetry. I suspect libv4l2 does > not emulate that very well. Try commenting out that check, might work > for you, works for me on master. I'll need to investigate for a proper > workaround. > > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/master/sys/v4l2/gstv4l2object.c#L3627 Some more context, libv4l2 seems to set fmt->fmt.pix.colorspace to 0, which is V4L2_COLORSPACE_DEFAULT, which is not supposed to be set by drivers. The whole story is that we suggest (try_fmt) 3:2:2:1 (in v4l2 values of colorspace, range, matrix, transfer), and libv4l2 returns 0:2:2:1. We fail at parsing this, and for some reason we endup leaving 3:2:2:1 into the caps. So that when we get to do set_fmt, we have 3:2:2:1 (bt709) in the caps. At this stage, because it was in the caps, we do validate and fail. To make the libv4l2 behaviour even more strange, when we do S_FMT, the return colorimetry is not 8:0:0:0:0 (so JPEG with default for everything). That make sense considering it will decode jpeg for us. But why didn't it returned that in TRY_FMT seems like a libv4l2 bug to me. So I think this should be fixed in libv4l2 of course, but we could also consider dropping the colorimetry from the caps to be set if the parsing failed. That should have worked too I guess. > > > > > > > > > -- > > Sent from: http://gstreamer-devel.966125.n4.nabble.com/ > > _______________________________________________ > > gstreamer-devel mailing list > > [hidden email] > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le lundi 18 novembre 2019 à 13:13 -0500, Nicolas Dufresne a écrit :
> Le lundi 18 novembre 2019 à 12:54 -0500, Nicolas Dufresne a écrit : > > Le lundi 18 novembre 2019 à 07:39 -0600, jeyp4 a écrit : > > > I modified GST_V4L2_USE_LIBV4L2=1 in a shell. But still v4l2src can't take > > > YV12 format? Can you test this patch for me ? https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/392 > > > > > > nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 > > > > > > nvidia@jetson:~$ GST_V4L2_USE_LIBV4L2=1 > > > nvidia@jetson:~$ echo $GST_V4L2_USE_LIBV4L2 > > > 1 > > > nvidia@jetson:~$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! > > > 'video/x-raw,format=(string)YV12,width=1280,height=720' ! xvimagesink > > > Setting pipeline to PAUSED ... > > > Pipeline is live and does not need PREROLL ... > > > Setting pipeline to PLAYING ... > > > ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal > > > data stream error. > > > Additional debug info: > > > gstbasesrc.c(3055): gst_base_src_loop (): > > > /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: > > > streaming stopped, reason not-negotiated (-4) > > > Execution ended after 0:00:00.000127687 > > > Setting pipeline to PAUSED ... > > > Setting pipeline to READY ... > > > Setting pipeline to NULL ... > > > Freeing pipeline ... > > > nvidia@jetson:~$ gst-inspect-1.0 --version > > > gst-inspect-1.0 version 1.14.5 > > > GStreamer 1.14.5 > > > https://launchpad.net/distros/ubuntu/+source/gstreamer1.0 > > > > On master, it throws an error about colorimetry. I suspect libv4l2 does > > not emulate that very well. Try commenting out that check, might work > > for you, works for me on master. I'll need to investigate for a proper > > workaround. > > > > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/master/sys/v4l2/gstv4l2object.c#L3627 > > Some more context, libv4l2 seems to set fmt->fmt.pix.colorspace to 0, > which is V4L2_COLORSPACE_DEFAULT, which is not supposed to be set by > drivers. > > The whole story is that we suggest (try_fmt) 3:2:2:1 (in v4l2 values of > colorspace, range, matrix, transfer), and libv4l2 returns 0:2:2:1. We > fail at parsing this, and for some reason we endup leaving 3:2:2:1 into > the caps. So that when we get to do set_fmt, we have 3:2:2:1 (bt709) in > the caps. At this stage, because it was in the caps, we do validate and > fail. > > To make the libv4l2 behaviour even more strange, when we do S_FMT, the > return colorimetry is not 8:0:0:0:0 (so JPEG with default for > everything). That make sense considering it will decode jpeg for us. > But why didn't it returned that in TRY_FMT seems like a libv4l2 bug to > me. > > So I think this should be fixed in libv4l2 of course, but we could also > consider dropping the colorimetry from the caps to be set if the > parsing failed. That should have worked too I guess. > > > > > > > > > > -- > > > Sent from: http://gstreamer-devel.966125.n4.nabble.com/ > > > _______________________________________________ > > > gstreamer-devel mailing list > > > [hidden email] > > > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Wow, thanks for putting this much effort for this issue.
Although I being not an expert of gstreamer, understood half only. I have to test this patch on Jetson, which has stock gstreamer 1.14, not gst-build. Can you share some instructions, how to patch? Sorry for my stupidity.. I will check tomorrow on my desk. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le lundi 18 novembre 2019 à 14:06 -0600, jeyp4 a écrit :
> Wow, thanks for putting this much effort for this issue. > Although I being not an expert of gstreamer, understood half only. I could reproduce locally and we have this goal to try and keep libv4l2 working for the basic use case. > > I have to test this patch on Jetson, which has stock gstreamer 1.14, not > gst-build. > > Can you share some instructions, how to patch? > Sorry for my stupidity.. I will check tomorrow on my desk. First step, make sure you can build and run Jetson/NVidia fork of GStreamer following NVidia's instruction. When that's reach, there is multiple ways, considering NVidia's is not proposing git repository, here's a propose method: cd gst-plugins-good wget https://gitlab.freedesktop.org/ndufresne/gst-plugins-good/commit/23089e9cc376bdda90185d2b2378e3ba1ad78c75.patch cat 23089e9cc376bdda90185d2b2378e3ba1ad78c75.patch | patch -p1 Hopefully there will be no conflict. Otherwise, it's really just few lines of code, you can just try and apply it manually. regards, Nicolas _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
This post was updated on .
Sorry for late reply, but I was working on this topic.
Instead of trying the above patch on jetson, I see that you have modified gst-pluging-good gstv4l2object.c file. So I just perform a new gst-build of latest gstreamer on my Intel PC. Still, on latest gstreamer v4l2src can't take YV12. [gst-master] jai@jai:/media/jai/Entertainment/Software/gstreamer/gst-build$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw, format=(string)YV12,width=1920, height=1080' ! xvimagesink -v
But if I run above pipeline on stock gstreamer, it is working fine. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list gstreamer-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le mer. 20 nov. 2019 05 h 10, jeyp4 <[hidden email]> a écrit : Sorry for late reply, but I was working on this topic. Looks like NVidia code based have diverged I guess. Try enabling more debug (e.g. GST_DEBUG="v4l*:7") Execution ended after 0:00:00.000149820 _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
This post was updated on .
Sorry, if I am not clear in my latest reply.
Instead of trying the patch on Nvidia Jetson, I just perform a new gst-build of latest gstreamer on my Intel PC. (Because I see that you have modified gst-pluging-good -> gstv4l2object.c file) Still, on latest gstreamer v4l2src can't take {video/x-raw, format=YV12}. It is still performing well with {image/jpeg ! jpegdec} -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list gstreamer-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le mercredi 20 novembre 2019 à 12:33 -0600, jeyp4 a écrit :
> Sorry, if I am not clear in my latest reply. > Instead of trying the patch on Nvidia Jetson, I just perform a new > gst-build of latest gstreamer on my Intel PC. (Because I see that you have > modified gst-pluging-good -> gstv4l2object.c file) > > Still, on latest gstreamer v4l2src can't take {video/x-raw, format=YV12}. It > is still performing well with {image/jpeg ! jpegdec} Sounds like you didn't build with libv4l2 support. Make sure you have the required -dev (debian) -devel (Fedora) etc. package. Or forgot to set the env, but something in these lines. Nicolas _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel signature.asc (201 bytes) Download Attachment |
I just performed
meson build\ ninja -C build\ How to build with libv4l2 support? -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le jeu. 21 nov. 2019 02 h 25, jeyp4 <[hidden email]> a écrit : I just performed Check the meson-log.txt, the libv4l2 check need to say yes, and for that you need appropriate header (-dev packages I mentioned earlier).
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
This post was updated on .
Yes, I saw meson-log.txt. libv4l2 was not detected.
I installed libv4l-dev. sudo apt-get install libv4l-dev
meson setup --wipe build/
Now lib4l2 was detected. Below is snippet of attached meson-logs.txt.
Dependency libv4l2 found: YES (cached)
|
Free forum by Nabble | Edit this page |