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
相关推荐
Mahut2 天前
我用 Electron + FFmpeg 做了一个本地视频处理工作站 ClipForge
前端·ffmpeg·electron
源之缘-OFD先行者12 天前
破界渲染:WinForm下的FFmpeg+Vortice极速推流引擎
ffmpeg·winform·推流·h264
源来猿往12 天前
记ffmpeg-8.1.1 之Android库编译(window)
android·ffmpeg
Deitymoon12 天前
RV1126+FFMPEG多路码流监控项目
ffmpeg·音视频
芝麻别开门12 天前
GStreamer DASH Demux 知识文档
ffmpeg·dash
ltlovezh12 天前
ROI 编码学习指南:Android 与 FFmpeg 的真实实现边界
android·ffmpeg·音视频开发
m0_7471245313 天前
多媒体框架 FFmpeg 和 GStreamer
ffmpeg·gstreamer
小鹿研究点东西14 天前
AI直播系统怎么搭?
人工智能·ffmpeg·自动化·音视频·语音识别
Nightwish514 天前
Oracle 数据库巡检检查清单
数据库·oracle·ffmpeg
luoyayun36114 天前
Qt/QML + FFmpeg 实现多音频文件顺序拼接功能
qt·ffmpeg·音频拼接