Skip to content

Commit 66778b7

Browse files
committed
docs(book): add docs for setting the encoder options
Signed-off-by: k4yt3x <i@k4yt3x.com>
1 parent 445d13b commit 66778b7

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

docs/book/src/running/command-line.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ video2x -i input.mp4 -o output.mp4 -f libplacebo -s path/to/custom/shader.glsl -
2929
List the available GPUs with `--list-gpus, -l`:
3030

3131
```bash
32-
$video2x --list-gpus
32+
$ video2x --list-gpus
3333
0. NVIDIA RTX A6000
3434
Type: Discrete GPU
3535
Vulkan API Version: 1.3.289
@@ -42,8 +42,63 @@ Select which GPU to use with the `--gpu, -g` argument:
4242
video2x -i input.mp4 -o output.mp4 -f realesrgan -r 4 -m realesr-animevideov3 -g 1
4343
```
4444

45-
Specify arbitrary extra FFmepg encoder options with the `--extra-encoder-options, -e` argument:
45+
Specify arbitrary extra FFmpeg encoder options with the `--extra-encoder-options, -e` argument:
4646

4747
```bash
4848
video2x -i input.mkv -o output.mkv -f realesrgan -m realesrgan-plus -r 4 -c libx264rgb -e crf=17 -e preset=veryslow -e tune=film
4949
```
50+
51+
## Encoder Options
52+
53+
Video2X uses FFmpeg's C libraries to encode videos. Encoder options are specified in two ways:
54+
55+
- **Common options** shared by all encoders are stored in a [`AVCodecContext`](https://ffmpeg.org/doxygen/trunk/structAVCodecContext.html) struct. Below are some options set through `AVCodecContext`:
56+
- Codec
57+
- Pixel format
58+
- Bitrate
59+
- Keyframe interval
60+
- Minimum and maximum quantizer
61+
- GOP size
62+
- **Encoder-specific** options are stored in [`AVOption`](https://ffmpeg.org/doxygen/trunk/structAVOption.html) structs and set with the [`av_opt_set`](https://ffmpeg.org/doxygen/trunk/group__opt__set__funcs.html#ga5fd4b92bdf4f392a2847f711676a7537) function. Below are some encoder-specific options for `libx264`:
63+
- CRF
64+
- Preset
65+
- Tune
66+
- Profile
67+
68+
Common options can only be set through Video2X's command line arguments. You can run `video2x --help` and see the `Encoder options` section to see the supported options.
69+
70+
You can specify encoder-specific options in Video2X using the `--extra-encoder-option` (`-e`) argument. To view the available options for a particular codec, run:
71+
72+
```bash
73+
ffmpeg -h encoder=$ENCODER
74+
```
75+
76+
For example, to view the available options for `libx264`, run:
77+
78+
```console
79+
$ ffmpeg -h encoder=libx264
80+
Encoder libx264 [libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
81+
General capabilities: dr1 delay threads
82+
Threading capabilities: other
83+
Supported pixel formats: yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p nv12 nv16 nv21 yuv420p10le yuv422p10le yuv444p10le nv20le gray gray10le
84+
libx264 AVOptions:
85+
-preset <string> E..V....... Set the encoding preset (cf. x264 --fullhelp) (default "medium")
86+
-tune <string> E..V....... Tune the encoding params (cf. x264 --fullhelp)
87+
-profile <string> E..V....... Set profile restrictions (cf. x264 --fullhelp)
88+
-fastfirstpass <boolean> E..V....... Use fast settings when encoding first pass (default true)
89+
-level <string> E..V....... Specify level (as defined by Annex A)
90+
-passlogfile <string> E..V....... Filename for 2 pass stats
91+
-wpredp <string> E..V....... Weighted prediction for P-frames
92+
-a53cc <boolean> E..V....... Use A53 Closed Captions (if available) (default true)
93+
-x264opts <string> E..V....... x264 options
94+
-crf <float> E..V....... Select the quality for constant quality mode (from -1 to FLT_MAX) (default -1)
95+
-crf_max <float> E..V....... In CRF mode, prevents VBV from lowering quality beyond this point. (from -1 to FLT_MAX) (default -1)
96+
-qp <int> E..V....... Constant quantization parameter rate control method (from -1 to INT_MAX) (default -1)
97+
...
98+
```
99+
100+
You can then set the encoder-specific options with the `-e` argument. The `-e` argument can be used multiple times to set multiple options. For example, the following arguments set the CRF to 17, the preset to `veryslow`, and the tune to `film` for `libx264`:
101+
102+
```console
103+
-e crf=17 -e preset=veryslow -e tune=film
104+
```

0 commit comments

Comments
 (0)