ffmpeg速成

bash 复制代码
ffmpeg -i ./Test.mp4

-i  输入
bash 复制代码
ffmpeg -i  chuangGuand.mp4 test1.avi
输出文件为test1.avi

视频截取

bash 复制代码
ffmpeg -ss 00:00:10 -t 00:00:30 -i test.mp4 -vcodec copy -acodec copy output.mp4

2. -ss 00:00:10
start time 开始时间
从视频第 10 秒开始截取
3. -t 00:00:30
duration 持续时间
截取30 秒长度
4. -i test.mp4
input 输入文件
要剪辑的原视频叫 test.mp4
5. -vcodec copy
视频编码直接复制,不重新压缩
6. -acodec copy
音频编码直接复制
和视频一样,不改动、不压缩
7. output.mp4
输出文件名

合并视频

bash 复制代码
file 'test1.mp4'
file 'test2.mp4'
file 'test3.mp4'
bash 复制代码
ffmpeg -f concat -i test.txt -c:v copy hb.mp4
bash 复制代码
ffmpeg -f concat -i test.txt -vcodec copy -acodec copy hb1.mp4


它们是完全等价的别名:
-vcodec copy
= video codec copy(老写法)
-c:v copy
= codec:video copy(新写法)

-acodec copy ≡ -c:a copy 音频

更改视频的分辨率

bash 复制代码
ffmpeg -i chuangGuand.mp4 -filter:v scale=1280:720 -c:a copy fbl.mp4

改变音视频的编码方式

bash 复制代码
ffmpeg -i test.avi -c:v libx264 -c:a aac output.mp4

提取视频中的音频

bash 复制代码
ffmpeg -i test.mp4 -vn test.mp3

-vn,就是 disable video

bash 复制代码
ffmpeg -i test.mp4 -an output.mp4

-an 去掉音频

提取图像

bash 复制代码
ffmpeg -i test.mp4 -r 1 -f image2 image_%2d.png

m3u8

bash 复制代码
ffmpeg -i test.mp4 -vcodec libx264 
-strict -2 -acodec aac -hls_list_size 0 -f hls index.m3u8


2. -vcodec libx264
视频编码用 H.264
= 所有浏览器、手机都支持的通用格式
3. -acodec aac
音频编码用 AAC
= 最通用的音频格式
4. -strict -2
允许使用标准 AAC 编码(老版本 FFmpeg 需要,现在可加可不加)
-strict very      → -3   最严格
-strict strict    → -2   严格
-strict normal    →  0   默认
-strict unofficial→  1   允许非官方
-strict experimental → 2 ✅ 实验性(常用

AI说的2015前
-strict -2是experiment
2015后 
-strict -2 是strict

5. -hls_list_size 0
m3u8 列表包含所有切片,不删除、不滚动

-hls_list_size 3 如果为3 只会保留最新的3个ts
= 0 = 保留全部切片
6. -f hls
强制输出 HLS 格式  -format 流媒体格式
7. index.m3u8
bash 复制代码
ffmpeg -i chuangGuand.mp4 -c:v libx264 -c:a aac -hls_time 30 -hls_list_size 0 -f hls Myindex.m3u8
相关推荐
街灯L3 小时前
【Ubuntu】使用ffmpeg解析m3u8网页视频
ubuntu·ffmpeg·音视频
烟雨江南7851 天前
特高压输电线路带电作业直升机吊篮与强电磁感应放电:基于“灵声智库”空间自适应滤波与声纹授权的离线语音控制指令方案
人工智能·ffmpeg·webrtc·语音识别·ai质检
AJi1 天前
H264码率控制
ffmpeg
换个昵称都难2 天前
webrtc voice engine 介绍(新版webrtc)
ffmpeg·音视频·webrtc
小鹿软件办公3 天前
巧用 Adobe Audition 中置声道提取,轻松分离人声与背景音乐
adobe·ffmpeg·简鹿人声分离
2023自学中5 天前
imx6ull开发板 移植 ffmpeg 4.2.11 + x264 视频编码库
linux·ffmpeg·音视频·嵌入式·开发板
feibaoqq5 天前
光电视频监控技术(GB28181/ONVIF/私有协议)
ffmpeg·音视频·低空安防
feiyangqingyun6 天前
使用ffmpeg播放不同节目/实时切换节目并推流/推流不同的节目流
ffmpeg·推节目流·广播节目
左直拳7 天前
利用海康CVR实现视频流历史回放
ffmpeg·cvr·视频回放·历史视频