Skip to content

CVBS Composite Decode

Harry Munday edited this page Jul 25, 2023 · 25 revisions

CVBS Decode

This spin-off project uses RAW CVBS captures and uses the signal processing and time base correction code, from vhs-decode & ld-decode there is no de-modulation like FM media.

cvbs-decode-ld-tools

CVBS an abrevation,

Composite Video Baseband Signal. (also lesser used: colour, video, blanking, and sync)

Baseband means a de-modulated signal off a recorded medium or a non-modulated live signal directly off a camera or media generation device.

Baseband signals are ready for direct use for audio this means a speaker and for video used to be an analogue analogue CRT TV set now its all on analogue to digital converter ICs.

Composite analogue video signals have been used from the pre-digital era to early digital equipment, developed in the 1950s and in full use from the 1960s to even today analogue systems using the ''Yellow RCA jack'' on consumer equipment and a BNC jack on prosumer/broadcast equipment.

S-Video is just composite Luminance with the Chromance modulated this minimizes colour interference during transport inside a cable with a pair of 2 shield cables shielded S-Video cable or 2 separate BNC cables then the chroma is demodulated at the input device level, there are 3 versions of this standard.

CVBS Resolution Standards

Signal Format Resolution Field System TV System Aspect Ratio RF Capture Support Decoding Support
CVBS 525 Lines Interlaced 525 NTSC 4:3 / 16:9 Yes* Yes*
CVBS 625 Lines Interlaced 625 PAL 4:3 / 16:9 Yes* Yes*
CVBS 240p 240 Lines Progressive NTSC 4:3 / 16:9 Yes* Yes*
CVBS 288p 288 Lines Progressive PAL 4:3 / 16:9 Yes* Yes*
960h CCTV 960 x 576 Interlaced N/A 16:9 Only Yes* Not Tested

Capturing RAW CVBS

CX Cards can try to switch back into standard mode causing wavy, jiggling, and loss of vertical sync frames, however if the card is in a fixed low gain state (level 0 / sixdb off) it is possible to get clean stable captures.

The DomesDayDuplicator's input filtering is not suited for said signal range, the input filtering stage needs to be modified currently, this does not work well as it captures the signal improperly.

There is also using a T adaptor to feed a secondary signal via waveform generator to keep CX Cards in raw output mode, then in post to low pass filter it and then decode it.

Installation

cvbs-decode is inside the vhs-decode install.

However you might need to do:

python3 setup.py build_ext --inplace

That's it you are ready to use CVBS-Decode!

Usage

Currently, this decoder will work just fine with stable signals and live media.

Example Usage Command:

./cvbs-decode --debug --pal -A --cxadc composite-test.u8 composite-test

To stop the decode press Ctrl+C

Extract VBI Data to .JSON:

ld-process-vbi composite-test.tbc

Output

cvbs-decode outputs 3 files

filename.tbc - Luminance & Chrominance Image Data

filename.tbc.json - Frame Descriptor Table (Resolution/Dropouts/SNR/Frames/VBI Data)

filename.log - Timecode Indexed Action/Output Log

Inspect TBC and adjust inside ld-analyse

ld-analyse composite-test.tbc

Click the link for the full list, the below are just basic usage commands only.

Set Input Frequency

Just like vhs-decode & ld-decode the default is 40msps 8-bit/10-bit/16-bit input.

Captures can be FLAC compressed (.cvbs) or Uncompressed .u8/u16 etc

-f Frequency Adjust in integers of hz, mhz, ghz or 4fsc/5fsc/8fsc/10fsc

--cxadc 28.6 MHz/8-bit (8fsc) Stock Crystal Native 8xFsc 8bit Unsigned Sampling Mode

--cxadc3 35.8 MHz/8-bit (10fsc) Stock Crystal Native 4xFsc 16bit Filtered Vertical Blanking Interval Data (Not Recommeded for capture due to up-sampling)

--10cxadc 14.3 MHz/16-bit (4fsc) Stock Crystal 1.25x 8xFsc 8bit Unsigned Sampling Mode

--10cxadc3 17.9 MHz/16-bit (5fsc) Stock Crystal 1.25x 4xFsc 16bit Filtered Vertical Blanking Interval Data

Set TV System

-n NTSC

--NTSCJ NTSC-J

-p PAL

--pm PAL-M

Decode Control

--debug Enables debug detailed logging output.

-A Automatic Sync Detection (Currently Mandatory For CVBS-Decode to work)

-S Seek Frame of Capture

--right_hand_hsync Use right-hand horizontal sync detection.

--ct Chroma Trap, cleans up chroma interference on the luma channel.

--sl Defines sharpness by default this is set to 0. (0-100 Range)

--notch Define the centre frequency for the optional built-in notch "bandpass" filter.

--notch_q defines the Q factor Intended primarily for reducing noise from interference however, the decoder logic already compensates based on tape type and TV System values.

Time Base Corrected Output

The Composite signal is stored in a single .tbc

This is a lossless digital file of the entire baseband composite signal like a D2/D3 digital tape.

Full 4fsc 1135x625 PAL (17727262 hz) (25i) (4.2GB/min) (560mbps)

Full 4fsc 910x525 NTSC (14318181 hz) (29.97i) (3.4GB/min) (453mbps)

Issues

Chroma issues with NTSC VHS use ntsc-phase-comp with chroma-decoder.

CVBS-Decode is not like ld-decode or vhs-decode so unstable scorces will most likey require tinkering.

Export to video file

cvbs-decode-3d

CVBS-Decode is the same workflow as Laserdisc's in with LD-Decode (without audio etc) using the suite of ld-tools.

ld-chroma-decoder is used to render the TBC to a full-colour video file you can render to y4m or pipe to FFmpeg.

The chroma-decoder can use over 20~35GB of ram if available and can run faster then real-time on fairly modern systems.

The decoder has lots of options that can be tweaked but the list of pre-made commands below will get you started with a good basic export with proper interlaced flagging.

Use ld-chroma-decoder -h to list all the options available to the decoder.

Replace INPUT.tbc and OUTPUT.mkv with your desired names.

Note

For standard output this list of export commands is provided you only need to change setdar=4/3 to setdar=16/9 for widescreen content.

Pre-Made Command List

(Y4M Only*) you can use these 2 commands.

NTSC

ld-chroma-decoder --ffll 1 --lfll 259 --ffrl 2 --lfrl 525 --decoder ntsc3d -p y4m -q INPUT.tbc OUTPUT.mov

PAL

ld-chroma-decoder --ffll 2 --lfll 308 --ffrl 2 --lfrl 620 --decoder transform3d -p y4m -q INPUT.tbc OUTPUT.mov

Example To Update Later

FFV1 (4:2:2) (Lossless Compressed)

NTSC

ld-chroma-decoder --decoder ntsc3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v ffv1 -level 3 -coder 1 -context 1 -g 1 -slicecrc 1 -vf setfield=tff -flags +ilme+ildct -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -color_range tv -pix_fmt yuv422p10le -vf setdar=4/3,setfield=tff OUTPUT.mkv

PAL

ld-chroma-decoder --decoder transform3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v ffv1 -level 3 -coder 1 -context 1 -g 1 -slicecrc 1 -vf setfield=tff -flags +ilme+ildct -color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg -color_range tv -pix_fmt yuv422p10le -vf setdar=4/3,setfield=tff OUTPUT.mkv

V210 (4:2:2) (Uncompressed)

NTSC

ld-chroma-decoder --decoder ntsc3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v v210 -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv422p10le -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -color_range tv -vf setdar=4/3,setfield=tff OUTPUT.mov

PAL

ld-chroma-decoder --decoder transform3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v v210 -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv422p10le -color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg -color_range tv -vf setdar=4/3,setfield=tff OUTPUT.mov

ProRes HQ (4:2:2) (Visually Lossless)

NTSC

ld-chroma-decoder --decoder ntsc3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v prores -profile:v 3 -vendor apl0 -bits_per_mb 8000 -quant_mat hq -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv422p10le -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -color_range tv -vf setdar=4/3,setfield=tff OUTPUT.mov

PAL

ld-chroma-decoder --decoder transform3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v prores -profile:v 3 -vendor apl0 -bits_per_mb 8000 -quant_mat hq -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv422p10le -color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg -color_range tv -vf setdar=4/3,setfield=tff OUTPUT.mov

Y4M (4:4:4) (Uncompressed)

NTSC

ld-chroma-decoder --decoder ntsc3d -p y4m -q INPUT.tbc OUTPUT.mov

PAL

ld-chroma-decoder --decoder transform3d -p y4m -q INPUT.tbc OUTPUT.mov

V410 (4:4:4) (Uncompressed)

NTSC

ld-chroma-decoder --decoder ntsc3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v v410 -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv444p10le -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -color_range tv -vf setdar=4/3,setfield=tff OUTPUT.mov

PAL

ld-chroma-decoder --decoder transform3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v v410 -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv444p10le -color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg -color_range tv -vf -vf setdar=4/3,setfield=tff OUTPUT.mov

ProRes 4444QX (4:4:4) (Visually Lossless)

NTSC

ld-chroma-decoder --decoder ntsc3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v prores -profile:v 5 -vendor apl0 -bits_per_mb 8000 -mbs_per_slice -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv444p10le -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -color_range tv -vf -vf setdar=4/3,setfield=tff OUTPUT.mov

PAL

ld-chroma-decoder --decoder transform3d -p y4m -q INPUT.tbc| ffmpeg -i - -c:v prores -profile:v 5 -vendor apl0 -bits_per_mb 8000 -mbs_per_slice 8 -f mov -top 1 -vf setfield=tff -flags +ilme+ildct -pix_fmt yuv444p10le -color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg -color_range tv -vf -vf setdar=4/3,setfield=tff OUTPUT.mov
Clone this wiki locally