How to batch convert mp4 files to ogg with ffmpeg using a bash command or Ruby

前端 未结 2 1602
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 04:33

I am running a OSX, don\'t know tons about video conversions. But I have like 200 videos that are all in mp4 format and won\'t play in Firefox. I need to convert them to o

2条回答
  •  一个人的身影
    2020-12-18 05:14

    This is using Ruby, assuming the ffmpeg you used is correct:

    Dir.glob("**/*.mp4").each do |filename|
      new_filename = File.join(
        File.dirname(filename),
        "#{File.basename(filename, ".mp4")}.ogg")
      `ffmpeg -i "#{filename}" -acodec vorbis -vcodec libtheora "#{new_filename}"`
    end
    

    Dir.glob with "**/*.mp4" recursively matches all the files within subdirectories witha .mp4 extension.

提交回复
热议问题