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
相关推荐
刘广睿2 天前
断点续传与分片下载是怎么实现的?Range 请求在视频下载中的工程实践
okhttp·ffmpeg·音视频·下载·python3.11
IvanCodes3 天前
FFmpeg安装与使用教程
ffmpeg
betazhou6 天前
mysql shell8.4.10+mysql 8.4.10搭建MySQL replicaset主从
数据库·mysql·ffmpeg·replicaset·mysql shell
VidDown7 天前
# VP9 还是 H.265?一次压缩选型翻车后的复盘
ffmpeg·音视频·h.265·视频编解码·视频·vp9
heqingchun167 天前
RK3568 交叉编译与部署:MPP + FFmpeg 硬解全流程
ffmpeg·视频编解码
云贝贝贝8 天前
OceanBase 生产运维 7 个高频现场:从连不上到误删兜底
运维·ffmpeg·oceanbase
≮傷£≯√8 天前
ffmpeg 2个图片合并为视频
ffmpeg·音视频
zone_z11 天前
07 · 等待事件与 OWI 方法:从 OSW 到 BUG 的完整破案实录
linux·数据库·oracle·ffmpeg·bug·troubleshooting
'20612 天前
**写了个自动整理下载视频的脚本:按片名归档、自动重命名、生成目录索引
开发语言·python·ffmpeg·音视频·cctv
殷忆枫12 天前
嵌入式Linux下基于FFmpeg实现MP4解码为JPG图片(SSD202D交叉编译实战)
linux·运维·ffmpeg