Created
August 3, 2020 05:56
-
-
Save sbliven/cb11583b982f4ebb55b0214eb6cd0b99 to your computer and use it in GitHub Desktop.
Convert a VCD .dat file to .mp4 video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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