Skip to content

RF Compression & Decompression Guide

Harry Munday edited this page Jul 27, 2023 · 21 revisions

FLAC Compression & De-Compression Guide

Previous Page RF Capture Guide

Sub-Page Speed & Decoding Testing

Next Page RF Decoding Guide

What is RF Compression & Down-Sampling?

FM RF data is just like audio data just electrical signal values digitised into bits of information, but this is just more information in a different waveform pattern than normal sound waves, as such we can use lossless audio codecs like FLAC to compress captured FM RF data down A LOT or lossy ones to just break the files in fun ways too!

Now Down-Sampling is a method of cutting file size down with controlled loss of data more accurately removing background noise or dead space for example a 10-bit ADC only has 10-bits of information but can only be saved in a 16-bit format FLAC will remove those 6 extra bits of essentially 0 value information, alongside filtering cut off removing anything else recorded outside of the real-world signal range for said particular audio or video format, simmer to how a XLR microphone will have a cut off for 75hz to remove buzzing sounds from lights

This process can be done for low bandwidth formats like HiFi FM signals without much care as only 5msps or less is needed but for video formats its more a stricter practice and the bandwidth also changes between PAL/NTSC systems on a per format basis.

Down sampling is most practical with 40msps 8-bit and 40msps 16-bit or higher rate captures from the Modified CX Cards or DomesDayDuplicator while redundant samples for initial capture is never a bad thing, for stable media it can be a waste of space.

The biggest gain here is in the limited size optical discs for archival the commands can be easily tweaked on an as-needed basis for example VHS NTSC has been resampled down to 325MB/Minute without issue, and has become common practice.

However and for unstable media it's advised to keep just a normal FLAC compressed RF without re-sampling it.

Down Sampling + FLAC Compression

Down-sampling is ideal for maximum space saving of stable media, however this is not lossless this is lossy so is not recommended unless you absolutely have to save space as this can yield upto a 10:1 ratio compared to raw captures, these values below should be taken with a grain of salt as re-sampling can very per media format and per TV system such as NTSC/PAL.

(NTSC VHS re-sampling has been fully tested)

Imgsli Slider Comparison

16msps 8-bit with FLAC compression for VHS NTSC

Runtime File Size Storage Medium Note
45min 15 GB
60min 19.44GB
75min 24.30GB 25GB M-Disk/GlassMasterDisc
90min 29.16GB S-VHS/VHS-C tape max
120min 38.88GB
150min 48.6GB 50GB M-Disk / 50GB GlassMasterDisc Max
3-hour 58.32GB VHS SP Max
240min 77.76GB
5-hour 97.2GB 100GB M-Disk Max
6-hour 116.64GB 128GB Sony Quad Layer BDXL Max / VHS LP Max

How does it work?

RF Data at 40msps in 10-bit packed --> ld-lds-converter --> 16-bit singed unpacked data --> Down Sampling via SoX or GNURadio with lowpass filtering --> 16msps 8-bit unsinged FLAC output

The benefits of this are purely for extra space savings, but can also speed up decoding and remove interference outside of the normal signal range, however for bad tapes however only standard FLAC compression is advised as frames of information can be damaged or lost entirely.

DomesDayDuplicator Normal FLAC Compression

ld-compress DdD-capture.lds

Will just compress your capture to a lossless 40msps 16-bit FLAC file in .ldf.

Linux Scripts (DomesDayDuplicator 10-bit Packed 40msps Captures)

Copy the scripts below into a text document, save and then add .sh extension to the end of the file, you can use these in any directory witch the script file is put inside of, you can name the scripts however you like but the below example is clear enough.

./40msps-DdD-16msps-8bit.sh DdD-capture.lds

Will make DdD-capture_NTSC_16msps_8-bit.flac

The scripts below automatically append the sample rate/bit-depth/TV System accordingly.

NTSC - VHS/Betamax (16msps 8-bit)

#!/bin/bash

echo "Conversion of 10-bit 40msps .lds to 8-bit 16msps NTSC .flac has started"

