[Cin] Analog S-Video or HDV capture via HDMI-USB to FFV1.mkv in realtime

Terje J. Hanssen terjejhanssen at gmail.com
Thu Feb 2 01:46:19 CET 2023

I have no plan to compete with our National Library located locally here :)

but I prepare myself to test and use one method left with regards to 
"Personal Video Archiving".

Therefore I have ordered two selected, inexpensive devices (the urls 
here are just for English language):

1) Capture Card USB HDMI 4K to 1080P USB-C adapter (Speedy USB 
3.2/3.1/3.0, 60 Hz and 1080p FHD.)

  * Fluid video recordings without delays or distortions during live
  * Linux not mentioned, but assumed this is a standard supported UVC.
    OBS and VLC is mentioned.

2) Scart AV SV to HDMI Converter Switcher S Video Composite RCA DVD HD 
TV adapter (3-4 weeks delivery time

  * The 3-in-1 S-/video/RCA/SCART to HDMI converter is a universal
    converter for analog video input to HDMI output.
  * Analog to digital converter (ADC), 10 bits maximum 1,62 MSPS sampling,

Q I have not yet found a definitiv ffmpeg FFV1 v 3 syntax guide for SD 
and HDV capturing and hope for suggestions and comments here!?

3.1 FFmpeg recipe (PAL)

    ffmpeg -i VIDEO_IN \

        -c:v ffv1 -level 3 -coder 1 -context 0 -slices 24 -slicecrc 1 \
        -color_primaries bt470bg \
        -color_trc bt709 \
        -colorspace bt470bg \
        -color_range mpeg \
        -map 0 \
        -top 1 \
        -c:a copy \
        -g 1 -pix_fmt + \

3.2 Reference Example

     Copy audio "as-is" and use FFV1.3 as video codec.

     Parameters are 8 threads, coder=1, context=1, GOP-size=1, 24 slices 
and slice-CRC on:

     ffmpeg -i <input_video>     \
         -acodec   copy          \
         -vcodec   ffv1 -level 3 \
         -threads  8             \
         -coder    1             \
         -context  1             \
         -g        1             \
         -slices  24             \
         -slicecrc 1             \

3.3 Various Encoding examples for Video capture from USB camera /dev/video0:

ffmpeg -f v4l2 -framerate 25 -video_size 720x576 -i /dev/video0 

ffmpeg -f v4l2 -framerate 25 -video_size 720x576 -i /dev/video0 -codec:v 
ffv1 -codec:a pcm_s16le \
     -f matroska  output_video.mkv

Check that video is captured properly using ffplay:

ffmpeg -ar 44100 -thread_queue_size 1024 -f alsa -i $AUDIO \
     -r 25 -thread_queue_size 1024 -i $VIDEO \
     -codec copy -f matroska  - | ffplay -

Check the overall flow using ffplay before capturing:

ffmpeg -ar 44100 -thread_queue_size 1024 -f alsa -i $AUDIO \
     -itsoffset -0.5 -r 25 -thread_queue_size 1024 -i $VIDEO \
     -filter_complex 'channelmap=FL-0' -filter_complex 
'crop=w=700:h=556:x=8:y=0' \
     -map 1:v  -map 0:a -codec:v ffv1 -codec:a pcm_s16le \
     -f matroska  - | ffplay -

4, Regarding FFV1 lossless compression in realtime
Comparison tests (2013/2015) have shown that FFV1 produced the smallest 
files at the fastest speed. It can be used to capture SD material in 
realtime, and HD possibly, too. This according to a 2012/2015 article, 
where I have extracted the results for FFV1 v.3 in the tables below:


NOTE: This is a consumer grade, off-the-shelf PC setup.

CPU: 	Intel(R) QuadCore(TM) i7-2600K CPU @ 3.40GHz
RAM: 	8 GB
Disk: 	Intel SSDSA2CW080G3 (SSD)
Operating System: 	GNU/Linux (Xubuntu 12.04.1, 64bit)
Transcoding tool: 	FFmpeg (version git N-59183-g3e62654, Dec 17 2013)

Video source file: 	VQEG reference video "football" 
<http://media.xiph.org/video/derf/y4m/football_422_ntsc.y4m> (NTSC-SD, 
720x486px, 30fps, yuv422p, 8bpc)
Codec 	Encoding 	Decoding 	Filesize 	% of uncompressed 	Implementation 
(version 3) 	216 fps 	277 fps 	111 MiB 	46.1% 	libavcodec (FFmpeg) 
<http://en.wikipedia.org/wiki/Libavcodec> 	log 

Video source file: 	SVT reference video "park joy" 
(full-HD/1080p, 1920x1080px, 50fps, yuv420p, 8bpc)
Codec 	Encoding 	Decoding 	Filesize 	% of uncompressed 	Implementation 
(version 3) 	31 fps 	63 fps 	879 MiB 	57.2% 	libavcodec (FFmpeg) 
<http://en.wikipedia.org/wiki/Libavcodec> 	log 

PAL-SD 720x576 stored as YUV422, 10 bpc (bits per component), instead of 
the tested 8 bpc above, seems to me would have enlarged the the 
filesizes with about 25%, or to about 40 GB/hr with FFV1 lossless 

Although the FFV1 compression results above obviously used yuv422p, 8bps 
source SD and FHD files as input, it seems for me that the encoding 
speeds at 216 fps and 31 fps for SD and FHD respectively, assumingly 
should manage realtime FFV1 encoding and streaming of PAL SD and HDV at 
25 fps as well, especially with a faster i7-6700 x 8 cpu. Comments here?

5. Related 2021-[Cin] threads as background references

[Cin] hdmi capture card (with v4l2)

[Cin] offtopic: Digitize and record Video with A/D USB adapters

[Cin] offtopic: HDMI capture

[Cin] Is SD and HD 422 Video Capture obtainable with V4L(2)?

[Cin] Uncompressed video to lossless compression FFV1/MKV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20230202/2df28893/attachment-0001.htm>

More information about the Cin mailing list