FFmpeg常用音视频处理指令

视频转换:

H264视频转ts视频流

ffmpeg -i test.h264 -vcodec copy -f mpegts test.ts

H264视频转mp4

ffmpeg -i test.h264 -vcodec copy -f mp4 test.mp4

ts视频转mp4

ffmpeg -i test.ts -acodec copy -vcodec copy -f mp4 test.mp4

mp4视频转flv

ffmpeg -i test.mp4 -acodec copy -vcodec copy -f flv test.flv

 

视频剪切:

ffmpeg  -i Security_OS.mp4 -vcodec copy -acodec copy -ss 0:11:00 -to 00:00:15 TEE_Security_OS.mp4 -y

ffmpeg -ss 0:11:00 -t 1:08:00 -i Security_OS.mp4 -vcodec copy -acodec copy TEE_Security_OS.mp4

-i 表示源视频文件

-vcodec copy表示使用跟原视频一样的视频编解码器。

-acodec copy表示使用跟原视频一样的音频编解码器。

-ss set the start time offset 设置从视频的哪个时间点开始截取

-to 截到视频的哪个时间点结束(如果是-t则表示截取多长的时间)

-y 表示如果输出文件已存在则覆盖。

 

分离视频音频流:

ffmpeg -i TEE_Security_OS.mp4 -vcodec copy -an TEE_Security_OS_Video.h264 //分离视频流

ffmpeg -i TEE_Security_OS.mp4 -acodec copy -vn TEE_Security_OS_Audio.aac //分离音频流

ffmpeg 工具集提供的 ffplay 可以播放H.264裸流

ffplay TEE_Security_OS_Video.h264

 

音频视频混合

ffmpeg -i VideoTest.wav -i TEE_Security_OS_Audio.avi TEE_Security_OS_Audio.mp4

 

更多指令参数信息->执行“ffmpeg -help”,部分选项简介如下:

Video options:
-vframes number     set the number of video frames to output (设置要输出的视频帧数)
-r rate             set frame rate (Hz value, fraction or abbreviation)(设置帧率(Hz值,分数或缩写))
-s size             set frame size (WxH or abbreviation)(设置帧大小(WxH或缩写))
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)(设置长宽比)
-bits_per_raw_sample number  set the number of bits per raw sample(设置每个原始样本的位数)
-vn                 disable video(禁用视频)
-vcodec codec       force video codec ('copy' to copy stream)(强制视频编解码器)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.(设置初始TimeCode值)
-pass n             select the pass number (1 to 3)(选择pass号码)
-vf filter_graph    set video filters(设置视频过滤器)
-ab bitrate         audio bitrate (please use -b:a)(音频比特率)
-b bitrate          video bitrate (please use -b:v)(视频比特率)
-dn                 disable data(禁用数据)

Audio options:
-aframes number     set the number of audio frames to output(设置要输出的音频帧数)
-aq quality         set audio quality (codec-specific)(设置音频质量(编解码器专用))
-ar rate            set audio sampling rate (in Hz)(设置音频采样率)
-ac channels        set number of audio channels(设置音频通道数)
-an                 disable audio(禁用音频)
-acodec codec       force audio codec ('copy' to copy stream)(强制音频编解码器)
-vol volume         change audio volume (256=normal)(改变音量)
-af filter_graph    set audio filters(设置音频过滤器)

Subtitle options:
-s size             set frame size (WxH or abbreviation)(设置帧大小(WxH或缩写))
-sn                 disable subtitle(禁用字幕)
-scodec codec       force subtitle codec ('copy' to copy stream)(强制字幕编解码器)
-stag fourcc/tag    force subtitle tag/fourcc(强制字幕 tag/fourcc)
-fix_sub_duration   fix subtitles duration(修复字幕持续时间)
-canvas_size size   set canvas size (WxH or abbreviation)(设置画布大小(WxH或缩写))
-spre preset        set the subtitle options to the indicated preset(将字幕选项设置为指定的预设)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值