[FFmpeg-user] How to set I/O Formats and Framerates for Analog video Capture?

Terje J. Hanssen terjejhanssen at gmail.com
Sat Mar 25 01:40:58 EET 2023


To correct a typo in my first line:

.... PAL DV25 with 4:2:2 chroma subsampling ... should be PAL DV25 with 
4:2:0 chroma subsampling.


Den 24.03.2023 23:09, skrev Terje J. Hanssen:
> So far I have converted and digitized analog PAL S-video 50i using a 
> usual way to PAL DV25 with 4:2:2 chroma subsampling.
> Now I want to try if some better Video quality can be achieved by 
> using 422 lossless ffv1 compressed encoding for archiving/preserving.
>
> I continue this topic with a new thread here, on base of a long 
> enough, previous thread with a generic description of the USB3 method, 
> setup 2 Analog:
>
>     ffmpeg -hide_banner -f alsa -ac 2 -i hw:3 -f v4l2
>         -framerate 25 -video_size 720x576 -i /dev/video2 -codec:v ffv1
>         -level 3 -codec:a pcm_s16le -f matroska video-out_ffv1.mkv
>
>
> Now I have also got the final hardware devices for USB3 capture:
>
>   * ADC (Analog S-video to HDMI converter) and
>   * MS2130 UHD capture card (HDMI/USB3)
>
> https://lists.ffmpeg.org/pipermail/ffmpeg-user/2023-February/056080.html
>
> To list my questions first, before the output details below:
>
> Q1)
> I hope for help to throw more light on how to set input and output 
> formats, framerates and other parameters, preferably with ffmpeg 
> command lines examples, preferably by commenting/editing mine below, 
> as I have not found any definitive guide for this.
>
> Q2)
> The capture card supports YUY2 which apparantly is 8-bit color depth 
> and yuyv422
> Other AV parameters required/suggested and where?
>
> Q3)
> One issue as I see it, is that PAL video is 50i or 25 fps, while the 
> capture card supports 60 fps, 50 fps, 30 fps.
> As seen in the ffmpeg output samples below, 25 fps is changed to 30 fps.
> Should I therefore set 50 fps on the input side and change this to 25 
> fps and interlaced on the output side ?
>
> Q4)
> Are i.e  both the following Input parameters required?
>
>     -f v4l2 -input_format yuyv422 -video_size 720x576 -framerate 50
>
> and
>
>     -i /dev/video2 -pix_fmt yuyv422 -vf scale=720:576 -filter:v fps=25
>
>
> Q5)
> The ADC converter possibly scales up 720x576 framesize to 1080p
> How should this be verified and taken care of with ffmpeg?
>
>
> Now some technical related info extracted from the hardware devices 
> documentation:
>
> ADC (S-video to HDMI converter) :
>
>     The SCART to HDMI  converter is a universal converter for analog
>     composite input to HDMI 1080p (60Hz) output. The analog to digital
>     conversion in this module employs 10bit maximal 162MSPS  sampling,
>     black/white level expansion, color transition improvements,
>     dynamic range expansion, blue stretch, auto-detect and
>     auto-convert the composite signal to 1080p (60Hz) output. SCART
>     output video signal format: PAL (composite video + stereo Audio).
>     No need to install drivers, portable, flexible, plug and play.
>     * Provide advanced signal processiong with great precision,
>     colors, resolutions and details.
>     * Support PAL, NTSC3.58, NTSCC4.43, SECAM, PAL/M, PAL/N standard
>     TV formats input.
>     eBay url as a reference description (but not bought there):
>     https://www.ebay.com/itm/295472602625
>
>
> MS2130 UHD capture card (HDMI/USB3):
>
>     4K HDMI mini Video Capture Card HDMI To USB 3.0 Game Record 1080P
>     60FPS Output for PS4/5 Camera Laptop PC Live Streaming MS2130 YUY2
>     Real USB 3.0 Fast Speed, 1080p 60fps YUY2 Full HD,Mini
>     Portable,Plug and Play
>     Support input resolution up to 4K at 30Hz;
>     * Support output resolution up to 1080P at 60Hz YUY2;
>     * Support 24/30/36bit deep color;
>     * Support most acquisition software, such as VLC,OBS ,Amcap,
>     Wirecast,Vmix,Potplayer,etc;
>     * Support Windows,Android and MacOS;
>     * Conform to USB Video and Audio UVC standards
>     eBay url as a reference description (but not bought there):
>     https://www.ebay.com/itm/394316094286
>
>
>
> Linux system verification of the devices (just for the ms2130 capture 
> card?):
>
> dmesg | egrep "UVC|UHD"
>
>     [    2.727780] usb 2-5: Product: USB3.0 UHD
>     [    2.755718] hid-generic 0003:345F:2130.0005: hiddev97,hidraw4:
>     USB HID v1.10 Device [MACROSILICON USB3.0 UHD] on
>     usb-0000:00:14.0-5/input4
>     [    5.041941] usb 1-11: Found UVC 1.00 device USB 2.0 Camera
>     (0c45:6340)
>     [    5.154331] usb 2-5: Found UVC 1.00 device USB3.0 UHD (345f:2130)
>
>
>
> udevadm info  /dev/video2 | egrep 'DEVNAME|ID_V4L_PRODUCT'
>
>     E: DEVNAME=/dev/video2
>     E: ID_V4L_PRODUCT=USB3.0 UHD: USB3.0 UHD
>
>
> cat /proc/asound/cards | grep UHD
>
>      2 [UHD            ]: USB-Audio - USB3.0 UHD
>                           MACROSILICON USB3.0 UHD at
>     usb-0000:00:14.0-5, super speed
>
>
> arecord -l | grep UHD
>
>     card 3: UHD [USB3.0 UHD], device 0: USB Audio [USB Audio]
>
>
>
> Extract the most relevant frame formats and framerates:
>
> v4l2-ctl -D -d /dev/video2 --list-formats-ext
>
>     Driver Info (not using libv4l2):
>             Driver name   : uvcvideo
>             Card type     : USB3.0 UHD: USB3.0 UHD
>             Bus info      : usb-0000:00:14.0-5
>             Driver version: 5.14.21
>             Capabilities  : 0x84A00001
>                     Video Capture
>                     Metadata Capture
>                     Streaming
>                     Extended Pix Format
>                     Device Capabilities
>             Device Caps   : 0x04200001
>                     Video Capture
>                     Streaming
>                     Extended Pix Format
>     ioctl: VIDIOC_ENUM_FMT
>             Index       : 0
>             Type        : Video Capture
>             Pixel Format: 'YUYV'
>             Name        : YUYV 4:2:2
>                     Size: Discrete 1920x1080
>                             Interval: Discrete 0.017s (60.000 fps)
>                             Interval: Discrete 0.020s (50.000 fps)
>                             Interval: Discrete 0.033s (30.000 fps)
>                             Interval: Discrete 0.050s (20.000 fps)
>                             Interval: Discrete 0.100s (10.000 fps)
>                     ............
>
>                     Size: Discrete 1280x720
>                             Interval: Discrete 0.017s (60.000 fps)
>                             Interval: Discrete 0.020s (50.000 fps)
>                             Interval: Discrete 0.033s (30.000 fps)
>                             Interval: Discrete 0.050s (20.000 fps)
>                             Interval: Discrete 0.100s (10.000 fps)
>                     ...............
>
>                     Size: Discrete 720x576
>                             Interval: Discrete 0.017s (60.000 fps)
>                             Interval: Discrete 0.020s (50.000 fps)
>                             Interval: Discrete 0.033s (30.000 fps)
>                             Interval: Discrete 0.050s (20.000 fps)
>                             Interval: Discrete 0.100s (10.000 fps)
>                    ................
>
>
>     Extract the most relevant pixel formats:
>
>     ffmpeg -hide_banner -pix_fmts | grep yuyv
>     IO... yuyv422                3             16      8-8-8
>
>     ffmpeg -hide_banner -pix_fmts | grep yuv42
>     IO... yuv420p                3             12      8-8-8
>     IO... yuv422p                3             16      8-8-8
>     .............
>
>
> Grab and show the input of a video4linux2 device:
>
> ffplay -hide_banner -f v4l2 -framerate 25 -video_size 720x576 /dev/video2
>
>     [video4linux2,v4l2 @ 0x7f8d5c000cc0] The driver changed the time
>     per frame from 1/25 to 1/30
>     Input #0, video4linux2,v4l2, from '/dev/video2':B sq=    0B f=0/0
>       Duration: N/A, start: 785.547518, bitrate: 199065 kb/s
>       Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422,
>     720x576, 199065 kb/s, 30 fps, 30 tbr, 1000k tbn
>      010 fd=   2 aq=    0KB vq=    0KB sq=    0B f=0/0
>
>
>
>     ffplay -hide_banner -f v4l2 -framerate 25 -video_size hd1080 
> /dev/video2
>
>         [video4linux2,v4l2 @ 0x7f9040000cc0] The driver changed the
>     time per frame from 1/25 to 1/30
>         Input #0, video4linux2,v4l2, from '/dev/video2':B sq=    0B f=0/0
>           Duration: N/A, start: 10481.959842, bitrate: 995328 kb/s
>           Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422,
>     1920x1080, 995328 kb/s, 30 fps, 30 tbr, 1000k tbn
>         fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
>
>
> ----------------
>
> List supported formats for a video4linux2 device:
>
>         ffplay -hide_banner -f v4l2 -list_formats all /dev/video2
>         [video4linux2,v4l2 @ 0x7f8280000cc0] Raw       :     yuyv422
>     :           YUYV 4:2:2 : 1920x1080 1600x1200 1360x768 1280x1024
>     1280x960 1280x720 1024x768 800x600 720x576 720x480 640x480
>         /dev/video2: Immediate exit requested
>         nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0
>
>
> Grab and record the input of a video4linux2 device, leave the frame 
> rate and size as previously set:
>
> ffmpeg -hide_banner -f v4l2 -input_format yuyv422 -video_size 720x576 
> -framerate 25 -t 20 -i /dev/video2 out-720x576_ms2130.mpeg
>
>     [video4linux2,v4l2 @ 0x556074085040] The driver changed the time
>     per frame from 1/25 to 1/30
>     Input #0, video4linux2,v4l2, from '/dev/video2':
>       Duration: N/A, start: 1377.916708, bitrate: 199065 kb/s
>       Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422,
>     720x576, 199065 kb/s, 30 fps, 30 tbr, 1000k tbn
>     Stream mapping:
>       Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg1video (native))
>     Press [q] to stop, [?] for help
>     [mpeg @ 0x5560740a7a80] VBV buffer size not set, using default
>     size of 230KB
>     If you want the mpeg file to be compliant to some specification
>     Like DVD, VCD or others, make sure you set the correct buffer size
>     Output #0, mpeg, to 'out-720x576_ms2130.mpeg':
>       Metadata:
>         encoder         : Lavf59.27.100
>       Stream #0:0: Video: mpeg1video, yuv420p(tv, progressive),
>     720x576, q=2-31, 200 kb/s, 30 fps, 90k tbn
>         Metadata:
>           encoder         : Lavc59.37.100 mpeg1video
>         Side data:
>           cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0
>     vbv_delay: N/A
>     frame=  601 fps= 30 q=31.0 Lsize=    1694kB time=00:00:19.96
>     bitrate= 695.0kbits/s speed=0.997x
>     video:1679kB audio:0kB subtitle:0kB other streams:0kB global
>     headers:0kB muxing overhead: 0.867047%
>
> ffprobe -hide_banner out-720x576_ms2130.mpeg
>
>     Input #0, mpeg, from 'out-720x576_ms2130.mpeg':
>       Duration: 00:00:20.03, start: 0.533333, bitrate: 692 kb/s
>       Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 720x576 [SAR
>     1:1 DAR 5:4], 104857 kb/s, 30 fps, 30 tbr, 90k tbn
>
>
>
>
>
>
>
>
>


More information about the ffmpeg-user mailing list