ffmpeg命令参数

主要参数

-i 设定输入流
-f 设定输出格式(format)
-ss 开始时间
-t 时间长度

视频参数

-vframes 设置要输出的视频帧数
-b 设定视频码率
-b:v 视频码率
-r 设定帧率
-s 设定画面的宽与高
-vn 不处理视频
-aspect aspect 设置横纵比4:3 或16:9 或1.333或 1.7777
-vcodec 设定视频编解码器,如果用copy表示原始编码数据必须被拷贝
-vf 视频过滤器

音频参数

-aframes 设置要输出的音频帧数
-b:a 音频码率
-ar 设定采样率
-ac 设定声音的Channel数
-acodec 设定声音编解码器,如果用copy表示原始编解码数据必须被拷贝
-an 不处理音频
-af 音频过滤器

例子1

原格式 16:9 1920*1080 6声道
在这里插入图片描述

转换格式(设定输出格式)

ffmpeg.exe -i test.mp4 -f flv test.flv

转换格式 音频拷贝

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

转换格式 视频拷贝

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

转换格式 音视频拷贝

ffmpeg.exe -i test.mp4  -codec copy -f flv test.flv

片段截取

输出格式可以不用特定指定输出格式-f
l从840秒开始截取60秒片段

ffmpeg.exe -i test.mp4 -ss 840 -t 60 -codec copy out.mp4

设置视频码率等

设置转换成800帧 码率1500k 帧率30 分辨率640*480

ffmpeg.exe -i test.mp4  -vframes 800   -b:v 1500k -r 30  -s 640x480    out1.mp4

转码效果
在这里插入图片描述
已变形
在这里插入图片描述

设置16:9

ffmpeg.exe -i test.mp4  -vframes 800   -b:v 1500k -r 30  -s 640x480 -aspect 16:9   out1.mp4

16:9 不会改变分辨率
在这里插入图片描述
播放效果(拉伸)
在这里插入图片描述

使用h265编码

ffmpeg.exe -i test.mp4  -vframes 800   -b:v 1500k -r 30  -s 640x480 -aspect 16:9  -vcodec libx265 out1.mp4

提取视频

去掉音频-an

>ffmpeg.exe -i test.mp4  -vframes 800   -b:v 1500k -r 30  -s 640x480 -aspect 16:9  -vcodec libx265 -an  video.mp4

提取音频

去掉视频-vn

ffmpeg.exe -i test.mp4    -acodec copy -vn  audio.mp4

视频转mp3

ffmpeg.exe -i out.mp4 -ac 2  out.mp3

设置音频码率和采样率

ffmpeg.exe -i out.mp4 -ac 2 -b:a 192k -ar 48000  out.mp3

指定MP3编码器

ffmpeg.exe -i out.mp4 -ac 2 -b:a 192k -ar 48000 -acodec libmp3lame  out.mp3

指定输出帧数

指定200帧数,即截断

ffmpeg.exe -i out.mp4 -ac 2 -b:a 192k -ar 48000 -acodec libmp3lame  -aframes 200  out.mp3

查看设备

ffmpeg.exe -list_devices  true -f dshow -i dummy

查看分辨率等

ffmpeg.exe -f dshow  -list_options true -i  video="Integrated Webcam"

录制视频

ffmpeg.exe -f dshow -video_size 1280x720 -i video="Integrated Webcam" v-out2.mp4

指定码率(3M)和帧率(15帧)

ffmpeg.exe -f dshow -video_size 1280x720 -i video="Integrated Webcam"  -b:v 3M -r 15 -y v-out2.mp4

录制音频

ffmpeg.exe -f dshow -i audio="麦克风 (Realtek(R) Audio)"  1.aac

录制音视频

-f dshow 指定多路

ffmpeg.exe -f dshow -video_size 1280x720  -i video="Integrated Webcam"  -f dshow -i audio="麦克风 (Realtek(R) Audio)"    -y 1.mp4
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值