简体   繁体   English

ffmpeg将.avi,.mp4,.mp3,.flv,.mkv转换为mp4

[英]ffmpeg to convert .avi, .mp4, .mp3, .flv, .mkv to mp4

I searching for a script that contains all of that attributes like the title. 我搜索包含所有属性(如标题)的脚本。

I have done one simple but that is only for one attribute so far and i do not want one script for each of all attributes to not be confused. 到目前为止,我已经完成了一个简单的操作,但这仅用于一个属性,我不希望每个属性的一个脚本都不会混淆。

Like this, running the script for like 10 minutes to see if there is any file that consist .flv and the automatic doing a convert for the file to a mp4 attribute. 像这样,运行脚本大约10分钟,以查看是否有任何包含.flv的文件,然后自动将文件转换为mp4属性。

#!/bin/bash
# Convert all flv to mp4
ext=.mp4
for file in *.flv; do
currmov=$file$ext
ffmpeg -r 15  -i $file  -b 296k -s 640x320 -vcodec mpeg4 -acodec aac $currmov
done

Thanks for help! 感谢帮助! /M /米

For all extensions: 对于所有扩展:

for file in *.{flv,avi,mp3,mkv}; do
        target="${file%.*}.mp4"
        [[ -f "$target" ]] && { echo "skipping $file - $target exists" ; continue; }
        echo ffmpeg -r 15  -i "$file"  -b 296k -s 640x320 -vcodec mpeg4 -acodec aac "$target"
done

remove the echo before ffmpeg if satisfied 如果满意,请在ffmpeg之前删除echo

You just need a second loop 您只需要第二个循环

for ext in avi mp3 flv mk4; do
    for file in *.$ext; do
        ...
    done
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM