How do you convert an entire directory with ffmpeg?

前端 未结 26 2158
长发绾君心
长发绾君心 2020-11-22 04:33

How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?

26条回答
  •  太阳男子
    2020-11-22 05:01

    I know this might be redundant but I use this script to batch convert files.

    old_extension=$1
    new_extension=$2
    
    for i in *."$old_extension";
      do ffmpeg -i "$i" "${i%.*}.$new_extension";
    done
    

    It takes 2 arguments to make it more flexible :

    1. the extension you want to convert from
    2. the new extension you want to convert to

    I create an alias for it but you can also use it manually like this:

    sh batch_convert.sh mkv mp4
    

    This would convert all the mkv files into mp4 files.

    As you can see it slightly more versatile. As long as ffmpeg can convert it you can specify any two extensions.

提交回复
热议问题