[FFmpeg-trac] #7596(undetermined:new): ffmpeg ignores v4l2 device prefs and selects a non-optimal format
FFmpeg
trac at avcodec.org
Thu Dec 6 10:30:59 EET 2018
#7596: ffmpeg ignores v4l2 device prefs and selects a non-optimal format
-------------------------------------+-------------------------------------
Reporter: colemickens | Type: defect
Status: new | Priority: normal
Component: | Version:
undetermined | unspecified
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Summary:
1. Set a v4l2 format preference.
2. Use ffmpeg or mpv to open the v4l2 device.
3. ffmpeg will use the correct resolution, but incorrect pixelformat
This results in a sub-optimal format being used, resulting in potentially
highly unfortunate end-results for the user.
Ideally:
1. ffmpeg would respect the preferences set for the device in v4l2
2. ffmpeg would choose the more optimal resolution/format for the best
result
In my case, since ffmpeg respects the resolution, but not the pixelformat,
it winds up operating at the best 1080p YUYV profile, which is 5FPS.
(compare to 1080p MJPEG which is 30FPS).
{{{
$ v4l2-ctl -d 4 --set-fmt-video=width=1920,height=1080,pixelformat=1
$ v4l2-ctl -d 4 --get-fmt-video
Format Video Capture:
Width/Height : 1920/1080
Pixel Format : 'MJPG' (Motion-JPEG)
Field : None
Bytes per Line : 0
Size Image : 4147200
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
$ mpv av://v4l2:/dev/video4
Playing: av://v4l2:/dev/video4
(+) Video --vid=1 (rawvideo 1920x1080 5.000fps)
[autoconvert] Converting yuyv422 -> yuv422p
VO: [gpu] 1920x1080 yuv422p
V: 00:00:02 / 00:00:03 (87%)
$ ffmpeg -f v4l2 -i /dev/video4 -c:v copy out.mkv
...
Input #0, video4linux2,v4l2, from '/dev/video4':
Duration: N/A, start: 23757.859585, bitrate: 165888 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080,
165888 kb/s, 5 fps, 5 tbr, 1000k tbn, 1000k tbc
...
$ ffmpeg -f v4l2 -input_format mjpeg -i /dev/video4 -c:v copy out.mkv
Input #0, video4linux2,v4l2, from '/dev/video4':
Duration: N/A, start: 23792.047911, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown),
1920x1080, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7596>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list