-
Notifications
You must be signed in to change notification settings - Fork 20
FLAC Compression Guide
You may add the --ogg flag but due to a recent update to FLAC, this is no longer a requirement. (2022)
Replace "media-name" with what you want to name your recording, data information is already added to the output for convenience.
Capture + FLAC in real time may cause dropped samples if used on older lower end systems or slow storage devices.
Note: the Fsc rate of the CX Chips output is based on the NTSC composite spec, though this does not really apply to the RF capture side of things whether you're capturing an NTSC or PAL signal, it's just noted due to VHS-Decode having the -f 8fsc -f 10fsc -f 5fsc -f 4fsc sample rate input frequency options.
The convention used for FLAC compression is raw sample rate divided by 1000 so the rates are as such.
28636 for 28.6mhz 8-bit (8fsc)
35795 for 35.7mhz 8-bit (10fsc) (Removed to prevent use, due to up-sampling)
14318 for 14.3mhz 16-bit (4fsc)
17898 for 17.8mhz 16-bit (5fsc)
Thanks to Tony we have several re-sampling scripts & a breakdown of how to use GNU radio.
cat /dev/cxadc0 | flac --fast -16 --sample-rate=28636 --sign=unsigned --channels=1 --endian=little --bps=8 --blocksize=65535 --lax -f - -o media-name-28msps-8bit-cx-card.flac
cat /dev/cxadc0 | flac --fast -16 --sample-rate=40000 --sign=unsigned --channels=1 --endian=little --bps=8 --blocksize=65535 --lax -f - -o media-name-40msps-8bit-cx-card.flac
cat /dev/cxadc0 | flac --fast -16 --sample-rate=14318 --sign=unsigned --channels=1 --endian=little --bps=16 --blocksize=65535 --lax -f - -o media-name-14.3msps-16bit-cx-card.flac
cat /dev/cxadc0 | flac --fast -16 --sample-rate=17898 --sign=unsigned --channels=1 --endian=little --bps=16 --blocksize=65535 --lax -f - -o media-name-17.8msps-16bit-cx-card.flac
cat /dev/cxadc0 | flac --fast -16 --sample-rate=20000 --sign=unsigned --channels=1 --endian=little --bps=16 --blocksize=65535 --lax -f - -o media-name-20msps-16bit-cx-card.flac
flac --best --sample-rate=28636 --sign=unsigned --channels=1 --endian=little --bps=8 -f input.u8 -o "media-name-28msps-8bit-cx-card.flac"
flac --best --sample-rate=40000 --sign=unsigned --channels=1 --endian=little --bps=8 -f input.u8 -o "media-name-40msps-8bit-cx-card.flac"
flac --best --sample-rate=14318 --sign=unsigned --channels=1 --endian=little --bps=16 -f input.u16 -o "media-name-14.3msps-16bit-cx-card.flac"
flac --best --sample-rate=17898 --sign=unsigned --channels=1 --endian=little --bps=16 -f input.u16 -o "media-name-17.8msps-16bit-cx-card.flac"
flac --best --sample-rate=20000 --sign=unsigned --channels=1 --endian=little --bps=16 -f input.u16 -o "media-name-20msps-16bit-cx-card.flac"
Simple .bat scripts for batch and drag and drop use.
They are contained within the main folder but can be manually downloaded here
(Thanks to Zardoff on the Discord!) The thing to understand is that 1 second of decoded video equates to 1000 "seconds" of raw RF (whether flac or uncompressed). This is due to the fact that tools like ffmpeg comprehend the sample rate in terms of ksps rather than Msps (factor of 1000 different).
The entire tape I captured was 2hr 4min long. The RF sample I needed was from 2:03:00 to 2:04:00 🙃
First, to get the start offset in seconds (2hr * 3600sec) + (3min * 60sec) = 7380sec
Second, multiply by 1000 to scale the offset for the RF capture, 1000 * 7380sec = 7380000sec
Third, since ffmpeg likes the starting offset specified in hh:mm:ss, convert the previous result to hours, 7380000sec / 3600sec = 2050hr
Finally, run this ffmpeg command to losslessly trim the RF:
ffmpeg -i rawRFinput.flac -c copy -ss 2050:00:00 rawRFinput-cut.flac
If you wanted to specify a length for the cut portion, you would use the -t flag in ffmpeg to specify that in hh:mm:ss, again scaled by 1000.
The math worked out very neatly for this example but hopefully you get the idea