FFmpeg 批量转换HTML5视频(mp4/webm/ogv)

现在Html5也逐渐普及了,设备对于mp4/webm/ogv的支持也逐渐广泛,但是Html5视频的转换软件却不是太多,这个Ffmpeg确实不错。而且功能也强大。

REM “H.264 / ACC”
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -y -i %1 -vcodec libx264 -vprofile high -preset slow -b:v 900k -maxrate 1200k -bufsize 1000k -vf scale=trunc(oh*a/2)*2:480 -threads 0 -acodec libvo_aacenc -b:a 128k %1.mp4

REM “Standard” web video (480p at 500kbit/s):
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -i %1 -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k %1_Standard.mp4

REM 360p video for older mobile phones (360p at 250kbit/s in baseline profile):
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -i %1 -vcodec libx264 -vprofile baseline -preset slow -b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -threads 0 -acodec libvo_aacenc -ab 96k %1_360p.mp4

REM 480p video for iPads and tablets (480p at 400kbit/s in main profile):
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -i %1 -vcodec libx264 -vprofile main -preset slow -b:v 400k -maxrate 400k -bufsize 800k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -ab 128k %1_480p.mp4

REM High-quality SD video for archive/storage (PAL at 1Mbit/s in high profile):
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -i %1 -vcodec libx264 -vprofile high -preset slower -b:v 1000k -vf scale=-1:576 -threads 0 -acodec libvo_aacenc -ab 196k %1_High.mp4

REM webm (VP8 / Vorbis)
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -y -i %1 -vcodec libvpx -quality good -cpu-used 5 -b:v 700k -maxrate 700k -bufsize 1000k -qmin 10 -qmax 42 -vf scale=trunc(oh*a/2)*2:480 -threads 4 -acodec libvorbis -f webm %1.webm

REM ogv  (Theora / Vorbis)
"D:\Program Files\FFmpeg\bin\ffmpeg.exe" -i %1 -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 -s 640x360 %1.ogv

遍历目录下的所有mpg文件,挨个转换到该目录!

for /r %1 %%i in (*.mpg) do "D:\Program Files\FFmpeg\Convert.bat" %%i

代码很简单,但是很实用,如果文件格式太乱,可以使用文件列表的形式来进行

for /r %1 %%i in (list.txt) do "D:\Program Files\FFmpeg\Convert.bat" %%i

大概就这些了,更多方法可以查看FFmpeg的使用说明

下载地址 ffmpeg-20131205-git-9ca32b2-win64-static

There are no comment yet.

HTML tag cannot be used in this comment.