@@ -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.
4752We'll walk through those concepts
4853with the following examples.
4954
50- ## Example 1
55+ ## Example 1: General-Purpose Encoding
5156
5257Open up a terminal window,
5358and navigate to the folder
5459where your VapourSynth script lives.
5560Let'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
5966Let's run through what each of these options means:
6067
@@ -69,7 +76,7 @@ If you're not,
6976it's basically a way of chaining two commands together.
7077In this case, we want to chain ` vspipe ` ,
7178the 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
8390to switch between faster encoding, or higher quality.
8491The 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,
98105but generally, if you want good quality
99106and 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
105112For the curious,
106113you 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).
108116However, this probably won't mean much at the moment.
109117Don't worry,
110118this guide will explain later
@@ -133,7 +141,7 @@ CRF is a constant-quality, 1-pass encoding mode.
133141In layman's terms,
134142this means that we don't need the output to meet a specific filesize,
135143we 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) ,
137145with 0 being the best quality
138146and 51 being the smallest filesize,
139147but 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.
166174In this case, x264 will write a file at ` x264output.mkv `
167175in 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.
170178In this case, we pass ` - ` for the input file,
171179which 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
175187For the next example,
176188let'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
198213Now we divide the kilobit size we calculated by our video length,
199214to 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
203220And 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
207226The ` --bitrate ` option, by itself,
208227says 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,
211230but the average bitrate of the video
212231will be close to what we requested.
213232
214- ## Example 3
233+ ## Example 3: 2-Pass Encoding
215234
216235So far, we've only done 1-pass encodes.
217236While using CRF 1-pass is great
@@ -235,12 +254,16 @@ if you need to target a certain bitrate.
235254
236255Here'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
240261This creates a stats file in our current directory,
241262which 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
245268You'll notice all we had to change was ` --pass 1 ` to ` --pass 2 ` . Simple!
246269
0 commit comments