Skip to content

Instantly share code, notes, and snippets.

@2niuhe
Created December 17, 2022 11:51
Show Gist options
  • Save 2niuhe/2b5d68518992b13400e730c8b2c684a0 to your computer and use it in GitHub Desktop.
Save 2niuhe/2b5d68518992b13400e730c8b2c684a0 to your computer and use it in GitHub Desktop.
ffmpeg批量转换文件
#!/bin/bash
srcExt=$1
destExt=$2
srcDir=$3
destDir=$4
opts=$5
# sh ./ffmpeg_convert_file.sh mp4 mp3 ./ ./ "-f mp3"
for filename in "$srcDir"/*.$srcExt; do
basePath=${filename%.*}
baseName=${basePath##*/}
echo "Convert $filename ....\n"
ffmpeg -i "$filename" $opts "$destDir"/"$baseName"."$destExt"
done
echo "Conversion from ${srcExt} to ${destExt} complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment