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
相关推荐
ofoxcoding4 小时前
Gemini TTS 与 ElevenLabs 语音合成实测:同一段视频旁白效果对比
ai·ffmpeg·音视频
_大峰_20 小时前
索尼 A7M4 误删视频恢复实战:基于原始卡镜像重建 MP4 数据
ffmpeg·数据恢复·音视频·mp4·exfat
Anhty1 天前
3 款手机音频剪辑 APP 横评,短视频配音后期,免费工具怎么选?
功能测试·ffmpeg·音视频
VidDown2 天前
自动给视频挑一张能看的封面:帧评分、构图与批量生成
python·ffmpeg·音视频·视频
可乐鸡翅yeah_3 天前
HLS 业务 Referer‑Policy 网页元标签引发播放异常排错
前端·javascript·网络·ffmpeg·php·音视频
开开心心就好4 天前
本地文件搜索工具推荐,占用小速度还快
智能手机·ffmpeg·ocr·word·音视频·网络攻击模型·安全架构
我科绝伦(Huanhuan Zhou)4 天前
oracle坏块导致备份不了
数据库·oracle·ffmpeg
RS迷途小书童4 天前
Python+FFmpeg提取大疆无人机MP4内嵌mov_text遥测SRT字幕并做完整性校验
python·ffmpeg·大疆·srt字幕·dji
开开心心就好4 天前
视频压缩工具推荐,画质效果很能打
智能手机·ffmpeg·ocr·word·排序算法·音视频·散列表
可乐鸡翅yeah_5 天前
业务中 M3U8 水印相关坑,硬水印和动态水印区别
前端·网络·数据库·ffmpeg·m3u8在线