English 中文(简体)
如何使用 shash 命令 或 Ruby 将 mp4 文件批量转换成 ffmpeg 的 mp4 文件到 ogg 。
原标题:How to batch convert mp4 files to ogg with ffmpeg using a bash command or Ruby

我正在运行一个OSX, 不知道有几吨的视频转换。 但我有200个视频, 全部都是mp4格式的, 并且不会在 Firefox 播放。 我需要把它们转换成 ogg 来使用 html5 视频标签 。

这些文件都生活在一个文件夹结构中, 使文件难以一次做一个。 我希望 Bash 命令或 Ruby 命令能够通过所有子文件夹, 找到全部. mp4 s 并转换它们 。

我找到一个有关如何与谷歌合作的参考资料:http://athmasagar.wordpress.com/2011/05/12/a-bash-struty-to-comfort-mp4-files-to-oggogv/

#!/bin/bash
for f in $(ls *mp4 | sed ‘s/(.*)..*/1/’)
do
ffmpeg -i $f.mp4 -acodec vorbis -vcodec libtheora $f.ogg
done

但不知道如何将它从Linux转换成 OSx。

最佳回答
问题回答

这是使用 Ruby, 假设您使用的 ffmpeg 是正确的 :

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

**/*.mp4" 的 Dir.glob 与 **/*.mp4" 相依匹配子目录内的所有文件, 并带有 a.mp4 扩展名 。





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签