ld-lds-converter -i $1 | sox -r 40000000 -b 16 -c 1 -e signed -t raw - -b 8 -r 16000000 -e unsigned -c 1 -t raw - sinc -n 2500 0-7650000 | flac -8 --sample-rate=16000 --sign=unsigned --channels=1 --endian=little --bps=8 - -o $1_NTSC_16msps_8-bit.flac

PAL - VHS/BetaMax (18msps 8-bit)

#!/bin/bash

echo "Conversion of 10-bit 40msps .lds to 8-bit 18msps PAL .flac has started"

ld-lds-converter -i $1 | sox -r 40000000 -b 16 -c 1 -e signed -t raw - -b 8 -r 18000000 -e unsigned -c 1 -t raw - sinc -n 2500 0-8670000 | flac -8 --sample-rate=18000 --sign=unsigned --channels=1 --endian=little --bps=8 - -o $1_PAL_18msps_8-bit.flac

NTSC/PAL - Umatic/SVHS/SuperBeta/ED-Beta (24msps 8-bit)

#!/bin/bash

echo "Conversion of 10-bit 40msps .lds to 8-bit 24msps .flac has started"

ld-lds-converter -i $1 | sox -r 40000000 -b 16 -c 1 -e signed -t raw - -b 8 -r 24000000 -e unsigned -c 1 -t raw - sinc -n 2500 0-9400000 | flac -8 --sample-rate=20000 --sign=unsigned --channels=1 --endian=little --bps=8 - -o $1_24msps_8-bit.flac

VHS HiFi FM Audio - (S)VHS-HiFi 40msps to 10msps 8-bit

#!/bin/bash

echo "Conversion of 10-bit 40msps .lds to 8-bit 5msps .flac has started"

ld-lds-converter -i $1 | sox -r 40000000 -b 16 -c 1 -e signed -t raw - -b 8 -r 5000000 -e unsigned -c 1 -t raw - sinc -n 2500 0-3050000 | flac -8 --sample-rate=5000 --sign=unsigned --channels=1 --endian=little --bps=8 - -o $1_VHS_HiFi_5msps_8-bit.flac

Note

Video8/Hi8 hifi is in the same modulated signal as video just on different carriers so you use 1 file for both video/hifi decoding.

There will be WSL2 passthrough scripts for windows made soon.

RF Compression & Resampling Commands - Windows Users

Download ld-tools for windows rename the folder to ld-tools-suite-windows and place it in the C:/ directory or your boot drives main directory for scripts to work.

Windows scripts for CXADC Captures can be found here!

You will need tools installed as PATH which is easy to do with chocolatey.

PowerShell as an administrator

Install Choco (chocolatey package manager)

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Then you can install these tools system-wide (PATH) without any hassle.

Install FFmpeg

choco install ffmpeg

Install FLAC

choco install flac

Install SoX

choco install sox.portable

Manual .exe downloads SoX / FLAC / FFmpeg

DomesDayDuplicator

You can capture in 16-bit uncompressed or 10-bit packed

16-bit Signed to FLAC

Since this is uncompressed data it is easy to handle

ffmpeg INPUT.s16 -i -f s16le -ar 40k -ac 1 -acodec flac -compression_level 11 -f ogg OUTPUT.flac

10-bit packed to FLAC

This outputs a unpacked file in .flac (Not Actually "Compressed")

2.8GB/Min 10-bit packed to 625MB/Min 16-bit FLAC

C:\ld-tools-suite-windows\ld-lds-converter.exe -u -i INPUT.lds | ffmpeg -f s16le -ar 40k -ac 1 -i - -acodec flac -compression_level 11 -f ogg OUTPUT.ldf 

You can then compress this file to a FLAC compressed file.

ffmpeg -i INPUT.flac -f s16le -ar 40k -ac 1 -acodec flac -compression_level 11 -f ogg OUTPUT.flac

Naming & Formatting Your Files

Rename the .flac to your media format name using standard designators & standard naming guide

Page End

Sub-Page Speed & Decoding Testing

Previous Page RF Capture Guide

Next Page RF Decoding Guide

Clone this wiki locally