Skip to content

Commit 3b60e39

Browse files
committed
More PR fixes
1 parent 947fac7 commit 3b60e39

File tree

1 file changed

+53
-30
lines changed

1 file changed

+53
-30
lines changed

encoding/codecs/x264.md

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ Here's how we get a copy of the x264 encoder:
2525

2626
### Windows
2727

28-
TODO
28+
Official Windows builds are available
29+
[here](https://download.videolan.org/pub/x264/binaries/win64/).
30+
For these examples,
31+
you'll want the latest version
32+
of the standard 8-bit build,
33+
which is the version without "10b" (for 10-bit) in the name.
2934

3035
### Linux/macOS
3136

@@ -35,7 +40,7 @@ Here are a few examples:
3540

3641
- **Ubuntu/Debian**: `sudo apt install x264`
3742
- **Arch Linux**: `sudo pacman -S x264`
38-
- **macOS**: `brew install x264`
43+
- **macOS**: `brew install x264`https://download.videolan.org/pub/x264/binaries/win64/
3944

4045
## Getting Started
4146

@@ -47,14 +52,16 @@ and understanding a few basic concepts.
4752
We'll walk through those concepts
4853
with the following examples.
4954

50-
## Example 1
55+
## Example 1: General-Purpose Encoding
5156

5257
Open up a terminal window,
5358
and navigate to the folder
5459
where your VapourSynth script lives.
5560
Let's run the following command:
5661

57-
`vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --tune animation --crf 24 -o x264output.mkv -`
62+
```
63+
vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --tune animation --crf 24 -o x264output.mkv -
64+
```
5865

5966
Let's run through what each of these options means:
6067

@@ -69,7 +76,7 @@ If you're not,
6976
it's basically a way of chaining two commands together.
7077
In this case, we want to chain `vspipe`,
7178
the program that reads VapourSynth scripts,
72-
with x264, our encoder.
79+
with `x264`, our encoder.
7380

7481
#### `--demuxer y4m`
7582

@@ -83,18 +90,18 @@ x264 has a set of presets
8390
to switch between faster encoding, or higher quality.
8491
The full list of presets, from fastest to slowest, is:
8592

86-
- ultrafast
87-
- superfast
88-
- veryfast
89-
- faster
90-
- fast
91-
- medium
92-
- slow
93-
- slower
94-
- veryslow
95-
- placebo
96-
97-
You will almost never want to use the very extreme settings,
93+
1. ultrafast
94+
1. superfast
95+
1. veryfast
96+
1. faster
97+
1. fast
98+
1. medium
99+
1. slow
100+
1. slower
101+
1. veryslow
102+
1. placebo
103+
104+
You will almost never want to use the extreme settings,
98105
but generally, if you want good quality
99106
and don't care about how long the encode takes,
100107
`slower` or `veryslow` are recommended.
@@ -104,7 +111,8 @@ we want a fast encode and have chosen `veryfast`.
104111

105112
For the curious,
106113
you can see a full list of the settings enabled by each preset
107-
by running `x264 --fullhelp | less`.
114+
by running `x264 --fullhelp | less` (Linux/Mac)
115+
or `x264 --fullhelp | more` (Windows).
108116
However, this probably won't mean much at the moment.
109117
Don't worry,
110118
this guide will explain later
@@ -133,7 +141,7 @@ CRF is a constant-quality, 1-pass encoding mode.
133141
In layman's terms,
134142
this means that we don't need the output to meet a specific filesize,
135143
we just want the output to meet a certain quality level.
136-
CRF ranges from 0 to 51,
144+
CRF ranges from 0 to 51 (for 8-bit encoding),
137145
with 0 being the best quality
138146
and 51 being the smallest filesize,
139147
but there is a certain range of CRF settings
@@ -166,11 +174,15 @@ We use `-o` to tell which filename to write the encoded file to.
166174
In this case, x264 will write a file at `x264output.mkv`
167175
in the current directory.
168176

169-
The last argument to x264 is always the input file.
177+
The last argument we are passing to x264 is the input file.
170178
In this case, we pass `-` for the input file,
171179
which tells x264 to use the piped output from vspipe.
180+
The input argument is the only positional argument,
181+
so it does not need to be last;
182+
x264 will recognize it
183+
as the only argument without a `--` flag before it.
172184

173-
## Example 2
185+
## Example 2: Targeted File Size
174186

175187
For the next example,
176188
let's say we want to make sure our encode
@@ -186,23 +198,30 @@ This means we'll need to know a couple of things:
186198
For this example,
187199
let's say our movie is 2 hours (120 minutes) long.
188200
We'll convert that to seconds:
189-
120 \* 60 = **7200 seconds**.
201+
120 minutes \* 60 minutes/second = **7200 seconds**.
190202
- Our target filesize.
191203
We know that this is 4.7GB,
192204
but we need to convert it to kilobits.
193205
We can do this with the following steps:
194-
- 4.7GB \* 1024 = 4812.8MB
195-
- 4812.8MB \* 1024 = 4928307.2KB (uppercase B = bytes)
196-
- 4928307.2KB \* 8 = **39426457.6Kb** (lowercase b = bits)
206+
207+
```
208+
4.7GiB * 1024MiB/GiB = 4812.8MiB
209+
4812.8MiB * 1024KiB/MiB = 4928307.2KiB
210+
4928307.2KiB * 8Kbits/KiB = 39426457.6Kbits
211+
```
197212

198213
Now we divide the kilobit size we calculated by our video length,
199214
to find our kilobit per second target bitrate:
200215

201-
39426457.6Kb / 7200 seconds = **5475 Kbps**
216+
```
217+
39426457.6Kbits / 7200 seconds = 5475 Kbps
218+
```
202219

203220
And here's how we could add that to our x264 command:
204221

205-
`vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --bitrate 5475 -o x264output.mkv -`
222+
```
223+
vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --bitrate 5475 -o x264output.mkv -
224+
```
206225

207226
The `--bitrate` option, by itself,
208227
says that we want to do a 1-pass, average-bitrate encode.
@@ -211,7 +230,7 @@ to sections of the video that have more detail or motion,
211230
but the average bitrate of the video
212231
will be close to what we requested.
213232

214-
## Example 3
233+
## Example 3: 2-Pass Encoding
215234

216235
So far, we've only done 1-pass encodes.
217236
While using CRF 1-pass is great
@@ -235,12 +254,16 @@ if you need to target a certain bitrate.
235254

236255
Here's how we would run our first pass:
237256

238-
`vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --pass 1 --bitrate 5475 -o x264output.mkv -`
257+
```
258+
vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --pass 1 --bitrate 5475 -o x264output.mkv -
259+
```
239260

240261
This creates a stats file in our current directory,
241262
which x264 will use in the second pass:
242263

243-
`vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --pass 2 --bitrate 5475 -o x264output.mkv -`
264+
```
265+
vspipe --y4m myvideo.vpy - | x264 --demuxer y4m --preset veryfast --pass 2 --bitrate 5475 -o x264output.mkv -
266+
```
244267

245268
You'll notice all we had to change was `--pass 1` to `--pass 2`. Simple!
246269

0 commit comments

Comments
 (0)