annotate DOCS/tech/encoding-guide.txt @ 15815:488f31bd127e

support raw ac3 (in private pes packets without the usual dvd 4 bytes substream header). Patch by Matthias Scharzott
author nicodvb
date Sat, 25 Jun 2005 13:25:27 +0000
parents 5a39a40aa702
children cfe186231e2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15796
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
1 Topics:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
2
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
4 I. Preparing to encode
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
5 1. Identifying source material and framerate
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
6 2. Selecting the quality you want
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
7 3. Constraints for efficient encoding
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
8 4. Cropping and scaling
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
9 5. Choosing resolution and bitrate
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
10
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
11 II. Containers and codecs
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
12 1. Where the movie will be played
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
13 2. Constraints of DVD, SVCD, and VCD
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
14 3. Limitations of AVI container
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
15
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
16 III. Basic MEncoder usage
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
17 1. Selecting codecs & format
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
18 2. Selecting input file or device
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
19 3. Loading video filters
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
20 4. Notes on A/V sync
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
21
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
22 IV. Encoding procedures
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
23 1. Encoding progressive video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
24 2. Two-pass encoding
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
25 3. Encoding interlaced video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
26 4. Deinterlacing
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
27 5. Inverse telecine
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
28 6. Capturing TV input
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
29 7. Dealing with mixed-source content
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
30 8. Low-quality & damaged sources
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
31
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
32 V. Optimizing encoding quality
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
33 1. Noise removal
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
34 2. Pure quality-gain options
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
35 3. Questionable-gain options
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
36 4. Advanced MPEG-4 features
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
37
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
38
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
39
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
40 I. Preparing to encode
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
41
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
42 Before you even think about encoding a movie, you need to take several
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
43 preliminary steps to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
44
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
45
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
46 I.1. Identifying source material and framerate
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
47
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
48 The first and most important step before you encode should be
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
49 determining what type of content you're dealing with. If your source
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
50 material comes from DVD or broadcast/cable/satellite TV, it will be
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
51 stored in one of two formats: NTSC for North America and Japan, and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
52 PAL for Europe, etc. But it's important to realize that this is just
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
53 the formatting for presentation on a television, and often does NOT
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
54 correspond to the original format of the movie. In order to produce a
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
55 suitable encode, you need to know the original format. Failure to take
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
56 this into account will result in ugly combing (interlacing) artifacts
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
57 in your encode, and will greatly reduce the quality/bitrate ratio of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
58 the encoder!
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
59
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
60 Here is a list of common types of source material, where you're likely
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
61 to find them, and their properties:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
62
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
63 Standard Film: Produced for theatrical display at 24fps.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
64
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
65 PAL video: Recorded with a PAL video camera at 50 fields per second. A
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
66 field consists of just the even or odd numbered lines of a frame.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
67 Television was designed to refresh these in alternation as a cheap
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
68 form of analog compression. The human eye supposedly compensates for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
69 this, but once you understand interlacing you'll learn to see it on TV
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
70 too and never enjoy TV again. Two fields do NOT make a complete frame,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
71 because they are captured 1/50 of a second apart in time, and thus
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
72 they do not line up unless there is no motion.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
73
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
74 NTSC Video: Recorded with an NTSC video camera at 59.94 fields per
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
75 second, or 60 fields per second in the pre-color era. Otherwise
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
76 similar to PAL.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
77
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
78 Animation: Usually drawn at 24fps, but animation also comes in
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
79 mixed-framerate varieties.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
80
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
81 Computer Graphics (CG): Can be any framerate, but 24 and 30 fps are
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
82 the most frequently encountered in NTSC regions, and 25 fps in PAL
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
83 regions.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
84
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
85 Old Film: Various lower framerates.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
86
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
87 Movies consisting of frames are referred to as progressive, while
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
88 those consisting of independent fields are called interlaced, or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
89 sometimes video, although this latter term is ambiguous.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
90
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
91 To further complicate matters, some movies will be a mix of several of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
92 the above.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
93
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
94 The most important distinction to make between all of these formats is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
95 that some are frame-based, while others are field-based. WHENEVER a
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
96 movie is prepared for display on television (including DVD), it is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
97 converted to a field-based format. The various methods by which this
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
98 can be done are collectively referred to as "pulldown", of which the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
99 infamous NTSC "3:2 telecine" is one variety. Unless the original
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
100 material was also field-based (and the same fieldrate), you are
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
101 getting the movie in a format other than the original.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
102
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
103 There are several common types of pulldown:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
104
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
105 PAL 2:2 pulldown: The nicest of them all. Each frame is shown for two
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
106 fields duration, by extracting the even and odd lines and showing them
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
107 in alternation. If the original material is 24fps, this process speeds
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
108 up the movie by 4%.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
109
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
110 PAL 2:2:2:2:2:2:2:2:2:2:2:3 pulldown: Every 12th frame is shown for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
111 three fields duration, instead of just two. This avoids the 4% speedup
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
112 issue, but makes the process much more difficult to reverse. It is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
113 usually seen in musical productions where adjusting the speed by 4%
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
114 would seriously damage the musical score.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
115
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
116 NTSC 3:2 telecine: Frames are shown alternatively for 3 fields or 2
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
117 fields duration. This gives a fieldrate 5/2 times the original
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
118 framerate. The result is also slowed down very slightly from 60 fields
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
119 per second to 59.94 fields per second to maintain NTSC fieldrate.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
120
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
121 NTSC 2:2 pulldown: Used for showing 30fps material on NTSC. Nice, just
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
122 like 2:2 PAL pulldown.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
123
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
124 There are also methods for converting between NTSC and PAL video. Such
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
125 topics are beyond the scope of this guide. If you encounter such a
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
126 movie and want to encode it, your best bet is to find a copy in the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
127 original format. NTSC/PAL conversion is highly destructive and cannot
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
128 be reversed cleanly, so your encode will greatly suffer if it is made
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
129 from a converted source.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
130
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
131 When video is stored on DVD, consecutive pairs of fields are grouped
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
132 as a frame, even though they are not intended to be shown at the same
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
133 moment in time. The MPEG2 standard used on DVD and digital TV provides
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
134 a way to encode the original progressive frames, and store the number
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
135 of fields for which each should be shown in the frame headers. If this
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
136 method has been used, the term "soft telecine" will often be used to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
137 describe the movie, since the process only directs the DVD player to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
138 apply pulldown to the movie rather than altering the movie itself.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
139 This case is highly preferable since it can easily be reversed
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
140 (actually ignored) by the encoder, and since it preserves maximal
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
141 quality. However, many DVD and broadcast production studios do not use
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
142 proper encoding techniques, and instead produce movies with "hard
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
143 telecine", where fields are actually duplicated in the encoded MPEG2.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
144
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
145 The procedures for dealing with these cases will be covered later in
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
146 this guide. For now, we leave you with some guides to identifying
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
147 which type of material you're dealing with:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
148
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
149 NTSC regions:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
150
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
151 - If MPlayer prints that the framerate has changed to 23.976 when
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
152 watching your movie, and never changes back, it's almost certainly
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
153 24fps content that has been "soft telecined".
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
154
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
155 - If MPlayer shows the framerate switching back and forth between
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
156 23.976 and 29.97, and you see "combing" at times, then there are
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
157 several possibilities. The 23.976 fps segments are almost certainly
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
158 24fps progressive content, "soft telecined", but the 29.97 fps parts
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
159 could be either hard-telecined 24fps content or NTSC video content.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
160 Use the same guidelines as the following two cases to determine
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
161 which.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
162
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
163 - If MPlayer never shows the framerate change, and every single frame
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
164 with motion appears combed, your movie is NTSC video at 59.94 fields
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
165 per second.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
166
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
167 - If MPlayer never shows the framerate change, and two frames out of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
168 every five appear combed, your movie is "hard telecined" 24fps
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
169 content.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
170
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
171 PAL regions:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
172
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
173 - If you never see any combing, your movie is 2:2 pulldown.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
174
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
175 - If you see combing alternating in and out every half second, then
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
176 your movie is 2:2:2:2:2:2:2:2:2:2:2:3 pulldown.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
177
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
178 - If you always seem combing during motion, then your movie is PAL
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
179 video at 50 fields per second.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
180
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
181 Hint: MPlayer can slow down movie playback with the -speed option. Try
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
182 using -speed 0.2 to watch the movie very slowly and identify the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
183 pattern, if you can't see it at full speed.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
184
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
185
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
186 I.2. Selecting the quality you want
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
187
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
188 It's possible to encode your movie at a wide range of qualities. With
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
189 modern video encoders and a bit of pre-codec compression (downscaling
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
190 and denoising), it's possible to achieve very good quality at 700 MB,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
191 for a 90-110 minute widescreen movie. And all but the longest movies
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
192 can be encoded with near-perfect quality at 1400 MB.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
193
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
194 If you do not plan to store your movies on CD or other size-limited
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
195 media, and you want maximal quality at all costs, you can encode in
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
196 constant quantizer mode, which will not aim to meet a specific target
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
197 bitrate or filesize but instead use the maximal accuracy encoding for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
198 all frames. This is not recommended in most cases, because you can
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
199 achieve significantly smaller file sizes without noticeable loss.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
200 However, it may be desirable for the hardcore archivists out there.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
201
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
202
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
203 I.4. Cropping and scaling
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
204
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
205 Recall from the previous section that the final picture size you
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
206 encode should be a multiple of 16 (in both width and height). This can
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
207 be achieved by cropping, scaling, or a combination of both.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
208
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
209 When cropping, there are a few guidelines that must be followed to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
210 avoid damaging your movie. The normal YUV format, 4:2:0, stores chroma
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
211 (color) information subsampled, i.e. chroma is only sampled half as
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
212 often in each direction as luma (intensity) information. Observe this
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
213 diagram, where L indicates luma sampling points and C chroma.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
214
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
215 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
216 C C C C
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
217 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
218
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
219 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
220 C C C C
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
221 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
222
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
223 As you can see, rows and columns of the image naturally come in pairs.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
224 Thus your crop offsets and dimensions MUST be even numbers. If they
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
225 are not, the chroma will no longer line up correctly with the luma. In
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
226 theory, it's possible to crop with odd offsets, but it requires
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
227 resampling the chroma which is potentially a lossy operation and not
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
228 supported by the crop filter.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
229
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
230 Further, interlaced video is sampled as follows:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
231
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
232 TOP FIELD BOTTOM FIELD
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
233
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
234 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
235 C C C C
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
236 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
237
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
238 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
239 C C C C
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
240 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
241
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
242 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
243 C C C C
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
244 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
245
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
246 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
247 C C C C
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
248 L L L L L L L L
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
249
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
250 As you can see, the pattern does not repeat until after 4 lines. So
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
251 for interlaced video, your y-offset and height for cropping must be
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
252 multiples of 4.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
253
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
254 So how do you determine a crop rectangle to begin with? Sometimes you
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
255 can guess, but the cropdetect filter in MPlayer can make it easy. Run
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
256 MPlayer with -vf cropdetect and it will print out the crop settings to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
257 remove the borders. You should let the movie run long enough that the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
258 whole picture area is used, in order to get accurate crop values.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
259 Then, test the values you get with MPlayer, using the command line
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
260 cropdetect printed, and adjust the rectangle as needed. The rectangle
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
261 filter can help by allowing you to interactively position the crop
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
262 rectangle over your movie. Remember to follow the above divisibility
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
263 guidelines so that you do not misalign the chroma planes.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
264
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
265 If you will be scaling your movie, it's usually best to crop only the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
266 black borders and noise, then scale so that the resulting dimensions
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
267 are multiples of 16. This can slightly distort the aspect ratio of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
268 your movie, but in practice the error cannot be seen. It's certainly
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
269 much less visible than the MPEG artifacts you will see from failing to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
270 crop & scale well.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
271
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
272 In certain cases, scaling may be undesirable. Scaling in the vertical
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
273 direction is difficult with interlaced video, and if you wish to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
274 preserve the interlacing, you should usually refrain from scaling. If
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
275 you will not be scaling but you still want to use multiple-of-16
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
276 dimensions, you will have to overcrop. Do not undercrop, since black
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
277 borders are very bad for encoding!
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
278
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
279
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
280
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
281
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
282 I.5. Choosing resolution and bitrate
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
283
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
284 If you will not be encoding in constant quantizer mode, you need to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
285 select a bitrate. The concept of bitrate is quite simple. It's the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
286 (average) number of bits that will be consumed to store your movie,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
287 per second. Normally bitrate is measured in kilobits (1000 bits) per
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
288 second. The size of your movie on disk is the bitrate times the length
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
289 of the movie in time, plus a small amount of "overhead" (see the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
290 section on codecs and containers). Other parameters such as scaling,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
291 cropping, etc. will NOT alter the file size unless you change the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
292 bitrate as well!
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
293
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
294 Bitrate does NOT scale proportional to resolution. That is to say, a
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
295 320x240 file at 200 kbit/sec will not be the same quality as the same
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
296 movie at 640x480 and 800 kbit/sec! There are two reasons for this:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
297
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
298 1. Perceptual: You notice MPEG artifacts more if they're scaled up
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
299 bigger! Artifacts appear on the scale of blocks (8x8). Your eye
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
300 will not see errors in 4800 small blocks as easily as it sees
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
301 errors in 1200 large blocks (assuming you'll be scaling both to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
302 fullscreen).
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
303
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
304 2. Theoretical: When you scale down an image but still use the same
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
305 size (8x8) blocks for the frequency space transform, you move more
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
306 data to the high frequency bands. Roughly speaking, each pixel
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
307 contains more of the detail than it did before. So even though your
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
308 scaled-down picture contains 1/4 the information in the spacial
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
309 directions, it could still contain a large portion of the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
310 information in the frequency domain (assuming that the high
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
311 frequencies were underutilized in the original 640x480 image).
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
312
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
313 Past guides have recommended choosing a bitrate and resolution based
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
314 on a "bits per pixel" approach, but this is usually not valid due to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
315 the above reasons. A better estimate seems to be that bitrates scale
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
316 proportional to the square root of resolution, so that 320x240 and 400
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
317 kbit/sec would be comparable to 640x480 at 800 kbit/sec. However this
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
318 has not been verified with theoretical or empirical rigor. Further,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
319 given that movies vary greatly with regard to noise, detail, degree of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
320 motion, etc., it's futile to make general recommendations for bits per
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
321 length-of-diagonal (the analogue of bits per pixel, using the square
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
322 root).
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
323
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
324 So far we have discussed the difficulty of choosing a bitrate and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
325 resolution.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
326
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
327 .................
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
328
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
329
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
330
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
331
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
332
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
333
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
334
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
335
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
336
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
337
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
338 II. Containers and codecs
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
339
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
340 II.1. Where the movie will be played
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
341
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
342 Perhaps the most important factor to choosing the format in which you
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
343 will encode your movie is where you want to be able to play it.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
344 Usually this involves a tradeoff between quality and features, since
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
345 the formats supported by the widest variety of players are also the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
346 worst in regards to compression.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
347
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
348 If you want to be able to play your encode on standalone/set-top
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
349 players, your primary choices are DVD, VCD, and SVCD. There are also
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
350 extensions such as KVCD and XVCD which violate the standards but work
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
351 on many players and deliver higher quality. Modern players are
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
352 beginning to support MPEG-4 ("DivX") movies in AVI and perhaps other
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
353 containers as well, but these are often buggy and require you to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
354 restrict your encodes to certain subsets of the full MPEG-4
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
355 functionality.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
356
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
357 If you wish to be able to share your movies with Windows or Macintosh
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
358 users, without them having to install additional software, your
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
359 choices are very limited. The ancient MPEG-1 format with MP2 or PCM
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
360 audio is probably the only choice that is universally supported.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
361 Interoperability with Windows/Mac also comes into play when deciding
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
362 how to encode and whether to scale to preserve aspect, since popular
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
363 media player applications for these systems do not honor the aspect
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
364 ratio encoding stored in MPEG-4 avi files.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
365
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
366
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
367 II.2. Constraints of DVD, SVCD, and VCD
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
368
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
369 Unfortunately, the DVD, SVCD, and VCD formats are subject to heavy
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
370 constraints. Only a small selection of encoded picture sizes & aspect
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
371 ratios are available. If your movie does not meet one of these, you
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
372 must scale and crop or add black borders (which are bad for quality!)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
373 to make it compliant.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
374
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
375 Format Resolution V.Codec A.Codec FPS Aspect
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
376 NTSC DVD 720x480 MPEG-2 AC3,PCM 24,30 4:3,16:9
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
377 NTSC DVD 352x240 * MPEG-1 AC3,PCM 24,30 4:3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
378 NTSC SVCD 480x480 MPEG-2 MP2 30 4:3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
379 NTSC VCD 352x240 MPEG-1 MP2 24,30 4:3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
380 PAL DVD 720x576 MPEG-2 MP2,AC3,PCM 25 4:3,16:9
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
381 PAL DVD 352x288 * MPEG-1 MP2,AC3,PCM 25 4:3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
382 PAL SVCD 480x576 MPEG-2 MP2 25 4:3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
383 PAL VCD 352x288 MPEG-1 MP2 25 4:3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
384
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
385 * These resolutions are rarely used in DVD because they are fairly low
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
386 quality.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
387
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
388 DVD, VCD, and SVCD also constrain you to relatively low GOP sizes. 18 is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
389 supposed to be the largest allowed GOP size for 30 fps NTSCP material;
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
390 for 25 or 24 fps, the GOP size should be 15.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
391
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
392 VCD video is required to be CBR at 1152 kbps. This highly limiting
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
393 constraint also comes along with an extremly low vbv buffer size of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
394 327 kilobits. SVCD allows varying video bitrates up to 2500 kbps, and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
395 a somewhat less insane vbv buffer size of 917 kilobits is allowed. DVD
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
396 video bitrates may range anywhere up to 9800 kbps (though typical bitrates
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
397 are about half that), and the vbv buffer size is 1835 kilobits.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
398
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
399 Here is a list of fields in lavcopts that you may be required to change
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
400 in order to make usable video for VCD, SVCD, or DVD:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
401
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
402 acodec: mp2 for VCD, SVCD, or PAL DVD; ac3 is most commonly used for DVD.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
403 PCM audio may also be used for DVD, but this is mostly a big
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
404 waste of space. Note that mp3 audio isn't spec-compliant for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
405 any of these formats, but players often have no problem playing
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
406 it anyway.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
407
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
408 abitrate: 224 for VCD; user-selectable for DVD and SVCD, but commonly used
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
409 values range from 192 to 384 kbps.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
410
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
411 vcodec: mpeg1video for VCD; mpeg2video for SVCD; mpeg2video is usually
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
412 used for DVD but you may also use mpeg1video for CIF resolutions.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
413
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
414 keyint: 18 for 30fps material, or 15 for 25/24 fps material. Commercial
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
415 producers seem to prefer keyframe intervals of 12.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
416
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
417 vrc_buf_size: 327 for VCD, 917 for SVCD, and 1835 for DVD.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
418
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
419 vrc_minrate: 1152, for VCD. May be left alone for SVCD and DVD.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
420
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
421 vrc_maxrate: 1152 for VCD; 2500 for SVCD; 9800 for DVD. For SVCD and DVD,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
422 you might wish to use lower values depending on your own
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
423 personal preferences and requirements.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
424
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
425 vbitrate: 1152 for vcd; up to 2500 for SVCD; up to 9800 for DVD. For the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
426 latter two formats, vbitrate should be set based on personal
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
427 preference. For instance, if you insist on fitting 20 or so
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
428 hours on a DVD, you could use vbitrate=400. The resulting
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
429 video quality would probably be quite bad. If you are trying
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
430 to squeeze out the maximum possible quality on a DVD, use
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
431 vbitrate=9800, but be warned that this could constrain you to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
432 less than an hour of video on a single-layer DVD.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
433
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
434 Here is a typical minimum set of lavcopts for encoding video for a VCD:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
435
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
436 -lavcopts vcodec=mpeg1video:vrc_buf_size=327:vrc_minrate=1152:\
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
437 vrc_maxrate=1152:vbitrate=1152:keyint=15:acodec=mp2
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
438
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
439 SVCD:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
440
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
441 -lavcopts vcodec=mpeg2video:vrc_buf_size=917:vrc_maxrate=2500:vbitrate=1800:\
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
442 keyint=15:acodec=mp2
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
443
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
444 DVD:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
445
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
446 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:\
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
447 vbitrate=5000:keyint=15:acodec=ac3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
448
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
449 For higher quality encoding, you may also wish to add quality-enhancing
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
450 options to lavcopts, such as trell, mbd=2, and others. Note that qpel
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
451 and v4mv, while often useful with MPEG-4, are not usable in MPEG-1 or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
452 MPEG-2. Also, if you are trying to make a very high quality DVD encode,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
453 it may be useful to add dc=10 to lavcopts. Doing so may help reduce the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
454 appearance of blocks in flat-colored areas. Putting it all together,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
455 here is an example of a set of lavcopts for a higher quality DVD:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
456
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
457 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:\
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
458 vbitrate=8000:keyint=15:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:\
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
459 predia=-10:cbp:mv0:vqmin=1:lmin=1:dc=10
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
460
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
461 If your movie has 2.35:1 aspect (most recent action movies), you will
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
462 have to add black borders or crop the movie down to 16:9 to make a DVD
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
463 or VCD. If you add black borders, try to align them at 16-pixel
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
464 boundaries in order to minimize the impact on encoding performance.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
465 Thankfully DVD has sufficiently excessive bitrate that you do not have
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
466 to worry too much about encoding efficiency, but SVCD and VCD are
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
467 highly bitrate-starved and require effort to obtain acceptable
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
468 quality.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
469
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
470
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
471
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
472
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
473
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
474 II.3. Limitations of the AVI container
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
475
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
476 Although it's the most widely-supported format after MPEG-1, AVI also
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
477 has some major drawbacks. Perhaps the most obvious is the overhead.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
478 For each chunk of the AVI file, 24 bytes are wasted on headers and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
479 index. This translates into a little over 5 MB per hour, or 1-2.5%
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
480 overhead for a 700 MB movie. This may not seem like much, but it could
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
481 mean the difference between being able to use 700 kbit/sec video or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
482 714 kbit/sec, and every bit of quality counts.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
483
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
484 In addition to gross inefficiency, AVI also has the following major
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
485 limitations:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
486
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
487 1. Only fixed-fps content can be stored. This is particularly limiting
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
488 if the original material you want to encode is mixed content, for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
489 example a mix of NTSC video and film material. Actually there are
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
490 hacks that can be used to store mixed-framerate content in AVI, but
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
491 they increase the (already huge) overhead fivefold or more so they
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
492 are not practical.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
493
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
494 2. Audio in AVI files must be either constant-bitrate (CBR) or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
495 constant-framesize (i.e. all frames decode to the same number of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
496 samples). Unfortunately, the most efficient codec, Vorbis, does not
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
497 meet either of these requirements. Therefore, if you plan to store
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
498 your movie in AVI, you'll have to use a less efficient codec such
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
499 as MP3 or AC3.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
500
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
501 With all of that said, MEncoder does not support variable-fps output
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
502 or Vorbis encoding. Therefore, you may not see these as limitations if
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
503 MEncoder is the only tool you will be using to produce your encodes.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
504 However, it is possible to use MEncoder only for the video encoding,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
505 and then use external tools to encode the audio and mux it into
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
506 another container format.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
507
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
508
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
509
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
510
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
511
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
512
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
513
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
514 III. Basic MEncoder usage
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
515
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
516 III.1. Selecting codecs & format
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
517
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
518 Audio and video codecs for encoding are selected with the -oac and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
519 -ovc options, respectively. The following choices are available,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
520 although some may not have been enabled at compiletime:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
521
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
522 Audio Codecs
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
523 mp3lame Encode VBR or CBR MP3 with LAME
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
524 lavc Use one of libavcodec's audio encoders
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
525 pcm Uncompressed PCM audio
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
526 copy Do not reencode, just copy compressed frames
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
527
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
528 Video codecs
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
529 lavc Use one of libavcodec's video encoders
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
530 xvid XviD
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
531 raw Uncompressed video frames
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
532 copy Do not reencode, just copy compressed frames
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
533 frameno Used for 3-pass encoding (not recommended)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
534
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
535 Several other video codecs are available, but not recommended. The
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
536 lavc audio and video encoders have additional suboptions to select
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
537 which codec to use within lavc. The syntax is:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
538
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
539 -lavcopts acodec=audio_codec_name
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
540 -lavcopts vcodec=video_codec_name
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
541
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
542 Your choices for lavc audio are mp2, ac3, and various adpcm formats
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
543 (low efficiency). For lavc video, you have many more choices:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
544
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
545 mpeg1video MPEG-1 video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
546 mpeg2video MPEG-2 video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
547 mpeg4 MPEG-4 video, standards-compliant
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
548 msmpeg4 Pre-standard MPEG-4 used by MS (aka DivX3)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
549 msmpeg4v2 Pre-standard MPEG-4 used by MS (low quality)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
550 msmpeg4v1 Pre-standard MPEG-4 used by MS (low quality)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
551 wmv1 Windows Media Video, V1 (aka WMV7)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
552 wmv2 Windows Media Video, V2 (aka WMV8)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
553 dvvideo DV video (used by DV cameras)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
554 mjpeg Motion JPEG
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
555 ljpeg Lossless JPEG
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
556 ffv1 Lossless FFmpeg video codec #1 (slow)
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
557 huffyuv A standard lossless codec
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
558
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
559 ...and lots more that aren't worth mentioning for most people.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
560
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
561
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
562
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
563 III.2. Selecting input file or device
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
564
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
565 MEncoder can encode from files or directly from a DVD or VCD disc.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
566 Simply include the filename on the command line to encode from a file,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
567 or dvd://titlenumber or vcd://tracknumber to encode from a DVD title
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
568 or VCD track. If you have already copied a DVD to your hard drive and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
569 wish to encode from the copy, you should still use the dvd:// syntax,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
570 along with -dvd-device followed by the path to the copied DVD root.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
571 The -dvd-device and -cdrom-device options can also be used to override
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
572 the paths to the device nodes for reading directly from disc, if the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
573 defaults of /dev/dvd and /dev/cdrom do not work on your system.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
574
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
575 When encoding from DVD, it is often desirable to select a chapter or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
576 range of chapters to encode. You can use the -chapter option for this
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
577 purpose. For example, -chapter 1-4 will only encode chapters 1 through
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
578 4 from the DVD. This is especially useful if you will be making a 1400
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
579 MB encode targetted for two CDs, since you can ensure the split occurs
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
580 exactly at a chapter boundary rather than in the middle of a scene.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
581
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
582 If you have a supported TV capture card, you can also encode from the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
583 TV-in device. Use tv://channelnumber as the filename, and -tv to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
584 configure various capture settings. DVB input works similarly.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
585
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
586
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
587 III.3. Loading video filters
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
588
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
589 Learning how to use MEncoder's video filters is essential to producing
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
590 good encodes. All video processing is performed through the filters --
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
591 cropping, scaling, color adjustment, noise removal, sharpening,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
592 deinterlacing, telecine, inverse telecine, and deblocking, just to
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
593 name a few. Along with the vast number of supported input formats, the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
594 variety of filters available in MEncoder is one of its main advantages
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
595 over other similar programs.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
596
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
597 Filters are loaded in a chain using the -vf option:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
598
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
599 -vf filter1=options,filter2=options,...
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
600
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
601 Most filters take several numeric options separated by colons, but the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
602 syntax for options varies from filter to filter, so read the man page
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
603 for details on the filters you wish to use.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
604
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
605 Filters operate on the video in the order they are loaded. For
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
606 example, the following chain:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
607
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
608 -vf crop=688:464:12:4,scale=640:464
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
609
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
610 will first crop the 688x464 region of the picture with upper-left
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
611 corner at (12,4), and then scale the result down to 640x464.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
612
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
613 Certain filters need to be loaded at or near the beginning of the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
614 filter chain, in order to take advantage of information from the video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
615 decoder that will be lost or invalidated by other filters. The
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
616 principal examples are pp (postprocessing, only when it is performing
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
617 deblock or dering operations), spp (another postprocessor to remove
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
618 MPEG artifacts), pullup (inverse telecine), and softpulldown (for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
619 converting soft telecine to hard telecine).
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
620
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
621 Advanced topics in filter chains and usage information for specific
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
622 filters will follow in chapters IV and V, as they are needed for the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
623 topics covered.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
624
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
625
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
626
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
627 III.4. Notes on A/V sync
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
628
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
629 MEncoder's audio/video synchronization algorithms were designed with
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
630 the intention of recovering files with broken sync. However they seem
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
631 to cause unnecessary skipping and duplication of frames, and possibly
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
632 slight A/V desync, when used with proper input. It is therefore
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
633 recommended that you switch to basic A/V sync with the -mc 0 option,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
634 or put this in your ~/.mplayer/mencoder config file, as long as you
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
635 are only working with good sources (DVD, TV capture, high quality
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
636 MPEG-4 rips, etc) and not broken ASF/RM/MOV files.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
637
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
638 If you want to further guard against strange frame skips and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
639 duplication, you can use both -mc 0 and -noskip. This will prevent ALL
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
640 A/V sync, and copy frames one-to-one, so you cannot use it if you will
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
641 be using any filters that unpredictably add or drop frames, or if your
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
642 input file has variable framerate! Therefore, using -noskip is not in
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
643 general recommended.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
644
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
645 The so-called "three-pass" encoding which MEncoder supports has been
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
646 reported to cause A/V desync. This will definitely happen if it is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
647 used in conjunction with certain filters, therefore, it is now
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
648 recommended NOT to use three-pass mode. This feature is only left for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
649 compatibility purposes and for expert users who understand when it is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
650 safe to use and when it is not. If you have never heard of three-pass
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
651 mode before, forget that we even mentioned it!
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
652
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
653 There have also been reports of A/V desync when encoding from stdin
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
654 with MEncoder. Do not do this! Always use a file or CD/DVD/etc device
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
655 as input.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
656
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
657
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
658
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
659
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
660
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
661 IV.1. Encoding progressive video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
662
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
663 As long as your input video is progressive (see section I.1),
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
664
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
665
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
666 Let's finally see a few examples:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
667
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
668 Encoding from 2:2 pulldown PAL DVD, title 1
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
669 2.35:1 picture aspect
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
670 1200 kbit/sec MPEG-4 video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
671 128 kbit/sec average-bitrate MP3 audio
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
672
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
673 mencoder dvd://1 -vf crop=712:432,scale=640:288 -mc 0 -oac mp3lame\
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
674 -lameopts abr:br=128 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
675
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
676 The crop size was presumably obtained by using the cropdetect filter
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
677 in MPlayer, or experimenting first with crop rectangles in MPlayer.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
678 The output framerate will be 25 fps, the same as the original DVD. It
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
679 would be preferable to adjust the playback speed to match the original
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
680 24 fps theatrical rate, but this is not yet possible with MEncoder.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
681 The options we pass to libavcodec are the bare minimum, and will yield
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
682 relatively poor quality. We will refine then in subsequent sections.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
683
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
684 Now, a second example:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
685
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
686 Encoding from soft-telecined NTSC DVD, title 3
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
687 2.35:1 picture aspect
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
688 900 kbit/sec MPEG-4 video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
689 Keeping the original AC3 audio
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
690
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
691 mencoder dvd://1 -vf crop=708:360,scale=640:288 -mc 0 -oac copy \
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
692 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=900 -ofps 23.976023976
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
693
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
694 This example is very similar to the first example, except for the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
695 -ofps option to adjust the output framerate. Unless you tell it
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
696 otherwise, MEncoder takes its output framerate from the input
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
697 framerate. This is reported as 29.97 fps (actually 30000/1001), or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
698 rather, 29.97 pairs of fields per second. But since the DVD is
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
699 soft-telecined, 1/5 of these fields are not actually present, but
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
700 intended to be added by the player when it telecines the movie in
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
701 realtime. There are actually only 23.976 (24000/1001) frames per
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
702 second. If you leave the framerate at the default, 29.97, it will
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
703 still work, but every 4th frame will get encoded in duplicate, making
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
704 the motion appear choppy.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
705
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
706 Finally, a comment on the number 23.976023976. You'll often see
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
707 recommendations to use -ofps 23.976, but this is wrong. MEncoder will
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
708 reduce 23.976 to 2997/125, which is not the same as 24000/1001. So in
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
709 order to get the right framerate written in the output file's header,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
710 always use plenty of precision.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
711
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
712
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
713
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
714
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
715 IV.2. Two-pass encoding
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
716
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
717 The complexity (and thus the number of bits) required to compress the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
718 frames of a movie can vary greatly from one scene to another. Modern
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
719 video encoders can adjust to these needs as they go and vary the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
720 bitrate. However, they cannot exceed the requested average bitrate for
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
721 long stretches of time, because they do not know the bitrate needs of
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
722 future scenes.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
723
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
724 Two-pass encoding solves this problem by encoding the movie twice.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
725 During the first pass, statistics are generated regarding the number
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
726 of bits used by each frame and the quantization level (quality) at
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
727 which it was encoded. Then, when the second pass begins, the encoder
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
728 reads these statistics and redistributes the bits from frames where
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
729 they are in excess to frames that are suffering from low quality.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
730
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
731 In order for the process to work properly, the encoder should be given
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
732 exactly the same sequence of frames during both passes. This means
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
733 that the same filters must be used, the same encoder parameters must
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
734 be used (with the possible exception of bitrate), and the same frame
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
735 drops and duplications (if any) must take place.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
736
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
737 In theory it's possible to use -oac pcm or -oac copy during the first
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
738 pass to avoid spending time encoding the audio. However, this can
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
739 result in slight variations in which frames get dropped or duplicated,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
740 so it may be preferable to encode the audio during the first pass as
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
741 well as the second. This also allows you to examine the final audio
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
742 bitrate and filesize, and to adjust the audio or video bitrate
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
743 slightly between passes if you don't meet your target size.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
744
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
745 Here is an example:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
746
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
747 Encoding from an existing AVI file
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
748 500 kbit/sec MPEG-4 video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
749 96 kbit/sec average-bitrate MP3 audio
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
750
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
751 mencoder bar.avi -vf scale=448:336 -mc 0 -oac mp3lame -lameopts \
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
752 abr:br=96 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500:vpass=1
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
753
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
754 mencoder bar.avi -vf scale=448:336 -mc 0 -oac mp3lame -lameopts \
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
755 abr:br=96 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500:vpass=2
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
756
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
757 If you do not want to overwrite the output from the first pass when
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
758 you begin the second, you can use the -o option to choose a different
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
759 output filename. Note the addition of the vpass option in this
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
760 example. If vpass is not specified, single-pass encoding is performed.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
761 If vpass=1, a log file is written with statistics from the first pass.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
762 If vpass=2, the log file is read and the second pass is encoded based
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
763 on those statistics. If you are short on disk space or don't want the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
764 extra disk wear from writing the file twice, you can use -o /dev/null
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
765 during the first pass. However, sometimes it is beneficial to watch
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
766 the first-pass file before beginning the second pass to make sure
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
767 nothing went wrong in the encoding.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
768
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
769 Next, an example using XviD instead of libavcodec:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
770
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
771 Encoding from an existing AVI file
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
772 500 kbit/sec MPEG-4 video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
773 Copying the existing audio stream unmodified
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
774
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
775 mencoder foo.avi -vf scale=320:240 -mc 0 -oac copy -ovc xvid \
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
776 -xvidencopts bitrate=400:pass=1
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
777
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
778 mencoder foo.avi -vf scale=320:240 -mc 0 -oac copy -ovc xvid \
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
779 -xvidencopts bitrate=400:pass=2
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
780
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
781 The options used are slightly different, but the process is otherwise
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
782 the same.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
783
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
784
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
785
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
786
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
787 IV.3. Encoding interlaced video
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
788
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
789 If the movie you want to encode is interlaced (NTSC video or PAL
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
790 video), you will need to choose whether you want to deinterlace or
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
791 not. While deinterlacing will make your movie usable on progressive
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
792 scan displays such a computer monitors and projectors, it comes at a
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
793 cost: the field rate of 50 or 59.94 fields per second is halved to 25
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
794 or 29.97 frames per second, and roughly half the information in your
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
795 movie will be lost during scenes with significant motion.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
796
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
797 Therefore, if you are encoding for high quality archival purposes, it
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
798 is recommended not to deinterlace. You can always deinterlace the
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
799 movie at playback time when displaying it on progressive scan devices,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
800 and future players will be able to deinterlace to full fieldrate,
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
801 interpolating 50 or 59.94 entire frames per second from the interlaced
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
802 video.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
803
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
804 Special care must be taken when working with interlaced video:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
805
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
806 1. Crop height and y-offset must be multiples of 4.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
807
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
808 2. Any vertical scaling must be performed in interlaced mode.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
809
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
810 3. Postprocessing and denoising filters may not work as expected
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
811 unless you take special care to operate them a field at a time, and
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
812 they may damage the video if used incorrectly.
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
813
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
814 With these things in mind, here is our first example:
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
815
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
816 mencoder capture.avi -mc 0 -oac lavc -ovc lavc -lavcopts \
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
817 vcodec=mpeg2video:vbitrate=6000:ilmv:ildct:acodec=mp2:abitrate=224
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
818
5a39a40aa702 Encoding guide featured by Richard Felker III, and updated by Jeff Clagg.
gpoirier
parents:
diff changeset
819 Note the ilmv and ildct options.