feat: add ffmpeg.md
cheatsheet (#18).
This commit is contained in:
parent
b5f2969044
commit
f19dcdf8c4
@ -67,6 +67,7 @@ Quick Reference
|
||||
## 工具
|
||||
|
||||
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141/var(\-\-bg\-opacity));-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
|
204
docs/ffmpeg.md
Normal file
204
docs/ffmpeg.md
Normal file
@ -0,0 +1,204 @@
|
||||
FFmpeg 备忘清单
|
||||
===
|
||||
|
||||
本备忘清单是 [FFmpeg](https://ffmpeg.org/) 中常见视频处理操作的备忘清单
|
||||
|
||||
参数参考
|
||||
---
|
||||
|
||||
### 常用开关
|
||||
|
||||
```bash
|
||||
-codecs # 列出编解码器
|
||||
-c:v # 视频编解码器(-vcodec)-'copy'复制流
|
||||
-c:a # 音频编解码器(-acodec)
|
||||
-fs SIZE # 限制文件大小(字节)
|
||||
```
|
||||
|
||||
### 音频
|
||||
|
||||
```bash
|
||||
-aq QUALITY # 音频质量(特定于编解码器)
|
||||
-ar 44100 # 音频采样率 (Hz)
|
||||
-ac 1 # 音频通道(1=单声道,2=立体声)
|
||||
-an # 没有音频
|
||||
-vol N # 音量(256=正常)
|
||||
```
|
||||
|
||||
### 比特率
|
||||
|
||||
```bash
|
||||
-b:v 1M # 视频比特率(1M = 1Mbit/s)
|
||||
-b:a 1M # 音频比特率
|
||||
```
|
||||
|
||||
#### 视频
|
||||
|
||||
```bash
|
||||
-aspect RATIO # 纵横比(4:3、16:9 或 1.25)
|
||||
-r RATE # 每秒帧率
|
||||
-s WIDTHxHEIGHT # 帧大小
|
||||
-vn # 没有视频
|
||||
```
|
||||
|
||||
视频编辑
|
||||
---
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 裁剪
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i <input> -filter:v "crop=640:480:100:25" <output>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
通过从输入视频中复制偏移 `x=100px` `y=25px` 的相应窗口来创建 `640x480` 大小的输出视频
|
||||
|
||||
### 缩放
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i <输入> -vf scale=640:480 <输出>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 剪切视频部分
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i <input> -ss 00:01:45 -t 00:02:35 -vcodec copy -acodec copy <output>
|
||||
$ ffmpeg -ss 00:00:30 -i orginalfile.mpg -t 00:00:05 -vcodec copy -acodec copy newfile.mpg
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### H265 2-pass 编码
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ ffmpeg -y -i <input> -c:v libx265 -b:v 2600k \
|
||||
-x265-params pass=1 \
|
||||
-an -f mp4 /dev/null && \
|
||||
ffmpeg -i <input> \
|
||||
-c:v libx265 -b:v 2600k \
|
||||
-x265-params pass=2 \
|
||||
-c:a aac -b:a 128k output.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
对于 `H265 2-pass` 编码,您需要组合 `2` 个 `ffmpeg` 调用
|
||||
|
||||
### 视频比特率设置
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
|
||||
```
|
||||
|
||||
将输出文件的视频比特率设置为 64 kbit/s
|
||||
|
||||
### 固定旋转
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i <input> -c copy -metadata:s:v:0 rotate=90 <output>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
不要为旋转重新编码,而是简单地为旋转角度添加一个视频元数据字段
|
||||
|
||||
### 视频帧速率
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i input.avi -r 24 output.avi
|
||||
```
|
||||
|
||||
将输出文件的帧速率强制为 24 fps
|
||||
|
||||
```bash
|
||||
$ ffmpeg -r 1 -i input.m2v -r 24 output.avi
|
||||
```
|
||||
|
||||
将输入文件的帧速率(仅对原始格式有效)强制为 1 fps,将输出文件的帧速率强制为 24 fps
|
||||
|
||||
重新包装
|
||||
---
|
||||
|
||||
### 提取音频流
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.mp4 -vn -acodec copy output.aac
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
将`-vn`(无视频)与 `-acodec copy` 结合起来。请注意,输出文件扩展名必须与输入文件中的音频编解码器匹配,`-acodec copy` 才能工作。
|
||||
|
||||
### 创建缩略图
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
在 10 秒时创建一个缩略图
|
||||
|
||||
```bash
|
||||
$ ffmpeg -ss 10 -i <input file> -vframes 1 -vcodec png -an thumb.png
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
例如,要每 `n` 秒创建一次缩略图,请使用 `-vf fps=1/n`
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i <input file> -vf fps=1/60 thumbnails/thumb%03d.png
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 处理 id3 标签
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
提取
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.mp3 -f ffmetadata metadata.txt
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
设置
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.mp3 -acodec copy -metadata title="<title>" -metadata artist="<artist>" -metadata album="<album>" out.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
更多[请查看](https://gist.github.com/eyecatchup/0757b3d8b989fe433979db2ea7d95a01)
|
||||
|
||||
### 重新采样/转换音频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.aac -acodec mp3 -ar 44100 -ab 128000 output.mp3
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 切换容器
|
||||
|
||||
将容器从 `MKV` 更改为 `MP4`
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i file.mkv -acodec copy -vcodec copy file.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 图片中的视频
|
||||
|
||||
如果您有多个编号的图像 image1.jpg、image2.jpg... 像这样从它们创建一个视频
|
||||
|
||||
```bash
|
||||
$ ffmpeg -f image2 -i image%d.jpg video.mp4
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 将视频拆分为图像
|
||||
|
||||
```bash
|
||||
$ ffmpeg -i video.mp4 image%d.jpg
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [FFmpeg 官网地址](https://ffmpeg.org/) _(ffmpeg.org)_
|
||||
- [FFmpeg Cheat Sheet](https://lzone.de/cheat-sheet/ffmpeg) _(lzone.de)_
|
||||
- [FFmpeg Cheat Sheet](https://devhints.io/ffmpeg) _(devhints.io)_
|
3
scripts/assets/ffmpeg.svg
Normal file
3
scripts/assets/ffmpeg.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
|
||||
<path d="M21.72 17.91V6.5l-.53-.49L9.05 18.52l-1.29-.06L24 1.53l-.33-.95-11.93 1-5.75 6.6v-.23l4.7-5.39-1.38-.77-9.11.77v2.85l1.91.46v.01l.19-.01-.56.66v10.6c.609-.126 1.22-.241 1.83-.36L14.12 5.22l.83-.04L0 21.44l9.67.82 1.35-.77 6.82-6.74v2.15l-5.72 5.57 11.26.95.35-.94v-3.16l-3.29-.18a64.66 64.66 0 0 0 1.28-1.23z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 436 B |
Loading…
x
Reference in New Issue
Block a user