【问题标题】:Recursively re-encode .mp4 files to new copies of .mp4 and convert .mp4 to .webm and .ogg using ffmpeg递归地将 .mp4 文件重新编码为 .mp4 的新副本,并使用 ffmpeg 将 .mp4 转换为 .webm 和 .ogg
【发布时间】:2016-11-17 06:53:06
【问题描述】:

.mp4 文件中有大约 300 个视频,我需要将它们重新编码为新的 .mp4 文件并将它们转换为 .webm.ogg 文件。

我想在命令行使用ffmpeg 执行此操作,并且我有以下命令将.mp4 转换为.webm

find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -vcodec libvpx -acodec libvorbis -cpu-used 5 -threads 8 "${0%%.mp4}.webm"' {} \;

谁能帮我将此命令修改为两个单独的命令,一个用于.mp4 -> .mp4(文件名后缀为-2),另一个用于.mp4 -> .ogg

谢谢。

【问题讨论】:

    标签: ffmpeg mp4 ogg webm


    【解决方案1】:

    好吧,因为我没有得到任何回复,所以我自己找到了答案。

    因此,为了其他希望做同样事情的人的利益,这里是我整理的各种命令:

    webm
    find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -vcodec libvpx -acodec libvorbis -vf scale=-1:480 -cpu-used 5 -threads 8 "${0%%.mp4}.webm"' {} \;
    ogv
    find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -vcodec libtheora -acodec libvorbis -vf scale=-1:480 -cpu-used 5 -threads 8 "${0%%.mp4}.ogv"' {} \;
    flv
    find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -c:v libx264 -ar 22050 -crf 28 -vf scale=-1:480 -cpu-used 5 -threads 8 "${0%%.mp4}.flv"' {} \;
    mp4
    find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -vcodec libx264 -vf scale=-1:480 -cpu-used 5 -threads 8 "${0%%.mp4}-2.mp4"' {} \;
    jpg
    find ./ -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -ss 00:00:10 -vframes 1 -r 1 -vf scale=-1:480 -f image2 "${0%%.mp4}.jpg"' {} \;
    

    请注意,我添加了标志-vf scale=-1:480,它按比例缩放视频。我已经将高度设置为 480px 并自动计算宽度。

    另外,请注意,我还包含了每个视频的屏幕截图导出。在视频的第 10 秒进行捕获并保存为 jpeg 文件。

    如果您想保留原始文件的日期,以便新版本(.webm、.ogv、.mp4、.flv)具有相同的修改日期,您可以使用touch 命令,如下所示:

    touch -r oldfile newfile

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-22
      • 1970-01-01
      • 2019-04-15
      • 2020-02-18
      • 2018-05-10
      • 2018-06-09
      • 2015-08-20
      • 2014-11-04
      相关资源
      最近更新 更多