Skip to content

Instantly share code, notes, and snippets.

@flmmkch
Last active November 13, 2022 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flmmkch/7cb0d7998cb80a6e41be03412361bb83 to your computer and use it in GitHub Desktop.
Save flmmkch/7cb0d7998cb80a6e41be03412361bb83 to your computer and use it in GitHub Desktop.
Bash script to numerize a VHS using a Hauppauge USB-Live 2 device using ffmpeg under Linux

VHS recording: how-to

Bash script to numerize a VHS using a Hauppauge USB-Live 2 device using ffmpeg under Linux.

Usage

./vhs_rec.sh output_filename.mkv 1:45:00

Optional arguments:

  • output file name
  • duration (ffmpeg time format)

Video standard

Set the VHS_STANDARD environment variable to either :

  • secam (default)
  • pal
  • nstc

Connecting the Hauppauge device to a recorder

Photograph of the cable connection

Reference

#!/bin/bash
output="$1"
if [ -z "$output" ]; then
output="output.mkv"
fi
if [ -z "$VHS_STANDARD" ]; then
VHS_STANDARD="secam"
fi
if [ "$VHS_STANDARD" -eq "secam" ]; then
VHS_STANDARD_V4L2="SECAM"
elif [ "$VHS_STANDARD" -eq "pal" ]; then
VHS_STANDARD_V4L2="PAL"
elif [ "$VHS_STANDARD" -eq "nstc" ]; then
VHS_STANDARD_V4L2="NSTC"
fi
duration="$2"
if [ -z "$duration" ]; then
duration="02:00:00"
fi
v4l2-ctl -s "$VHS_STANDARD_V4L2"
echo "Recording for $duration as $output with standard $VHS_STANDARD"
# output format: h264 for video, opus for audio
ffmpeg \
-f alsa \
-thread_queue_size 4096 \
-i sysdefault:CARD=Cx231xxAudio \
-f video4linux2 \
-thread_queue_size 4096 \
-framerate 25 \
-channel 0 \
-i /dev/v4l/by-id/usb-Hauppauge_Hauppauge_Device_0014068359-video-index0 \
-standard "$VHS_STANDARD" \
-c:v h264 \
-b:v 2M \
-c:a libopus \
-b:a 96k \
-async 1 \
-preset faster \
-t "$duration" \
"$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment