v4l2src fail - but could be buggy driver

Nicolas Dufresne nicolas at ndufresne.ca
Mon Jun 12 19:52:58 UTC 2023


Hi,

Le dimanche 11 juin 2023 à 22:45 +0100, Peter Allen via gstreamer-devel a
écrit :
> Hi All,
> 
> I am attempting to use gstreamer with a camera I've had to write the driver
> for on a relatively untested arm board (an Allwinner S3). And guess what -
> I've got issues :)
> 
> The camera has an onboard ISP, so produces UYVY 422p on Mipi CSI, and the MIPI
> peripheral has the capability to convert between different YUV formats In fact
> interleaved UYVY comes out in a really weird byte order, so I've been using
> NV12 or NV16 as it is correct. When I use v4l2-ctl to produce the stream, all
> is well:
> 
> v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=NV12 --stream-mmap
> --stream-count=600 --silent -d /dev/video0 --stream-to=MyFile.raw
> 
> However when I try to do similar things with gstreamer, I have issues:
> gst-launch-1.0 -ve v4l2src device=/dev/video0 ! video/x-
> raw,width=1280,height=720,framerate=60/1,format=NV12 ! queue ! filesink
> location=GstNV12Raw.raw
> 
> gives:
> ot at openhd-x20dev:/home/openhd# gst-launch-1.0 -ve v4l2src device=/dev/video0 !
> video/x-raw,width=1280,height=720,framerate=60/1,format=NV12 ! queue !
> filesink location=GstNV12Raw.raw
> [ 2048.216638] hdzerocam_open(816)
> [ 2048.219869] hdzerocam_fill_fmt(805): HDZero fill
> Setting pipeline to PAUSED ...
> Pipeline is live and does not need PREROLL ...
> Pipeline is PREROLLED ...
> Setting pipeline to PLAYING ...
> New clock: GstSystemClock
> /GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw,
> width=(int)1280, height=(int)720, framerate=(fraction)60/1,
> format=(string)NV12, interlace-m[ 2048.274807] hdzerocam_get_fmt(710)
> ode=(string)progressive, colorimetry=(string)2:0:0:0
> /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/[
> 2048.290307] hdzerocam_s_stream(755)
> x-raw, width=(int)1280, height=(int)720, framerate=(fraction)60/1,
> format=(string)NV12, interlace-mode=(string)progressive,
> colorimetry=(string)2:0:0:0
> /GstPipeline:pipeline0/GstQueue:queue0.[ 2048.309943] hdzerocam_s_stream(755)
> GstPad:src: caps = video/x-raw, width=(int)1280, height=(int)720,
> framerate=(fraction)60/1, format=(string)NV12, interlace-
> mode=(string)progressive, colorimetry=(string)2:0:0:0
> /GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/x-raw,
> width=(int)1280, height=(int)720, framerate=(fraction)60/1,
> format=(string)NV12, interlace-mode=(string)progressive,
> colorimetry=(string)2:0:0:0
> /GstPipeline:pipeline0/GstQueue:queue0.GstPad:sink: caps = video/x-raw,
> width=(int)1280, height=(int)720, framerate=(fraction)60/1,
> format=(string)NV12, interlace-mode=(string)progressive,
> colorimetry=(string)2:0:0:0
> /GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-
> raw, width=(int)1280, height=(int)720, framerate=(fraction)60/1,
> format=(string)NV12, interlace-mode=(string)progressive,
> colorimetry=(string)2:0:0:0
> 0:00:00.159656333   443   0x5b4c58 WARN              video-info video-
> info.c:204:validate_colorimetry: Need to specify a color matrix when using YUV
> format (NV12)
> 0:00:00.159812875   443   0x5b4c58 WARN              video-info video-
> info.c:520:gst_video_info_from_caps: invalid colorimetry, using default
> 0:00:00.161243625   443   0x5b4c58 WARN              video-info video-
> info.c:204:validate_colorimetry: Need to specify a color matrix when using YUV
> format (NV12)
> 0:00:00.161350333   443   0x5b4c58 WARN              video-info video-
> info.c:520:gst_video_info_from_caps: invalid colorimetry, using default
> 0:00:00.161923083   443   0x5b4c58 WARN              video-info video-
> info.c:204:validate_colorimetry: Need to specify a color matrix when using YUV
> format (NV12)
> 0:00:00.162008667   443   0x5b4c58 WARN              video-info video-
> info.c:520:gst_video_info_from_caps: invalid colorimetry, using default
> 0:00:00.162248167   443   0x5b4c58 WARN              video-info video-
> info.c:204:validate_colorimetry: Need to specify a color matrix when using YUV
> format (NV12)
> 0:00:00.162310958   443   0x5b4c58 WARN              video-info video-
> info.c:520:gst_video_info_from_caps: invalid colorimetry, using default
> 0:00:00.172358583   443   0x5b4c58 WARN          v4l2bufferpool
> gstv4l2bufferpool.c:814:gst_v4l2_buffer_pool_start:<v4l2src0:pool0:src>
> Uncertain or not enough buffers, enabling copy threshold
> 0:00:00.205794042   443   0x5b4c58 ERROR              videometa
> gstvideometa.c:242:default_map: plane 1, no memory at offset 1382400
> 0:00:00.205912917   443   0x5b4c58 ERROR                default video-
> frame.c:168:gst_video_frame_map_id: failed to map video frame plane 1
> 0:00:00.206110167   443   0x5b4c58 ERROR         v4l2bufferpool
> gstv4l2bufferpool.c:161:gst_v4l2_buffer_pool_copy_buffer:<v4l2src0:pool0:src>
> could not map buffer
> 0:00:00.206237458   443   0x5b4c58 ERROR         v4l2bufferpool
> gstv4l2bufferpool.c:2071:gst_v4l2_buffer_pool_process:<v4l2src0:pool0:src>
> failed to copy buffer

I think GStreamer is trying to copy the image to remove the HW specific padding.
The reported stride (bytesperline in V4L2) might be a little bit off. The v4l2-
ctl utilise does not do line per line copies, so it does not use it. If you can
build v4l2-utils and use v4l2-tracer tracer ... to spy on the exchange between
gst and the kernel I'd be able to tell.

An alternative is to enable some kernel debug, which should be sufficient for
this case:

sudo su -c "echo 0xff > /sys/class/video4linux/video0/dev_debug"

Run gst, and then the output will be in "dmesg". Don't forget to echo 0, or to
reboot, this can slow down a lot the driver.

Nicolas

> 0:00:00.206398958   443   0x5b4c58 WARN                 basesrc
> gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0> error: Internal data stream
> error.
> 0:00:00.206471292   443   0x5b4c58 WARN                 basesrc
> gstbasesrc.c:3127:gst_base_src_loop:<v4l2src0> error: streaming stopped,
> reason error (-5)
> ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data
> stream error.
> Additional debug info:
> ../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop ():
> /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
> streaming stopped, reason error (-5)
> Execution ended after 0:00:00.057735709
> Setting pipeline to NULL ...
> Freeing pipeline ...
> 
> ----------------------------------------------------
> i'm well aware that this might not be gstreamer's issue, but I'm really
> struggling to understand what  is going on with
> gstvideometa.c:242:default_map: plane 1, no memory at offset 1382400
> 
> Full GST_DEBUG_LEVEL=4 attached in case it helps.
> 
> Can anyone shed some light?
> Thank you
> Pete

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230612/4b7c7210/attachment-0001.htm>


More information about the gstreamer-devel mailing list