ffmpeg 工具集

来源:互联网 发布:美国有穷人吗 知乎 编辑:程序博客网 时间:2024/05/18 01:33

问题

使用ffmpeg命令对视频中部分帧(大概300帧)进行截图的时候,发现截图速度随着帧时间越来越往后,速度越来越慢。

原因分析

出现这种情况的原因是由于参数的位置放置不正确造成的 "-ss" 要放在第一个参数位置,这样ffmpeg截图的时候就会直接跳到该帧进行截图,而不是逐帧扫描。

解决方法

将命令由:

ffmpeg -y -i beijing-480p.mp4 -ss 6000 -s 320x180 -frames 1 -f image2 result.jpg

改为:

ffmpeg -y -ss 6000 -i beijing-480p.mp4 -s 320x180 -frames 1 -f image2 result.jpg


ffmpeg 抽取一帧(ss单位为秒)
ffmpeg -i media.ts -y -f image2 -ss 6 test.jpg

ffmpeg 截屏

ffmpeg -ss 0 -t 4 -i ./720p.mp4 -r 1 -q:v 2 -f image2 output-0%d.jpg
从 0 秒开始持续 4 秒,每秒 1 帧,质量较高,输出为 output-0x.jpg

多音轨提取单音轨

ffmpeg -i 720p.mkv -map 0:v -vcodec copy -map 0:a:1 -acodec copy 720p.mp4

ffplay 播放 yuv
ffplay -f rawvideo -video_size 352x288 352x288.yuv

ffplay 播放 264
ffplay yourfile.264

ffmpeg 解压 yuv
ffmpeg -i 352x288.264 -pix_fmt yuv420p -vframes 100000 352x288.yuv

ffmpeg 分离 aac
ffmpeg -i inputfile.mp4 -ss 00:00:00 -t 00:10:00 -acodec copy -bsf: aac_adtstoasc outputfile.aac

ffmpeg 分离 264
ffmpeg -i inputfile.mp4 -ss 00:00:00 -t 00:01:00 -codec copy -bsf: h264_mp4toannexb -f h264 outputfile.264

ffmpeg 提取时间
ffmpeg -i inputfile.mp4 -ss 00:00:01 -t 23:59:59 -vcodec copy -acodec copy outputfile.mp4

ffmpeg 音频重采样
ffmpeg -i inputfile.mp4 -ss 00:00:00 -t 00:01:00 -strict -2 -acodec aac -ar 48000 -ab 128k outputfile.aac


flv 转 mp4 (Windows)
将以下文本存为 flv2mp4.bat

for /R %%s in (*.flv) do (
  ffmpeg -i %%s -vcodec copy -acodec copy -vbsf h264_mp4toannexb %%s.ts
)

del *.flv
ren *.flv.ts *.
ren *.flv *.ts

ffmpeg -i "concat:01.ts|02.ts|03.ts|04.ts|05.ts|06.ts|07.ts|08.ts|09.ts|10.ts" -acodec copy -vcodec copy -absf aac_adtstoasc 1.mp4
ffmpeg -i "concat:11.ts|12.ts|13.ts|14.ts|15.ts|16.ts|17.ts|18.ts|19.ts|20.ts" -acodec copy -vcodec copy -absf aac_adtstoasc 2.mp4
ffmpeg -i "concat:21.ts|22.ts|23.ts|24.ts|25.ts|26.ts|27.ts|28.ts|29.ts|30.ts" -acodec copy -vcodec copy -absf aac_adtstoasc 3.mp4
ffmpeg -i "concat:31.ts|32.ts|33.ts|34.ts|35.ts|36.ts|37.ts|38.ts|39.ts|40.ts" -acodec copy -vcodec copy -absf aac_adtstoasc 4.mp4
ffmpeg -i "concat:41.ts|42.ts|43.ts|44.ts|45.ts|46.ts|47.ts|48.ts|49.ts|50.ts" -acodec copy -vcodec copy -absf aac_adtstoasc 5.mp4

01~50.ts 等文件必须存在

0 0