ffmpeg使用
转码
1 2 3 4 5
| ffmpeg -i out.ogv -vcodec h264 out.mp4 ffmpeg -i out.ogv -vcodec mpeg4 out.mp4 ffmpeg -i out.ogv -vcodec libxvid out.mp4 ffmpeg -i out.mp4 -vcodec wmv1 out.wmv ffmpeg -i out.mp4 -vcodec wmv2 out.wmv
|
提取
1
| ffmpeg -ss 00:00:26 -i input.mp4 -to 00:05:26 -c copy -copyts cut.mp4
|
提取音频:
1
| ffmpeg -i 111.mp4 -f mp3 -ar 16000 111.mp3
|
提取当前目录所有 mp4 文件的音频,并保存为对应的 mp3。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #!/bin/bash
echo "converting..."
FILES=`ls *.mp4`
#echo $FILES count=`ls *.mp4 | wc -l` i=0 for file in $FILES do let i+=1 baase=$(basename $file .mp4) echo 'converting' '(' $i, $count ')' $baase ffmpeg -i $baase.mp4 -f mp3 -ar 16000 $baase.mp3
done
echo "done" sleep 1000
|
合并
1 2 3 4 5 6
| $ cat mylist.txt file '/path/to/file1' file '/path/to/file2' file '/path/to/file3'
ffmpeg -f concat -i mylist.txt -c copy output
|
1 2 3 4
| ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi
|
图片缩放
1 2 3 4 5 6 7 8 9 10 11 12
| ffmpeg -y -i input.jpg -vf scale=800:-1 aaa.jpg
示例: #!/bin/bash
FILES=`ls *.jpg`
for file in $FILES do echo "converting" $file ffmpeg -y -i $file -vf scale=800:-1 $file done
|
注:添加-y
可覆盖原文件。