Skip to content

Instantly share code, notes, and snippets.

@kuntalchandra
Last active January 12, 2018 05:20
Show Gist options
  • Save kuntalchandra/9bc89f8b6425a45bb3f96fa3ca5ac0d4 to your computer and use it in GitHub Desktop.
Save kuntalchandra/9bc89f8b6425a45bb3f96fa3ca5ac0d4 to your computer and use it in GitHub Desktop.
Convert mkv file to avi file. Applicable to a list of files. Uses xargs for parallel processing.
#!/bin/bash
shopt -s nullglob
source_files=(/home/kuntal/Videos/Tom.and.Jerry.The.Golden.Collection.Volume.One.720p.BluRay/*.mkv)
convert() {
source_file=$(echo $0 | cut -f1 -d:)
target_file=$(echo $0 | cut -f2 -d:)
echo "source file: $source_file"
ffmpeg -i $source_file $target_file
echo "converted file: $target_file"
sleep 1
}
export -f convert
for source_file in "${source_files[@]}"; do
filename="${source_file%.*}"
target_file="$filename.avi"
echo "$source_file:$target_file"
done | xargs -t -I{} --max-procs=3 bash -c convert "{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment