Skip to content

Instantly share code, notes, and snippets.

@johnnyopao
Created December 24, 2018 05:46
Show Gist options
  • Save johnnyopao/e3a372f666dab2ac60790e4308a731f9 to your computer and use it in GitHub Desktop.
Save johnnyopao/e3a372f666dab2ac60790e4308a731f9 to your computer and use it in GitHub Desktop.
ffmpeg - Convert videos to smaller scale. Clean up filenames. Backup original
for vid in */*.mp4
do
new_file_name=$(echo $vid | awk '{ gsub(/ /, "-"); gsub(/[&|\+|{|}]/, ""); gsub(/-+/, "-"); gsub(/-_-/, "-"); gsub(/(-[0-9]{3,})/, "") }; 1')
ffmpeg -i "./$vid" -filter:v "scale=w=800:h=-1" "./${new_file_name}"
backup_dir="./backup/$(dirname "$vid")"
mkdir -p $backup_dir && cp "./$vid" $backup_dir
rm "./${vid}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment