Opened 11 years ago
Closed 10 years ago
#3517 closed defect (fixed)
can't set Video4Linux2 framerate
Reported by: | nunojpg | Owned by: | holden |
---|---|---|---|
Priority: | important | Component: | avdevice |
Version: | git-master | Keywords: | v4l2 regression |
Cc: | mywing81@gmail.com | Blocked By: | |
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
ffmpeg version N-61985-gd5c0036
built on Mar 31 2014 22:09:58 with gcc 4.8 (Ubuntu 4.8.2-17ubuntu2)
configuration: --enable-libx264 --enable-gpl --enable-libfaac --enable-nonfree
Linux sky5 3.13.0-20-generic #42-Ubuntu SMP Fri Mar 28 09:56:33 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
My webcam supports several framerates at 640x480.
If I try to grab it using:
./ffmpeg -f v4l2 -video_size 640x480 -framerate 5 -i /dev/video1 out1.avi
The webcam will continue with the 30fps selected (checked with v4l2-ctl -all), while ffmpeg will output the correct framerate, by droping every 5 in 6 frames.
This is a bug since ffmpeg tries to confirm the v4l2 accepts the selected framerate, but then does not select it:
./ffmpeg -f v4l2 -video_size 640x480 -framerate 3 -i /dev/video1 out3.avi
[video4linux2,v4l2 @ 0x32fca40] The driver changed the time per frame from 1/3 to 1/5
In this example v4l2 reports that the webcam does not support 3fps, and the closest value is 5fps. But 30fps will remain selected!
Current VLC HEAD does configure v4l2 framerate correctly.
Also the framerate is being set before the video_size, which introduces probably related errors.
The webcam under test supports hd1080@5fps, and hd720@10fps.
According to the following examples, it changes the framerate according to the video_size that was previously selected, and not the one that is currently being selected!
./ffmpeg -f v4l2 -video_size hd720 -framerate 10 -i /dev/video1 out.avi
(no errors)
./ffmpeg -f v4l2 -video_size hd1080 -framerate 10 -i /dev/video1 out.avi
(no errors)
./ffmpeg -f v4l2 -video_size hd1080 -framerate 10 -i /dev/video1 out.avi
[video4linux2,v4l2 @ 0x1f38a40] The driver changed the time per frame from 1/10 to 1/5
./ffmpeg -f v4l2 -video_size hd720 -framerate 10 -i /dev/video1 out.avi
[video4linux2,v4l2 @ 0x1d63a40] The driver changed the time per frame from 1/10 to 1/5
./ffmpeg -f v4l2 -video_size hd720 -framerate 10 -i /dev/video1 out.avi
(no errors)
Attachments (1)
Change History (9)
comment:1 by , 11 years ago
Keywords: | v4l2 added |
---|
comment:2 by , 11 years ago
nuno@sky5:~/Desktop/ffmpeg$ ./ffmpeg -f v4l2 -video_size 640x480 -framerate 5 -i /dev/video1 out1.avi ffmpeg version N-61985-gd5c0036 Copyright (c) 2000-2014 the FFmpeg developers built on Mar 31 2014 22:09:58 with gcc 4.8 (Ubuntu 4.8.2-17ubuntu2) configuration: --enable-libx264 --enable-gpl --enable-libfaac --enable-nonfree libavutil 52. 70.100 / 52. 70.100 libavcodec 55. 55.106 / 55. 55.106 libavformat 55. 36.100 / 55. 36.100 libavdevice 55. 11.100 / 55. 11.100 libavfilter 4. 3.100 / 4. 3.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 Input #0, video4linux2,v4l2, from '/dev/video1': Duration: N/A, start: 851.587966, bitrate: 24576 kb/s Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 24576 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc Output #0, avi, to 'out1.avi': Metadata: ISFT : Lavf55.36.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480, q=2-31, 200 kb/s, 5 tbn, 5 tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo -> mpeg4) Press [q] to stop, [?] for help *** dropping frame 2 from stream 0 at ts 0 Last message repeated 1 times *** dropping frame 3 from stream 0 at ts 1 Last message repeated 5 times *** dropping frame 4 from stream 0 at ts 2 Last message repeated 3 times *** dropping frame 4 from stream 0 at ts 2time=00:00:00.80 bitrate= 972.7kbits/s dup=0 drop=12 Last message repeated 1 times *** dropping frame 5 from stream 0 at ts 3 Last message repeated 4 times *** dropping frame 6 from stream 0 at ts 4 Last message repeated 5 times *** dropping frame 7 from stream 0 at ts 5time=00:00:01.20 bitrate= 838.5kbits/s dup=0 drop=25 *** dropping frame 8 from stream 0 at ts 6 *** dropping frame 9 from stream 0 at ts 7 Last message repeated 4 times *** dropping frame 10 from stream 0 at ts 8 Last message repeated 1 times *** dropping frame 10 from stream 0 at ts 8ime=00:00:02.00 bitrate= 635.4kbits/s dup=0 drop=34 Last message repeated 1 times *** dropping frame 11 from stream 0 at ts 9 Last message repeated 3 times *** dropping frame 12 from stream 0 at ts 10 Last message repeated 3 times *** dropping frame 12 from stream 0 at ts 10me=00:00:02.40 bitrate= 545.9kbits/s dup=0 drop=44 *** dropping frame 13 from stream 0 at ts 11 Last message repeated 3 times *** dropping frame 14 from stream 0 at ts 12 Last message repeated 2 times *** dropping frame 15 from stream 0 at ts 13me=00:00:02.80 bitrate= 565.9kbits/s dup=0 drop=52 Last message repeated 1 times *** dropping frame 16 from stream 0 at ts 14 Last message repeated 1 times *** dropping frame 17 from stream 0 at ts 15me=00:00:03.40 bitrate= 490.1kbits/s dup=0 drop=56 Last message repeated 2 times *** dropping frame 19 from stream 0 at ts 17 *** dropping frame 20 from stream 0 at ts 18 *** dropping frame 20 from stream 0 at ts 18me=00:00:04.00 bitrate= 440.6kbits/s dup=0 drop=61 *** dropping frame 21 from stream 0 at ts 19 Last message repeated 1 times *** dropping frame 22 from stream 0 at ts 20 Last message repeated 1 times *** dropping frame 23 from stream 0 at ts 21me=00:00:04.40 bitrate= 411.8kbits/s dup=0 drop=66 Last message repeated 2 times *** dropping frame 24 from stream 0 at ts 22 Last message repeated 1 times frame= 24 fps=5.3 q=2.3 Lsize= 231kB time=00:00:04.80 bitrate= 394.2kbits/s dup=0 drop=71 video:225kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.722515% Received signal 2: terminating.
nuno@sky5:~/Desktop/ffmpeg$ v4l2-ctl -d 1 --all Driver Info (not using libv4l2): Driver name : uvcvideo Card type : HD Pro Webcam C920 Bus info : usb-0000:00:1d.7-1 Driver version: 3.13.7 Capabilities : 0x84000001 Video Capture Streaming Device Capabilities Device Caps : 0x04000001 Video Capture Streaming Priority: 2 Video input : 0 (Camera 1: ok) Format Video Capture: Width/Height : 640/480 Pixel Format : 'YUYV' Field : None Bytes per Line: 1280 Size Image : 614400 Colorspace : SRGB Crop Capability Video Capture: Bounds : Left 0, Top 0, Width 640, Height 480 Default : Left 0, Top 0, Width 640, Height 480 Pixel Aspect: 1/1 Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (30/1) Read buffers : 0 brightness (int) : min=0 max=255 step=1 default=128 value=128 contrast (int) : min=0 max=255 step=1 default=128 value=128 saturation (int) : min=0 max=255 step=1 default=128 value=128 white_balance_temperature_auto (bool) : default=1 value=1 gain (int) : min=0 max=255 step=1 default=0 value=200 power_line_frequency (menu) : min=0 max=2 default=2 value=2 white_balance_temperature (int) : min=2000 max=6500 step=1 default=4000 value=4793 flags=inactive sharpness (int) : min=0 max=255 step=1 default=128 value=128 backlight_compensation (int) : min=0 max=1 step=1 default=0 value=0 exposure_auto (menu) : min=0 max=3 default=3 value=3 exposure_absolute (int) : min=3 max=2047 step=1 default=250 value=500 flags=inactive exposure_auto_priority (bool) : default=0 value=1 pan_absolute (int) : min=-36000 max=36000 step=3600 default=0 value=0 tilt_absolute (int) : min=-36000 max=36000 step=3600 default=0 value=0 focus_absolute (int) : min=0 max=250 step=5 default=0 value=0 flags=inactive focus_auto (bool) : default=1 value=1 zoom_absolute (int) : min=100 max=500 step=1 default=100 value=100
In regard to the framerate being set before the video_size:
nuno@sky5:~/Desktop/ffmpeg$ ./ffmpeg -f v4l2 -video_size hd1080 -framerate 5 -i /dev/video1 file1.avi ffmpeg version N-61985-gd5c0036 Copyright (c) 2000-2014 the FFmpeg developers built on Mar 31 2014 22:09:58 with gcc 4.8 (Ubuntu 4.8.2-17ubuntu2) configuration: --enable-libx264 --enable-gpl --enable-libfaac --enable-nonfree libavutil 52. 70.100 / 52. 70.100 libavcodec 55. 55.106 / 55. 55.106 libavformat 55. 36.100 / 55. 36.100 libavdevice 55. 11.100 / 55. 11.100 libavfilter 4. 3.100 / 4. 3.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 Input #0, video4linux2,v4l2, from '/dev/video1': Duration: N/A, start: 579.007577, bitrate: 165888 kb/s Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080, 165888 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc Output #0, avi, to 'file1.avi': Metadata: ISFT : Lavf55.36.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1920x1080, q=2-31, 200 kb/s, 5 tbn, 5 tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo -> mpeg4) Press [q] to stop, [?] for help frame= 8 fps=5.3 q=11.3 Lsize= 370kB time=00:00:01.80 bitrate=1682.4kbits/s video:364kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.584158% Received signal 2: terminating.
nuno@sky5:~/Desktop/ffmpeg$ ./ffmpeg -f v4l2 -video_size hd720 -framerate 10 -i /dev/video1 file2.avi ffmpeg version N-61985-gd5c0036 Copyright (c) 2000-2014 the FFmpeg developers built on Mar 31 2014 22:09:58 with gcc 4.8 (Ubuntu 4.8.2-17ubuntu2) configuration: --enable-libx264 --enable-gpl --enable-libfaac --enable-nonfree libavutil 52. 70.100 / 52. 70.100 libavcodec 55. 55.106 / 55. 55.106 libavformat 55. 36.100 / 55. 36.100 libavdevice 55. 11.100 / 55. 11.100 libavfilter 4. 3.100 / 4. 3.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 [video4linux2,v4l2 @ 0x1fcba40] The driver changed the time per frame from 1/10 to 1/5 Input #0, video4linux2,v4l2, from '/dev/video1': Duration: N/A, start: 591.103138, bitrate: 73728 kb/s Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 73728 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc Output #0, avi, to 'file2.avi': Metadata: ISFT : Lavf55.36.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x720, q=2-31, 200 kb/s, 5 tbn, 5 tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo -> mpeg4) Press [q] to stop, [?] for help *** dropping frame 3 from stream 0 at ts 1 *** dropping frame 4 from stream 0 at ts 2 *** dropping frame 5 from stream 0 at ts 3time=00:00:00.80 bitrate=1553.1kbits/s dup=0 drop=2 *** dropping frame 6 from stream 0 at ts 4 Last message repeated 1 times frame= 6 fps=5.7 q=4.6 Lsize= 185kB time=00:00:01.20 bitrate=1265.6kbits/s dup=0 drop=5 video:180kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.166727% Received signal 2: terminating.
If the second is considered to be a independent bug, I will open a new ticket if not fixed.
comment:4 by , 11 years ago
comment:5 by , 10 years ago
Cc: | added |
---|---|
Owner: | set to |
Reproduced by developer: | set |
Status: | new → open |
Hello, could you please test the attached patch and see if that solves the problem for you? Thanks.
by , 10 years ago
Attachment: | 0001-lavd-v4l2-revert-b1ad9312331759679a9c956233716a67ae6.patch added |
---|
comment:6 by , 10 years ago
Patch works on top of git HEAD, v4l2 now gets the correct framerate selected.
The eventually related issue I also reported is also fixed with this (regarding the message: [video4linux2,v4l2 @ 0x1d63a40] The driver changed the time per frame from 1/10 to 1/5). So related they were.
Thanks!
comment:7 by , 10 years ago
Keywords: | regression added |
---|---|
Priority: | normal → important |
Iiuc, this ticket describes a regression (since when?)
comment:8 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
The commit was reverted by Michael in 6f21fb79
To make this a valid ticket, please provide a failing command line together with the complete, uncut console output.