On Sat, 14 Dec 2024 09:06:15 +0100,
Stefan Hagen <sh+openbsd-m...@codevoid.de> wrote:
> 
> Kirill A. Korinsky wrote (2024-12-14 00:46 CET):
> > On Fri, 13 Dec 2024 23:54:31 +0100,
> > Stefan Hagen <sh+openbsd-m...@codevoid.de> wrote:
> > > $ ffplay -f v4l2 -list_formats all -i /dev/video0
> > > [video4linux2,v4l2 @ 0x854a377c400] Compressed:       mjpeg :             
> > >    MJPEG : 1280x720 640x360 640x480 848x480 960x540 1920x1080 2560x1440 
> > > 2592x1944
> > > [video4linux2,v4l2 @ 0x854a377c400] Raw       :     yuyv422 :             
> > >     YUYV : 640x480 640x360
> > > 
> > > In practice neither mpv, not ffmpeg/ffplay can play the mjpeg or yuyv422 
> > > stream:
> > > 
> > > $ ffplay -f v4l2 -i /dev/video0
> > > [ webcam turns on, it takes a few seconds ]
> > > [video4linux2,v4l2 @ 0xfc8c9cab400] ioctl(VIDIOC_DQBUF): Invalid argument
> > > Input #0, video4linux2,v4l2, from '/dev/video0':
> > >   Duration: N/A, bitrate: 147456 kb/s
> > >   Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 
> > > 147456 kb/s, 30 fps, 30 tbr, 1000k tbn
> > > [video4linux2,v4l2 @ 0xfc8c9cab400] ioctl(VIDIOC_DQBUF): Invalid argument
> > > [video4linux2,v4l2 @ 0xfc8c9cab400] ioctl(VIDIOC_DQBUF): Invalid argument
> > > [video4linux2,v4l2 @ 0xfc8c9cab400] ioctl(VIDIOC_DQBUF): Invalid argument
> > > ...
> > > 
> > > I assume the webcam is not sending a standard format / or our 
> > > video4linux2 is too old.
> > >
> > 
> > I had commited to uvideo.c some fixes which allows me to fix 2 of webcam
> > which I had access, and which had similar errors.
> > 
> > May I ask you which version of uvideo.c you have in your kernel? Is it 
> > v1.227?
> 
> Yes, it's v1.227.
> 
> $ video -f /dev/video0
> video: ioctl VIDIOC_DQBUF: Invalid argument
> 
> In my mail, I pasted the wrong ffmpeg output. I meant to paste the mjpeg 
> example, which gives me a different error:
> 
> $ ffplay -f v4l2 -input_format mjpeg -i /dev/video0 
> ffplay version 6.1.2 Copyright (c) 2003-2024 the FFmpeg developers
>   built with OpenBSD clang version 16.0.6
>   configuration: --enable-shared --arch=amd64 --cc=cc --cxx=c++ 
> --enable-debug --disable-stripping --disable-indev=jack --disable-outdev=sdl2 
> --disable-vulkan --enable-fontconfig --enable-frei0r --enable-gpl 
> --enable-ladspa --enable-libaom --enable-libass --enable-libdav1d 
> --enable-libfontconfig --enable-libfreetype --enable-libfribidi 
> --enable-libgsm --enable-libmp3lame --enable-libopus --enable-libspeex 
> --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx 
> --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid 
> --enable-libzimg --enable-nonfree --enable-openssl --enable-libvidstab 
> --extra-cflags='-I/usr/local/include -I/usr/X11R6/include' 
> --extra-libs='-L/usr/local/lib -L/usr/X11R6/lib' --extra-ldsoflags= 
> --mandir=/usr/local/man --objcc=/usr/bin/false --optflags='-O2 -pipe -g 
> -Wno-redundant-decls'
>   libavutil      58. 29.100 / 58. 29.100
>   libavcodec     60. 31.102 / 60. 31.102
>   libavformat    60. 16.100 / 60. 16.100
>   libavdevice    60.  3.100 / 60.  3.100
>   libavfilter     9. 12.100 /  9. 12.100
>   libswscale      7.  5.100 /  7.  5.100
>   libswresample   4. 12.100 /  4. 12.100
>   libpostproc    57.  3.100 / 57.  3.100
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoringB f=0/0   
> [mjpeg @ 0x22f5cfa5800] No JPEG data found in image
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoring
> [mjpeg @ 0x22f5cfa5800] No JPEG data found in image
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoringB f=0/0   
> [mjpeg @ 0x22f5cfa5800] No JPEG data found in image
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoringB f=0/0   
> [mjpeg @ 0x22f5cfa5800] No JPEG data found in image
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoringB f=0/0   
> [mjpeg @ 0x22f5cfa5800] No JPEG data found in image
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoringB f=0/0   
> [mjpeg @ 0x22f5cfa5800] No JPEG data found in image
> [mjpeg @ 0x22f5cfa5800] Found EOI before any SOF, ignoring
> ...
> 
> Below is a dmesg with UVIDEO_DEBUG enabled, in case you're interested to 
> look at it.
> 

Here a blind shot. Future debug requires uvideo_debug = 2 which very noise.

Index: sys/dev/usb/uvideo.c
===================================================================
RCS file: /home/cvs/src/sys/dev/usb/uvideo.c,v
diff -u -p -r1.228 uvideo.c
--- sys/dev/usb/uvideo.c        14 Dec 2024 09:58:04 -0000      1.228
+++ sys/dev/usb/uvideo.c        14 Dec 2024 11:32:41 -0000
@@ -2112,12 +2112,10 @@ uvideo_vs_cb(struct usbd_xfer *xfer, voi
        usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
 
        DPRINTF(2, "%s: *** buffer len = %d\n", DEVNAME(sc), len);
-       if (len == 0)
-               goto skip;
 
        for (i = 0; i < sc->sc_nframes; i++) {
                frame = ixfer->buf + (i * sc->sc_vs_cur->psize);
-               frame_size = ixfer->size[i];
+               frame_size = min(len, ixfer->size[i]);
 
                if (frame_size == 0)
                        /* frame is empty */
@@ -2128,7 +2126,7 @@ uvideo_vs_cb(struct usbd_xfer *xfer, voi
                        break;
        }
 
-skip:  /* setup new transfer */
+       /* setup new transfer */
        uvideo_vs_start_isoc_ixfer(sc, ixfer);
 }
 

-- 
wbr, Kirill

Reply via email to