On Wednesday 26 September 2007, Jörg Hermsdorf wrote:
> Today I tried to use ffmpeg to capture and live transcode the stream. It
> seems like ffmpeg is supposed to capture from v4l2 devices, here is the
> result of my attempts so far.
>
> I tried to capture at different sizes and to different output formats,
> capturing starts always fine but after some time (varies, sometimes after
> just 2 seconds, sometimes after 2 minutes) I always get the same error:
>
> # ffmpeg -v 100 -f video4linux2 -s 320x240 -i /dev/video0 -f audio_device
> -i /dev/dsp2 -f m4v test.m4v FFmpeg version SVN-r9778, Copyright (c)
> 2000-2007 Fabrice Bellard, et al. configuration: --prefix=/usr
> --mandir=/usr/share/man --libdir=/usr/lib64 --shlibdir=/usr/lib64
> --enable-pthreads --enable-libogg --enable-libvorbis --enable-libmp3lame
> --enable-libfaad --enable-libfaadbin --enable-libfaac --enable-libxvid
> --enable-libx264 --enable-liba52 --enable-liba52bin --enable-pp
> --enable-shared --enable-dc1394 --enable-libtheora --enable-gpl libavutil
> version: 49.4.1
>   libavcodec version: 51.40.4
>   libavformat version: 51.12.1
>   built on Jul 29 2007 17:41:31, gcc: 4.2.1 20070705 (prerelease) (SUSE
> Linux) [video4linux2 @ 0x2b8bb4a4f220][3]Capabilities: 4000001
> [video4linux2 @ 0x2b8bb4a4f220]The V4L2 driver set input_id: 0, input:
> Camera 1 Input #0, video4linux2, from '/dev/video0':
>   Duration: N/A, bitrate: 30720 kb/s
>   Stream #0.0, 1/1000000: Video: rawvideo, yuyv422, 320x240, 1/25, 30720
> kb/s, 25.00 fps(r) File 'Downloads/uvc/test.m4v' already exists. Overwrite
> ? [y/N] y
> Output #0, m4v, to 'Downloads/uvc/test.m4v':
>   Stream #0.0, 1/90000: Video: mpeg4, yuv420p, 320x240, 1/25, q=2-31, 200
> kb/s, 25.00 fps(c) Stream mapping:
>   Stream #0.0 -> #0.0
> Press [q] to stop encoding
> ....
> [video4linux2 @ 0x2b91704f3220]The v4l2 frame is 25600 bytes, but 153600
> bytes are expected ....
> [video4linux2 @ 0x2b8bb4a4f220]The v4l2 frame is 32000 bytes, but 153600
> bytes are expected
>
> It's always the same error, ffmpeg aborts because at some point it receives
> a v4l2 frame that has a smaller size than expected. The actual frame size
> of the erroneous frame is always different (I posted two examples above) .
> So it seems to me, that's a problem with uvcvideo, which at some point just
> delivers a corrupt/incomplete frame. ffmpeg can't handle that and aborts.
> But the file that has been captured so far (until ffmpeg aborts) looks good
> and can be played with vlc, so I have hope that this issue can be fixed and
> that piping ffmpeg's output to vlc should be possible to stream my cam
> mpeg4 encoded via http.

The USB isochronous transfers are not error free. Packets can be lost, which 
result in incomplete/erroneous frames. The only way I can think of to detect 
those erroneous/incomplete frames is to look at the frame size. This can be 
done for uncompressed formats, but will obviously be useless for compressed 
format.

The driver currently handles complete and incomplete frames the same way. I 
can add a driver option to make it drop incomplete frames, returning complete 
frames only to the application. Would you be able to test that ?

Best regards,

Laurent Pinchart
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to