Skip to content

Instantly share code, notes, and snippets.

@sbliven
Created August 3, 2020 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbliven/cb11583b982f4ebb55b0214eb6cd0b99 to your computer and use it in GitHub Desktop.
Save sbliven/cb11583b982f4ebb55b0214eb6cd0b99 to your computer and use it in GitHub Desktop.
Convert a VCD .dat file to .mp4 video
#!/bin/bash
# usage: vcd2mp4 output.mp4 input.dat [input2.dat...]
if [[ $# -lt 2 ]]; then
echo "usage: $0 output.mp4 input.dat [input2.dat...]" >&2
exit 1
fi
output="$1"
shift
# concatenate inputs
declare -a PARAMS
if [[ $# -gt 1 ]]; then
FILELIST="$(mktemp vcd2mp4_XXXX)"
while [[ $# > 0 ]]; do
echo "file '$1'" >> "$FILELIST"
shift
done
PARAMS+=(-f concat -safe 0 -i "$FILELIST")
else
PARAMS+=(-i "$1")
shift
fi
PARAMS+=(-vf yadif -c:v libx264 -crf 20 -c:a aac -b:a 128k -movflags +faststart)
PARAMS+=("$output")
echo -n "ffmpeg "
for param in "${PARAMS[@]}"; do echo -n "'$param':q "; done
echo
ffmpeg "${PARAMS[@]}"
code=$?
rm "$FILELIST"
exit $code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment