Last active
July 28, 2023 10:26
-
-
Save mandymozart/79300a9d6dc10cb1a9e0d0b7bded0616 to your computer and use it in GitHub Desktop.
Batch convert all files in ${directory} from MPG Sony AVCHD and copy to ${out}.
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
#!/usr/bin/bash | |
# input files directory | |
directory=$1 | |
# converted files directory | |
out=$2 | |
echo "Batch convert all files in ${directory} from MPG Sony AVCHD and copy to ${out}" | |
echo "------------------------------------------------------------------------------" | |
[[ -z "$directory" ]] && { echo "Error: directory required"; exit 1; } | |
[[ -z "$out" ]] && { echo "Error: out required"; exit 1; } | |
mkdir -p $out | |
for f in $directory/*.MPG; | |
do | |
if [ -f "$f" ] | |
then | |
echo "Processing $f file..." | |
file_output=$(basename -- $f) | |
ffmpeg -i $f -c:v libx264 -vf yadif -c:a aac -crf 15 -preset:v veryslow "${out}/${file_output%.MPG}.mp4" | |
RC=$? | |
if [ "${RC}" -ne "0" ]; then | |
# Do something to handle the error. | |
exit 1 | |
else | |
# Everything was ok. | |
echo "Copied file to ${out}/${file_output%.MPG}.mp4" | |
fi | |
else | |
echo "Warning: Some problem with \"$f\"" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment