FFMPEG操作指南

这是一份全面的FFMPEG操作指南,涵盖从分离视频音频流、视频解复用、转码、封装,到剪切、录制、YUV播放、格式转换等众多功能。还包含图片转视频、视频转gif、加音轨、字幕、水印等特效处理,以及视频合并、格式转换等实用技巧。
摘要由CSDN通过智能技术生成

FFMPEG操作指南

ffmpeg基本命令

1.分离视频音频流

ffmpeg -i input_file -vcodec copy -an output_file_video  //分离视频流
ffmpeg -i input_file -acodec copy -vn output_file_audio  //分离音频流

2.视频解复用

ffmpeg –i test.mp4 –vcodec copy –an –f m4v test.264
ffmpeg –i test.avi –vcodec copy –an –f m4v test.264

3.视频转码

ffmpeg –i test.mp4 –vcodec h264 –s 352278 –an –f m4v test.264 //转码为码流原始文件
ffmpeg –i test.mp4 –vcodec h264 –bf 0 –g 25 –s 352
278 –an –f m4v test.264 //转码为码流原始文件
ffmpeg –i test.avi -vcodec mpeg4 –vtag xvid –qsame test_xvid.avi //转码为封装文件

4.视频封装

ffmpeg –i video_file –i audio_file –vcodec copy –acodec copy output_file

5.视频剪切

ffmpeg –i test.avi –r 1 –f image2 image-%3d.jpeg //提取图片
ffmpeg -ss 0:1:30 -t 0:0:20 -i input.avi -vcodec copy -acodec copy output.avi //剪切视频

6.视频录制

ffmpeg –i rtsp://192.168.3.205:5555/test –vcodec copy out.avi

7.YUV序列播放

ffplay -f rawvideo -video_size 1920x1080 input.yuv

8.YUV序列转AVI

ffmpeg –s w*h –pix_fmt yuv420p –i input.yuv –vcodec mpeg4 output.avi

9.截取视频的第一帧保存为JPG图片

格式:ffmpeg -i 视频文件名 -y -f image2 -ss 00:00:01 -vframes 1 图片名.jpg

ffmpeg -i lesson001.mp4 -y -f  image2  -ss 00:00:01 -vframes 1 firstFrame.jpg
ffmpeg -i lesson002.mpg -y -f  image2  -ss 00:00:01 -vframes 1 firstFrame.jpg
ffmpeg -i 1.mp4 -y -f  image2  -ss 00:00:01 -vframes 25 firstFrame%d.jpg

10.获取视频时长

格式:ffmpeg -i 视频文件名 2>&1 | grep ‘Duration’ | cut -d ’ ’ -f 4 | sed s/,//

ffmpeg -i lesson003.mpg 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//

11.图片转视频

图片像素必须为偶数,大小最好与原视频完全相同

ffmpeg -y -f image2 -i capture%3d.jpg -r 23.98 img.mp4  

12.视频转gif

1.使用ffmpeg自带的转换功能

ffmpeg -y -ss 25 -t 10 -i D:\video_test\gif\1.mp4 -s 134x154 -f gif -r 4 D:\video_test\g
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值