Skip to content

Commit b1a4664

Browse files
committed
Update other projects & add FFmpeg page
1 parent c800193 commit b1a4664

File tree

2 files changed

+171
-1
lines changed

2 files changed

+171
-1
lines changed

src/ffmpeg-notes.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
layout: layouts/page.njk
3+
title: FFmpeg Notes
4+
5+
eleventyNavigation:
6+
key: FFmpeg Notes
7+
order: 4
8+
9+
image: /img/avatar.png
10+
description: "Notes for FFmpeg that I've accumulated over time."
11+
---
12+
13+
# {{ title }}
14+
15+
Hi, these are Butterscotch's personal FFmpeg notes! These are just a bunch of personal notes I've made about using FFmpeg over the years, so it's not a proper guide or anything.
16+
17+
## Useful links
18+
19+
- <https://trac.ffmpeg.org/wiki/Encode/H.264>
20+
- <https://trac.ffmpeg.org/wiki/Encode/H.265>
21+
- <https://trac.ffmpeg.org/wiki/Encode/AV1>
22+
- <https://slhck.info/video/2017/02/24/crf-guide.html>
23+
- <https://ffmpeg.org/ffmpeg.html#Advanced-options>
24+
- <https://ffmpeg.org/ffmpeg-codecs.html>
25+
26+
## CRF - Bitrate control
27+
28+
The Constant Rate Factor (CRF) is the main control for quality and bitrate for most modern encoders. The CRF scale starts from 0 to some variable value (usually 51, check for each encoder), where 0 is the highest quality (lossless) and the highest number is the lowest quality.
29+
30+
### H264
31+
32+
The CRF scale is 0-51, where 0 is lossless, 23 is the default, and 51 is the worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17-28. Consider 17 or 18 to be visually lossless or nearly so; it should look the same or nearly the same as the input but it isn't technically lossless.
33+
34+
Note: The maximum value can change with 10-bit encoding.
35+
36+
### H265
37+
38+
The CRF scale is 0-51, where 0 is lossless, 28 is the default, and 51 is the worst quality possible. This scale is pretty much the same as H264 but can have higher quality at higher CRF values.
39+
40+
### SVT-AV1
41+
42+
The valid CRF value range for libsvtav1 is 0-63, with the default being 35. Lower values correspond to higher quality and greater file size. Lossless encoding is currently ​not supported. It is generally recommended to use preset 5/6 at CRF 24-28 for the best quality results.
43+
44+
## Basic info commands
45+
46+
### List hardware acceleration options
47+
48+
```bash
49+
ffmpeg -hwaccels
50+
```
51+
52+
### List codecs/encoders/decoders
53+
54+
```bash
55+
ffmpeg -codecs
56+
ffmpeg -encoders
57+
ffmpeg -decoders
58+
```
59+
60+
## Hardware acceleration
61+
62+
- `hwaccel` is the input hardware acceleration
63+
- `hwaccel_output_format` is the output hardware acceleration
64+
65+
## Example commands
66+
67+
### Basic H265
68+
69+
```bash
70+
ffmpeg -i input.mp4 -map 0 -c:v libx265 -crf 28 -c:a copy output.mp4
71+
```
72+
73+
### Basic SVT-AV1
74+
75+
#### Important options
76+
77+
- `-preset 6` - A good SVT-AV1 encoding preset
78+
- `-crf 27` - Good value trade-off between quality and size
79+
- `-pix_fmt yuv420p10le` - 10-bit encoding, reduces colour banding, optional
80+
81+
#### High quality
82+
83+
```bash
84+
ffmpeg -i input.mp4 -map 0 -c:v libsvtav1 -preset 6 -crf 27 -pix_fmt yuv420p10le -c:a copy output.mp4
85+
```
86+
87+
#### Medium quality
88+
89+
```bash
90+
ffmpeg -i input.mp4 -map 0 -c:v libsvtav1 -preset 6 -crf 35 -pix_fmt yuv420p10le -c:a copy output.mp4
91+
```
92+
93+
#### Low quality
94+
95+
```bash
96+
ffmpeg -i input.mp4 -map 0 -c:v libsvtav1 -preset 6 -crf 51 -pix_fmt yuv420p10le -c:a copy output.mp4
97+
```
98+
99+
### Copy embedded subtitles from MP4 to MP4
100+
101+
```bash
102+
ffmpeg -i input.mp4 -map 0 -c:v copy -c:a copy -c:s mov_text output.mp4
103+
```
104+
105+
### Encode video using CUDA (NVIDIA)
106+
107+
```bash
108+
ffmpeg -init_hw_device cuda=hw -filter_hw_device hw -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -map 0 -c:v h264_nvenc -c:a copy output.mp4
109+
```
110+
111+
### Encode video using QuickSync (Intel) with embedded subtitles
112+
113+
```bash
114+
ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hwaccel qsv -hwaccel_output_format qsv -i input.mp4 -map 0 -c:v h264_qsv -c:a copy -c:s mov_text output.mp4
115+
```
116+
117+
### Encode video using Vulkan/AMF (AMD)
118+
119+
```bash
120+
ffmpeg -init_hw_device vulkan=hw -filter_hw_device hw -hwaccel vulkan -hwaccel_output_format vulkan -i input.mp4 -map 0 -c:v h264_amf -c:a copy output.mp4
121+
```
122+
123+
### Resize video using letterbox
124+
125+
```bash
126+
ffmpeg -i input.mp4 -map 0 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black" output.mp4
127+
```
128+
129+
### Batch encode
130+
131+
Bulk conversion using Windows batch scripting. Should probably use something better like PowerShell
132+
133+
```bat
134+
FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -b:a 48k "%~nG.opus"
135+
```
136+
137+
### Video to high quality GIF
138+
139+
```bash
140+
ffmpeg -i input.mp4 -vf "split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
141+
```
142+
143+
### Join two audio streams
144+
145+
See:
146+
147+
- <https://ffmpeg.org/ffmpeg-filters.html#amix>
148+
- <https://gist.github.com/LukasKnuth/4d7ee6812ccb221b2775e984516b56d4>
149+
150+
```bash
151+
ffmpeg -i input.mp4 -map 0 -filter_complex amix=inputs=2 output.mp4
152+
```
153+
154+
### Images to GIF at 50 FPS from 60 FPS
155+
156+
```bash
157+
ffmpeg -r 60 -i image_%003d.jpg -vf "fps=50" out.gif
158+
```
159+
160+
### Image and audio to video
161+
162+
```bash
163+
ffmpeg -i image.jpg -i audio.wav -tune stillimage -shortest out.mp4
164+
```
165+
166+
### Combine audio and video
167+
168+
```bash
169+
ffmpeg -i video.webm -i audio.webm -map 0:v:0 -map 1:a:0 -c:v copy -c:a copy out.webm
170+
```

src/other-projects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Bingus Search is a passion project of mine to assist with technical support, hel
2222

2323
## [SlimeVR Firmware Tool](https://slimevr-firmware.bscotch.ca/)
2424

25-
I host a fork of the SlimeVR Firmware Tool for people to use as the original is no longer hosted or maintained. There is a version being developed to be integrated within the SlimeVR software, but as of writing, it is not yet released.
25+
I host a fork of the SlimeVR Firmware Tool for people to use as the original is no longer hosted or maintained. There is a version integrated within the SlimeVR software which I highly recommend using instead.
2626

2727
## [SlimeVR Testing Checklist](https://slimevr-testing.bscotch.ca/)
2828

0 commit comments

Comments
 (0)