20725
|
1 <?xml version="1.0" encoding="utf-8"?>
|
|
2 <!-- synced with r20683 -->
|
|
3 <!-- **Partially** translated -->
|
|
4 <chapter id="encoding-guide">
|
|
5 <title>Кодирование с <application>MEncoder</application></title>
|
|
6
|
|
7 <sect1 id="menc-feat-dvd-mpeg4">
|
|
8 <title>Создание высококачественного MPEG-4 ("DivX") рипа из DVD фильма</title>
|
|
9
|
|
10 <para>
|
|
11 Одним часто задаваемым вопросом является "Как мне сделать рип самого высокого
|
|
12 качества для заданного размера?". Другой вопрос "Как мне создать DVD рип с самым
|
|
13 высоким возможным качеством? Я не беспокоюсь о размере файла, мне нужно лишь
|
|
14 наилучшее качество.".
|
|
15 </para>
|
|
16
|
|
17 <para>
|
|
18 Последний вопрос, похоже, отчасти неверно сформулирован. В конце концов, если
|
|
19 Вы не беспокоитесь о размере файла, почему бы просто не скопировать весь MPEG-2
|
|
20 видео поток с DVD? Конечно, ваш AVI файл будет занимать около 5GB,
|
|
21 но если Вы желате наилучшее качество и не волнуетесь о размере, то это,
|
|
22 несомненно, лучшее решение.
|
|
23 </para>
|
|
24
|
|
25 <para>
|
|
26 В действительности, причиной, по которой Вы хотите перекодировать DVD в MPEG-4,
|
|
27 является именно Ваше <emphasis role="bold">беспокойство</emphasis>
|
|
28 о размере файла.
|
|
29 </para>
|
|
30
|
|
31 <para>
|
|
32 Сложно дать универсальный рецепт о создании DVD рипа очень высокого
|
|
33 качества. Необходимо рассмотреть несколько факторов, и Вы должны
|
|
34 понимать эти детали, иначе Вы, скорее всего, разочаруетесь своими
|
|
35 результатами. Ниже мы исследуем некоторые из этих вопросов, а затем
|
|
36 рассмотрим пример. Мы предполагаем, что Вы используете
|
|
37 <systemitem class="library">libavcodec</systemitem> для кодирования видео,
|
|
38 хотя теория также применима и к другим кодекам.
|
|
39 </para>
|
|
40
|
|
41 <para>
|
|
42 Если это кажется для Вас слишком сложным, то Вам, пожалуй, следует использовать
|
|
43 один из многочисленных неплохих фронтендов, указанных в
|
|
44 <ulink url="http://www.mplayerhq.hu/design7/projects.html#mencoder_frontends">разделе MEncoder</ulink>
|
|
45 нашей страницы родственных проектов.
|
|
46 Так Вы должны получить высококачественные рипы без особых размышлений,
|
|
47 поскольку большинство этих утилит разработаны для принятия умных решений за Вас.
|
|
48 </para>
|
|
49
|
|
50 <sect2 id="menc-feat-dvd-mpeg4-preparing-encode">
|
|
51 <title>Подготовка к кодированию: Идентификация исходного материала и кадровой
|
|
52 частоты</title>
|
|
53 <para>
|
|
54 Прежде, чем даже задумываться о кодировании фильма, Вам необходимо выполнить
|
|
55 некоторые предварительные действия.
|
|
56 </para>
|
|
57
|
|
58 <para>
|
|
59 Первым и наиболее важным шагом перед кодированием должно быть опеределение
|
|
60 типа содержимого, с которым Вы работате.
|
|
61 Если источником Ваших исходных материалов является DVD или
|
|
62 широковещательное/кабельное/спутниковое TV, оно будет содержаться в одном из
|
|
63 двух форматов: NTSC для Северной Америки и Японии, PAL для Европы и т.д..
|
|
64 Однако, важно понимать, что это только форматирование для показа на
|
|
65 телевидении, и оно часто
|
|
66 <emphasis role="bold">не</emphasis> соответствует
|
|
67 исходному формату фильма.
|
|
68 Опыт показывает, что NTSC материал существенно более сложен для кодирования,
|
|
69 т.к. в нём содержится больше элементов, которые нужно идентифицировать.
|
|
70 Для проведения удачного кодирования, Вам необходимо знать исходный формат.
|
|
71 Отказ от принятия этого во внимание приведёт к различным дефектам в Вашем
|
|
72 кодировании, включая безобразные гребешки (артефакты череcстрочной развёртки)
|
|
73 и повторяющиеся или даже потерянные кадры.
|
|
74 Кроме ухудщения картинки, артефакты так же уменьшают эффективность кодирования:
|
|
75 Вы получите худшее качество на единицу битпотока.
|
|
76 </para>
|
|
77
|
|
78 <sect3 id="menc-feat-dvd-mpeg4-preparing-encode-fps">
|
|
79 <title>Определение кадровой чатоты источника</title>
|
|
80 <para>
|
|
81 Вот список, содержащий общие типы исходных материалов, где,
|
|
82 преимущественно, можно найти и их свойства:
|
|
83 </para>
|
|
84 <itemizedlist>
|
|
85 <listitem><para>
|
|
86 <emphasis role="bold">Стандартный фильм</emphasis>: Производятся
|
|
87 для театральных показов на 24 fps [кадр/сек].
|
|
88 </para></listitem>
|
|
89 <listitem><para>
|
|
90 <emphasis role="bold">PAL видео</emphasis>: Записывается с помощью
|
|
91 PAL видеокамеры при 50 полях в секунду.
|
|
92 Поле состоит только из чётных или нечётных линий кадра.
|
|
93 Телевидение было разработано для обновления этих полей попеременно,
|
|
94 что используется как вид дешёвого аналогового сжатия.
|
|
95 Человеческий глаз, предположительно, компенсирует это, но однажды
|
|
96 поняв чересстрочную развёртку, Вы научитесь видеть её и на TV и
|
|
97 Вам больше никогда не понравится телевидение.
|
|
98 Два поля <emphasis role="bold">не</emphasis> составляют
|
|
99 целый кадр, поскольку они снимаются с задержкой в 1/50 секунды
|
|
100 и, следовательно, не формируют одно изображение, за исключением случая
|
|
101 полного отсутсвия движения.
|
|
102 </para></listitem>
|
|
103 <listitem><para>
|
|
104 <emphasis role="bold">NTSC видео</emphasis>: Записывается с помощью
|
|
105 NTSC видеокамеры при 60000/1001 полях в секунду, или 60 полях в секунду
|
|
106 в эпоху чёрно-белого TV.
|
|
107 В других отношениях аналогично PAL.
|
|
108 </para></listitem>
|
|
109 <listitem><para>
|
|
110 <emphasis role="bold">Анимация</emphasis>: Обычно рисуется на 24 fps,
|
|
111 но также существуют разновидности со смешанной кадровой частотой.
|
|
112 </para></listitem>
|
|
113 <listitem><para>
|
|
114 <emphasis role="bold">Компьютерныя графика (CG)</emphasis>: Может
|
|
115 быть с любой частотой кадров, но некоторые встречаются чаще остальных;
|
|
116 24 и 30 кадров в секунду типичны для NTSC, и 25 fps типично для PAL.
|
|
117 </para></listitem>
|
|
118 <listitem><para>
|
|
119 <emphasis role="bold">Старый фильм</emphasis>: Различные низкие
|
|
120 кадровые частоты.
|
|
121 </para></listitem>
|
|
122 </itemizedlist>
|
|
123 </sect3>
|
|
124
|
|
125 <sect3 id="menc-feat-dvd-mpeg4-preparing-encode-material">
|
|
126 <title>Идентификация исходного материала</title>
|
|
127 <para>
|
|
128 Фильмы, состоящие из кадров, называются фильмами с построчной (или прогрессивной)
|
|
129 развёрткой, а состоящие из независимых полей — фильмами с чересстрочной
|
|
130 развёрткой или просто видео; однако, последний термин двусмысленный.
|
|
131 </para>
|
|
132 <para>
|
|
133 Из-за дальнейших усложнений, некоторые фильмы будут смесью
|
|
134 нескольких, указанных выше.
|
|
135 </para>
|
|
136 <para>
|
|
137 Наиболее важным различием между всеми этими форматами является
|
|
138 то, что одни из них основаны на кадрах, а другие — на полях.
|
|
139 <emphasis role="bold">Любой</emphasis> фильм, подготовленный для
|
|
140 просмотра на телевидении (включая DVD), преобразуется в формат,
|
|
141 основанный на полях.
|
|
142
|
|
143 <!-- FIXME: Существует ли лучший *краткий* (1-2 слова) перевод для
|
|
144 терминов pulldown и telecine? В литературе, которую я нашёл,
|
|
145 используют или указанные мной, по сути дела, транслитерации,
|
|
146 или так и оставляют английские названия.
|
|
147 А точный перевод можно выполнить только целым предложением
|
|
148 (т.е. определением), что совершенно неуместно в контексте
|
|
149 данного документа, где эти термины часто встречаются. -->
|
|
150
|
|
151 Различные методы, с помощью которых это может быть сделано, совокупно
|
|
152 называются "телесин" (англ. telecine), одним из вариантов которого
|
|
153 является отвратительный NTSC "3:2 пулдаун" (англ. pulldown).
|
|
154 За исключением случаев, когда формат исходного материала был
|
|
155 также основан на полях (и с такой же частотой полей), Вы получите
|
|
156 фильм в формате отличном от исходного.
|
|
157 </para>
|
|
158
|
|
159 <itemizedlist>
|
|
160 <title>Существует несколько общих типов пулдауна:</title>
|
|
161 <listitem><para>
|
|
162 <emphasis role="bold">PAL 2:2 пулдаун</emphasis>: Наилучший из всех.
|
|
163 Каждый кадр показывается за время длительности двух полей путем
|
|
164 извлечения чётных и нечётных строк и их попременного показа.
|
|
165 Если в исходном материале 24 fps, то это ускоряет воспроизведение фильма
|
|
166 на 4%.
|
|
167 </para></listitem>
|
|
168 <listitem><para>
|
|
169 <emphasis role="bold">PAL 2:2:2:2:2:2:2:2:2:2:2:3 пулдаун</emphasis>:
|
|
170 Каждый 12-й кадр показывается за время длительности трёх полей,
|
|
171 вместо двух.
|
|
172 Это помогает избежать проблемы 4%-го ускорения, но делает обращение
|
|
173 процесса существенно более сложным.
|
|
174 Такие вещи обычно наблюдаются в музыкальных произведениях, где
|
|
175 изменение скорости на 4% существенно повредит музыкальную партитуру.
|
|
176 </para></listitem>
|
|
177 <listitem><para>
|
|
178 <emphasis role="bold">NTSC 3:2 телесин</emphasis>: Кадры показываются
|
|
179 попеременно за время длительности 3-х полей или 2-х полей.
|
|
180 Это даёт частоту полей в 2.5 раза больше исходной частоты кадров.
|
|
181 Результат также очень незначительно замедляется от 60 до 60000/1001
|
|
182 полей в секунду для поддержания частоты полей NTSC.
|
|
183 </para></listitem>
|
|
184 <listitem><para>
|
|
185 <emphasis role="bold">NTSC 2:2 пулдаун</emphasis>: Используется
|
|
186 для отображения материала с 30 fps на NTSC.
|
|
187 Так же мил, как и 2:2 PAL пулдаун.
|
|
188 </para></listitem>
|
|
189 </itemizedlist>
|
|
190
|
|
191 <para>
|
|
192 Так же существуют методы для преобразования между NTSC и PAL видео,
|
|
193 но подобные темы выходят за рамки данного руководства.
|
|
194 Если Вам попался такой фильм, и Вы хотите кодировать его,
|
|
195 лучшим решением будет найти копию в исходном формате.
|
|
196 Преобразование между этими двумя форматами вносит большие потери
|
|
197 и не может быть точно обращено, так что Ваше кодирование
|
|
198 существенно пострадает, если оно делается из преобразованного
|
|
199 источника.
|
|
200 </para>
|
|
201 <para>
|
|
202 Когда видео находится на DVD, последовательные пары полей
|
|
203 группируются как кадр, даже если они не предназначены для
|
|
204 одновременного отображения.
|
|
205 Стандарт MPEG-2, используемый на DVD и цифровом TV предоставляет
|
|
206 возможность одновременно кодировать исходные кадры с построчной
|
|
207 развёрткой и сохранять число полей, в течении которых кадр
|
|
208 должен быть показан, в его заголовке.
|
|
209 Если был использован такой метод, фильм часто будет называться
|
|
210 как "мягкий телесин", т.к. процесс только указывает DVD-плееру
|
|
211 о необходимости применения пулдауна к фильму, не изменяя при этом
|
|
212 сам фильм.
|
|
213 Этот случай существенно предпочтителен, т.к. он может быть легко обращён
|
|
214 (в действительности, проигнорирован) кодером и т.к. он сохраняет
|
|
215 максимальное качество.
|
|
216 Однако, многие широковещательные и DVD студии не используют
|
|
217 надлежащую технологию кодирования и вместо этого производят
|
|
218 фильмы с "жёстким телесином", где поля в действительности
|
|
219 повторяются в кодированном MPEG-2.
|
|
220 </para>
|
|
221 <para>
|
|
222 Порядок действия в таких случаях будет описан
|
|
223 <link linkend="menc-feat-telecine">позже в данном руководстве</link>.
|
|
224 Сейчас мы дадим Вам несколько советов по идентификации типа
|
|
225 материала, с которым Вы работаете:
|
|
226 </para>
|
|
227
|
|
228 <itemizedlist>
|
|
229 <title>Области NTSC:</title>
|
|
230 <listitem><para>
|
|
231 Если при просмотре Вашего фильма <application>MPlayer</application>
|
|
232 выводит, что частота кадров была изменена до 24000/1001 и она
|
|
233 никогда не меняется обратно, то это почти наверняка содержимое
|
|
234 с построчной развёрткой, которое было подвергнуто
|
|
235 "мягкому телесину".
|
|
236 </para></listitem>
|
|
237 <listitem><para>
|
|
238 Если <application>MPlayer</application> отображает попеременные
|
|
239 переключения частоты кадров между 24000/1001 и 30000/1001, и Вы
|
|
240 иногда видите "гребешки", есть несколько возможностей.
|
|
241 Сегменты с 24000/1001 fps почти наверняка являются "мягко
|
|
242 телесиненным" содержимым с построчной развёрткой, но части с
|
|
243 30000/1001 fps могут быть как "жёстко телесиненым" содержимым
|
|
244 с 24000/1001 fps, так и NTSC видео с 60000/1001 полями в секунду.
|
|
245 Испольуйте два нижеследующих руководства для определения того,
|
|
246 с каким случаем вы имеете дело.
|
|
247 </para></listitem>
|
|
248 <listitem><para>
|
|
249 Если <application>MPlayer</application> никогда не показывает
|
|
250 изменения кадровой частоты и каждый отдельный кадр, где есть
|
|
251 движение, оказывается гребёнкой, Ваш фильм есть NTSC видео с
|
|
252 60000/1001 полями в секунду.
|
|
253 </para></listitem>
|
|
254 <listitem><para>
|
|
255 Если <application>MPlayer</application> никогда не показывает
|
|
256 изменения кадровой частоты и два кадра из каждых пяти оказываются
|
|
257 гребёнкой, Ваш фильм представляет собой "жёстко телесиненное"
|
|
258 содержимое с 24000/1001 fps.
|
|
259 </para></listitem>
|
|
260 </itemizedlist>
|
|
261
|
|
262 <itemizedlist>
|
|
263 <title>Области PAL:</title>
|
|
264 <listitem><para>
|
|
265 Если Вы не видите никакой гребёнки, Ваш фильм есть 2:2 пулдаун.
|
|
266 </para></listitem>
|
|
267 <listitem><para>
|
|
268 Если Вы видите попеременную гребёнку каждые полсекунды,
|
|
269 Ваш фильм представляет собой 2:2:2:2:2:2:2:2:2:2:2:3 пулдаун.
|
|
270 </para></listitem>
|
|
271 <listitem><para>
|
|
272 Если Вы всегда видите гребёшки во время движения, значит Ваш
|
|
273 фильм является PAL видео с 50 полями в секунду.
|
|
274 </para></listitem>
|
|
275 </itemizedlist>
|
|
276
|
|
277 <note><title>Подсказка:</title>
|
|
278 <para>
|
|
279 <application>MPlayer</application> может замедлить воспроизведение
|
|
280 фильма с опцией -speed или воспроизводить его покадрово.
|
|
281 Попробуйте использовать опцию <option>-speed 0.2</option> для
|
|
282 очень медленного просмотра фильма или несколько раз нажмите
|
|
283 клавишу "<keycap>.</keycap>" для воспроизведения одного кадра
|
|
284 за раз и идетнифицируйте образец, если не можете его увидеть на
|
|
285 полной скорости.
|
|
286 </para>
|
|
287 </note>
|
|
288 </sect3>
|
|
289 </sect2>
|
|
290
|
|
291 <sect2 id="menc-feat-dvd-mpeg4-2pass">
|
|
292 <title>Постоянный квантователь против многопроходности</title>
|
|
293
|
|
294 <para>
|
|
295 Возможно кодировать Ваш фильм, широко варьируя качество.
|
|
296 С современными видеокодерами и небольшим сжатием перед кодированием
|
|
297 (уменьшением размера и шумов) возможно достичь очень хорошего
|
|
298 качества при размере 700 МБ для 90-110-минутного широкоэкранного фильма.
|
|
299 Более того, всё, кроме самых длинных фильмов, может быть кодировано
|
|
300 с почти безупречным качеством на 1400 МБ.
|
|
301 </para>
|
|
302
|
|
303 <para>
|
|
304 Есть три подхода при кодировании видео: постоянный битпоток (CBR),
|
|
305 постоянный квантователь и многопроходность (ABR или усреднённый битпоток).
|
|
306 </para>
|
|
307
|
|
308 <para>
|
|
309 Сложность кадров фильма и, таким образом, число битов, нужных для их
|
|
310 сжатия может существенно отличаться от одной сцены к другой.
|
|
311 Современные видеокодеры могут подстраиваться под это в процессе
|
|
312 работы и варьировать битпоток.
|
|
313 Однако, в таких простых режимах как CBR кодеры не знают загруженность
|
|
314 битпотока в последующих сценах и т.о. не могут превысить затребованный
|
|
315 битпоток для больших промежутков времени.
|
|
316 Более продвинутые режимы, такие как многопроходный режим, могут
|
|
317 учитывать статистику предыдущих проходов; это решает проблему,
|
|
318 упомянутую выше.
|
|
319 </para>
|
|
320
|
|
321 <note><title>Замечание:</title>
|
|
322 <para>
|
|
323 Большинство кодеков, поддерживающих ABR кодирование, поддерживают
|
|
324 только двупроходный режим, в то время как некоторые другие, такие
|
|
325 как <systemitem class="library">x264</systemitem>,
|
|
326 <systemitem class="library">XviD</systemitem>
|
|
327 и <systemitem class="library">libavcodec</systemitem> поддерживают
|
|
328 многопроходность, несколько улучшающую качество на каждом проходе,
|
|
329 однако, это улучшение не измеримо и не заметно после 4-го прохода
|
|
330 или около того.
|
|
331 Поэтому, в данном разделе дву- и многопроходность будут
|
|
332 использоваться взаимозаменяемо.
|
|
333 </para>
|
|
334 </note>
|
|
335
|
|
336 <para>
|
|
337 В каждом из этих режимов видеокодек (такой как
|
|
338 <systemitem class="library">libavcodec</systemitem>)
|
|
339 разбивает видеокадр на макроблоки размером 16х16 пикселей и потом
|
|
340 применяет квантователь к каждому макроблоку. Чем меньше квантоваль,
|
|
341 тем лучше качество и выше битпоток.
|
|
342 Метод, используемый видео кодером для определения того, какой
|
|
343 квантователь использовать для данного макроблока, варьируется и
|
|
344 подлежит тонкой настройке. (Это крайнее упрощение реального
|
|
345 процесса, но основная концепция полезна для понимания.)
|
|
346 </para>
|
|
347
|
|
348 <para>
|
|
349 Когда Вы указываете постоянный битпоток, видеокодек будет кодировать
|
|
350 видео, отбрасывая детали столько, сколько необходимо и настолько мало,
|
|
351 насколько это возможно с целью оставаться ниже заданного битпотока.
|
|
352 Если Вас действительно не волнует размер файла, Вы можете также
|
|
353 использовать CBR и указать бесконечный битпоток. (На практике это
|
|
354 означает значение, достаточно большое для обозначения отсутствия
|
|
355 предела, например, 10000 Кбит.) В результате, без реального ограничения
|
|
356 битпотока, кодек использует наименьший возможный квантователь для
|
|
357 каждого макроблока (как указано опцией
|
|
358 <option>vqmin</option> для
|
|
359 <systemitem class="library">libavcodec</systemitem>, равной 2 по умолчанию).
|
|
360 Как только Вы укажите настолько низкий битпоток, что кодек будет
|
|
361 вынужден использовать более высокий квантователь, Вы почти наверняка
|
|
362 испортите качество Вашего видео.
|
|
363 Чтобы избежать этого, Вам, вероятно, придётся уменьшить размеры
|
|
364 Вашего видео, согласно методу, описанному далее в этом руководстве.
|
|
365 В общих чертах, Вам следует избегать CBR совсем, если Вы заботитесь
|
|
366 о качестве.
|
|
367 </para>
|
|
368
|
|
369 <para>
|
|
370 С постоянным квантователем кодек использует для всех макроблоков
|
|
371 один и тот же квантователь, указанный в опции
|
|
372 <option>vqscale</option> (для
|
|
373 <systemitem class="library">libavcodec</systemitem>).
|
|
374 Если Вы хотите рип наивысшего возможного качества, снова не взирая
|
|
375 на битпоток, Вы можете использовать
|
|
376 <option>vqscale=2</option>.
|
|
377 Это приведёт к тому же битпотоку и PSNR (пику отношения сигнала к шуму),
|
|
378 что и CBR с
|
|
379 <option>vbitrate</option>=бесконечности и значением по умолчанию
|
|
380 <option>vqmin</option>, равным 2.
|
|
381 </para>
|
|
382
|
|
383 <para>
|
|
384 Проблема с постоянным квантованием заключается в том, что кодек использует
|
|
385 заданный квантователь вне зависимости от того, требуется это для
|
|
386 макроблока или нет. То есть возможно использование большего квантователя
|
|
387 для макроблока без ухудшения видимого качества. Зачем тратить биты на
|
|
388 излишне низкий квантователь? У Вашего процессора есть столько тактов,
|
|
389 сколько есть времени, но имеется лишь ограниченное число битов на
|
|
390 жёстком диске.
|
|
391 </para>
|
|
392
|
|
393 <para>
|
|
394 При двупроходном кодировании первый проход создаст рип фильма так,
|
|
395 как будто это был CBR, но сохранит лог свойств для каждого кадра.
|
|
396 Эта информация затем будет использована во время второго прохода
|
|
397 для принятия интеллектуальных решений о том, какой квантователь
|
|
398 следует использовать. Во время быстрого движения или сцен с
|
|
399 высокой детализацией с большой веротностью будут использованы
|
|
400 бОльшие квантователи, а во время медленного движения или сцен
|
|
401 с низкой детализацией — меньшие.
|
|
402 Обычно количество движения играет существенно более важную роль,
|
|
403 чем количество деталей.
|
|
404 </para>
|
|
405
|
|
406 <para>
|
|
407 Если Вы используете <option>vqscale=2</option>, то Вы теряете биты.
|
|
408 Если Вы используете <option>vqscale=3</option>, то Вы не получаете
|
|
409 рип наивысшего качества. Предположим, вы делаете рип DVD, используя
|
|
410 <option>vqscale=3</option>, результат получается 1800 Кбит.
|
|
411 Если Вы сделаете двупроходное кодирование с
|
|
412 <option>vbitrate=1800</option>, получившееся видео быдет обладать
|
|
413 <emphasis role="bold">лучшим качеством</emphasis> для
|
|
414 <emphasis role="bold">того же битпотока</emphasis>.
|
|
415 </para>
|
|
416
|
|
417 <para>
|
|
418 После того, как Вы сейчас убедились, что два прохода — это путь
|
|
419 к действию, возникает вопрос о том, какой битпоток использовать?
|
|
420 Ответ таков, что нет единого ответа. В идеале, Вы хотите выбрать
|
|
421 битпоток, при котором достигается наилучший баланс между качеством
|
|
422 и размером файла. Здесь возможны вариации в зависимости от
|
|
423 исходного видеоматериала.
|
|
424 </para>
|
|
425
|
|
426 <para>
|
|
427 Если размер не важен, хорошей отправной точкой для рипа очень высокого
|
|
428 качества будет 2000 Кбит +/- 200 Кбит.
|
|
429 Для видеоматериала с быстрым движением или высокой детализацией
|
|
430 или просто если у Вас очень разборчивый глаз, Вы можете использовать
|
|
431 2400 или 2600.
|
|
432 Для некоторых DVD Вы не заметите разницы на 1400 Кбит. Хорошей идеей
|
|
433 является экспериментирование со сценами на разных битпотоках, чтобы
|
|
434 почувствовать разницу.
|
|
435 </para>
|
|
436
|
|
437 <para>
|
|
438 Если Вашей целью является определённый размер, Вам нужно как-нибудь
|
|
439 вычислить битпоток. Но перед этим, Вам нужно знать, сколько места
|
|
440 нужно зарезервировать по аудио дорожку(и), так что Вам необходимо
|
|
441 <link linkend="menc-feat-dvd-mpeg4-audio">извлечь их</link> сперва.
|
|
442 Вы можете расчитать битпоток с помощью следующей формулы:
|
|
443 <systemitem>битпоток = (конечный_размер_в_МБайт - размер_звука_в_МБайт) *
|
|
444 1024 * 1024 / длительность_в_секундах * 8 / 1000</systemitem>.
|
|
445 Например, для сжатия двухчасового фильма в 702 МБ CD, с 60 МБ
|
|
446 аудио дорожкой, битпоток видео должен составлять:
|
|
447 <systemitem>(702 - 60) * 1024 * 1024 / (120*60) * 8 / 1000
|
|
448 = 740 кбит/сек</systemitem>.
|
|
449 </para>
|
|
450
|
|
451 </sect2>
|
|
452
|
|
453
|
|
454 <sect2 id="menc-feat-dvd-mpeg4-constraints">
|
|
455 <title>Ограничения для эффективного кодирования</title>
|
|
456
|
|
457 <para>
|
|
458 Из-за особенностей MPEG-подобного сжатия, существуют различные
|
|
459 ограничения, которым Вы должны следовать для достижения
|
|
460 максимального качества.
|
|
461 MPEG разбивает видео на квадраты 16х16, называемые макроблоками.
|
|
462 Каждый макроблок состоит из 4 блоков 8х8 с информацией о люме
|
|
463 (интенсивности) и двух блоков 8х8 с информацией о хроме (цвете)
|
|
464 половинного разрешения (один для красно-бирюзовой оси и другой
|
|
465 для жёлто-голубой оси).
|
|
466 Даже если ширина и высота Вашего фильма не кратны 16, кодер
|
|
467 всё равно использует нужное количество макроблоков 16х16 для покрытия
|
|
468 всей области картинки, дополнительная область будет впустую потрачена.
|
|
469 Так что в интересах максимизации качества при фиксированном размере
|
|
470 файла, не стоит использовать размеры, не кратные 16.
|
|
471 </para>
|
|
472
|
|
473 <para>
|
|
474 У большинства DVD также есть определённое подобие чёрных полос на
|
|
475 краях. Если Вы их оставите, это может повредить качество несколькими
|
|
476 путями.
|
|
477 </para>
|
|
478
|
|
479 <orderedlist>
|
|
480 <listitem>
|
|
481 <para>
|
|
482 MPEG-подобное сжатие также очень чувствительно к преобразованиям
|
|
483 частотных интервалов, в частности, к дискретному косинусному
|
|
484 преобразованию (DCT), которое аналогично преобразованию Фурье.
|
|
485 Этот вид сжатия эффективен для представления образов и сглаженных
|
|
486 переходов, но у него возникают проблемы с острыми краями.
|
|
487 <!-- FIXME: для слова ringing я тоже не нашёл краткого однозначного
|
|
488 перевода; лучшее, что приходит на ум - это "размывание краёв",
|
|
489 ясное дело, что причиной является отбрасывание малых гармоник,
|
|
490 в результате чего вместо точки возникает затухающая окружность,
|
|
491 но вот как это кратко выразить... -->
|
|
492 Для кодирования последних Вам нужно гораздо больше битов, а иначе
|
|
493 у вас появится артефакт, известный как размывание краёв
|
|
494 (англ. ringing).
|
|
495 </para>
|
|
496
|
|
497 <para>
|
|
498 Частотные преобразования (DCT) выполняются независимо для каждого
|
|
499 макроблока (на самом деле, для каждого блока), так что эта проблема
|
|
500 возникает только в случае попадания острого края внутрь блока.
|
|
501 Если Ваши чёрные поля возникают точно на границах, кратных 16
|
|
502 пикселям, это не проблема.
|
|
503 Однако, чёрные полосы на DVD редко хорошо расположены, так что
|
|
504 на практике Вам всегда придётся усекать стороны для избежания
|
|
505 этих проблем.
|
|
506 </para>
|
|
507 </listitem>
|
|
508 </orderedlist>
|
|
509
|
|
510 <para>
|
|
511 В дополнение к преобразованиям частотных интервалов, MPEG-подобное
|
|
512 сжатие использует векторы движения для отображения изменений от
|
|
513 одного кадра к другому. Векторы движения, естественно, работают
|
|
514 существенно менее эффективно для новых объектов, идущих от
|
|
515 краёв картинки, поскольку они отсутсвуют в предыдущих кадрах.
|
|
516 Пока картинка простирается вплоть до края кодируемой области,
|
|
517 у векторов движения не возникает проблем с движением объектов
|
|
518 за пределы картинки. Однако, при наличии черных полей
|
|
519 могут возникнуть проблемы:
|
|
520 </para>
|
|
521
|
|
522 <orderedlist continuation="continues">
|
|
523 <listitem>
|
|
524 <para>
|
|
525 Для каждого макроблока MPEG-подобное сжатие сохраняет вектор,
|
|
526 определяющий какая часть предыдущего кадра должна быть скопирована
|
|
527 в этот макроблок как основа для предсказания следующего кадра.
|
|
528 Кодированию подлежит только оставшаяся разность. Если макроблок
|
|
529 простирается до края картинки и содержит часть чёрной полосы,
|
|
530 то векторы движения других частей каритки перепишут чёрную полосу.
|
|
531 Это означает, что много битов нужно потратить либо на повторное
|
|
532 чернение переписанной полосы, либо (что более вероятно) вектор
|
|
533 движения не будет использован вовсе и все изменения для этого
|
|
534 макроблока будут явно кодированы. Другими словами, эффективность
|
|
535 кодирования существенно уменьшается.
|
|
536 </para>
|
|
537
|
|
538 <para>
|
|
539 Ещё раз, эта проблема возникает только в случае, если чёрные полосы
|
|
540 не укладываются в границы, кратные 16.
|
|
541 </para>
|
|
542 </listitem>
|
|
543
|
|
544 <listitem>
|
|
545 <para>
|
|
546 Наконец, предположим, что у нас есть находящийся внутри картинки
|
|
547 макроблок и объект движется в этот блок от края изображения.
|
|
548 MPEG-подобное кодирование не может сказать "скопируй ту часть,
|
|
549 что внутри картинки, но не чёрную полосу". Так что чёрная полоса
|
|
550 также быдет скопирована внутрь, в результате чего масса битов
|
|
551 будет потрачена на кодирование части изображения, которое должно
|
|
552 быть на месте полосы.
|
|
553 </para>
|
|
554
|
|
555 <para>
|
|
556 Для случаев, когда всё изображение движется к краю кодируемой
|
|
557 области, у MPEG есть специальные оптимизации для многократного
|
|
558 копирования пикселей на край картинки, когда вектор движения
|
|
559 идёт извне области кодирования. Эта возможность становится
|
|
560 бесполезной, если у фильма есть чёрные полосы. В отличии от
|
|
561 случаев 1 и 2, выравнивание границ до кратности 16 здесь
|
|
562 не поможет.
|
|
563 </para>
|
|
564 </listitem>
|
|
565
|
|
566 <listitem>
|
|
567 <para>
|
|
568 Несмотря на то, что границы полностью чёрные и никогда не изменяются,
|
|
569 существуют, как минимум, определённые накладные расходы, связанные
|
|
570 с наличием большего числа макроблоков.
|
|
571 </para>
|
|
572 </listitem>
|
|
573 </orderedlist>
|
|
574
|
|
575 <para>
|
|
576 Благодаря всем этим причинам, рекомендуется полностью урезать
|
|
577 чёрные полосы. Более того, если есть области шумов/искажений
|
|
578 на краях картинки, то их урезание также поспособствует улучшению
|
|
579 качества кодирования. Видеофилы, желающие сохранить оригинал как
|
|
580 можно более точно, могут возражать против такого усечения; но
|
|
581 если Вы не планируете кодировать при постоянном квантователе,
|
|
582 качество, полученное при усечении, существенно превысит потери
|
|
583 информации на краях.
|
|
584 </para>
|
|
585 </sect2>
|
|
586
|
|
587
|
|
588 <sect2 id="menc-feat-dvd-mpeg4-crop">
|
|
589 <title>Усечение и масштабирование</title>
|
|
590
|
|
591 <para>
|
|
592 Вспомните из предыдущего раздела, что конечный размер картинки,
|
|
593 подлежащей кодированию, должен быть кратен 16 (как высота,так
|
|
594 и ширина). Это может быть достигнуто усечением, масштабированием
|
|
595 или комбинацией того и другого.
|
|
596 </para>
|
|
597
|
|
598 <para>
|
|
599 Есть несколько рекомендаций для усечения, которым необходимо следовать
|
|
600 для избежания повреждения фильма.
|
|
601 Обычный формат YUV, 4:2:0, сохраняет хрому (информацию о цвете)
|
|
602 половинной дискретизации, т.е. хрома сохраняется в два раза реже
|
|
603 в каждом направлении, чем люма (информация об интенсивности).
|
|
604 Рассмотрите следующую диаграмму, где L обозначает точки дискретизации
|
|
605 люмы и C — хромы.
|
|
606 </para>
|
|
607
|
|
608 <informaltable>
|
|
609 <?dbhtml table-width="40%" ?>
|
|
610 <?dbfo table-width="40%" ?>
|
|
611 <tgroup cols="8" align="center">
|
|
612 <colspec colnum="1" colname="col1"/>
|
|
613 <colspec colnum="2" colname="col2"/>
|
|
614 <colspec colnum="3" colname="col3"/>
|
|
615 <colspec colnum="4" colname="col4"/>
|
|
616 <colspec colnum="5" colname="col5"/>
|
|
617 <colspec colnum="6" colname="col6"/>
|
|
618 <colspec colnum="7" colname="col7"/>
|
|
619 <colspec colnum="8" colname="col8"/>
|
|
620 <spanspec spanname="spa1-2" namest="col1" nameend="col2"/>
|
|
621 <spanspec spanname="spa3-4" namest="col3" nameend="col4"/>
|
|
622 <spanspec spanname="spa5-6" namest="col5" nameend="col6"/>
|
|
623 <spanspec spanname="spa7-8" namest="col7" nameend="col8"/>
|
|
624 <tbody>
|
|
625 <row>
|
|
626 <entry>L</entry>
|
|
627 <entry>L</entry>
|
|
628 <entry>L</entry>
|
|
629 <entry>L</entry>
|
|
630 <entry>L</entry>
|
|
631 <entry>L</entry>
|
|
632 <entry>L</entry>
|
|
633 <entry>L</entry>
|
|
634 </row>
|
|
635 <row>
|
|
636 <entry spanname="spa1-2">C</entry>
|
|
637 <entry spanname="spa3-4">C</entry>
|
|
638 <entry spanname="spa5-6">C</entry>
|
|
639 <entry spanname="spa7-8">C</entry>
|
|
640 </row>
|
|
641 <row>
|
|
642 <entry>L</entry>
|
|
643 <entry>L</entry>
|
|
644 <entry>L</entry>
|
|
645 <entry>L</entry>
|
|
646 <entry>L</entry>
|
|
647 <entry>L</entry>
|
|
648 <entry>L</entry>
|
|
649 <entry>L</entry>
|
|
650 </row>
|
|
651 <row>
|
|
652 <entry>L</entry>
|
|
653 <entry>L</entry>
|
|
654 <entry>L</entry>
|
|
655 <entry>L</entry>
|
|
656 <entry>L</entry>
|
|
657 <entry>L</entry>
|
|
658 <entry>L</entry>
|
|
659 <entry>L</entry>
|
|
660 </row>
|
|
661 <row>
|
|
662 <entry spanname="spa1-2">C</entry>
|
|
663 <entry spanname="spa3-4">C</entry>
|
|
664 <entry spanname="spa5-6">C</entry>
|
|
665 <entry spanname="spa7-8">C</entry>
|
|
666 </row>
|
|
667 <row>
|
|
668 <entry>L</entry>
|
|
669 <entry>L</entry>
|
|
670 <entry>L</entry>
|
|
671 <entry>L</entry>
|
|
672 <entry>L</entry>
|
|
673 <entry>L</entry>
|
|
674 <entry>L</entry>
|
|
675 <entry>L</entry>
|
|
676 </row>
|
|
677 </tbody>
|
|
678 </tgroup>
|
|
679 </informaltable>
|
|
680
|
|
681 <para>
|
|
682 Как Вы видите, строки и столбцы изображения естественным образом
|
|
683 идут в парах. Поэтому смещения и размеры усечения
|
|
684 <emphasis>должны</emphasis> быть чётными числами.
|
|
685 Иначе хрома перестанет правильно соответствовать люме.
|
|
686 Теоретически возможно усечение с нечётными смещениями, но оно
|
|
687 потребует преобразования хромы, что потенциально является
|
|
688 операцией с потерей качества и не поддерживается фильтром
|
|
689 усечения сторон crop.
|
|
690 </para>
|
|
691
|
|
692 <para>
|
|
693 Далее, видео с чересстрочной развёрткой дискретизируется следующим
|
|
694 образом:
|
|
695 </para>
|
|
696
|
|
697 <informaltable>
|
|
698 <?dbhtml table-width="80%" ?>
|
|
699 <?dbfo table-width="80%" ?>
|
|
700 <tgroup cols="16" align="center">
|
|
701 <colspec colnum="1" colname="col1"/>
|
|
702 <colspec colnum="2" colname="col2"/>
|
|
703 <colspec colnum="3" colname="col3"/>
|
|
704 <colspec colnum="4" colname="col4"/>
|
|
705 <colspec colnum="5" colname="col5"/>
|
|
706 <colspec colnum="6" colname="col6"/>
|
|
707 <colspec colnum="7" colname="col7"/>
|
|
708 <colspec colnum="8" colname="col8"/>
|
|
709 <colspec colnum="9" colname="col9"/>
|
|
710 <colspec colnum="10" colname="col10"/>
|
|
711 <colspec colnum="11" colname="col11"/>
|
|
712 <colspec colnum="12" colname="col12"/>
|
|
713 <colspec colnum="13" colname="col13"/>
|
|
714 <colspec colnum="14" colname="col14"/>
|
|
715 <colspec colnum="15" colname="col15"/>
|
|
716 <colspec colnum="16" colname="col16"/>
|
|
717 <spanspec spanname="spa1-2" namest="col1" nameend="col2"/>
|
|
718 <spanspec spanname="spa3-4" namest="col3" nameend="col4"/>
|
|
719 <spanspec spanname="spa5-6" namest="col5" nameend="col6"/>
|
|
720 <spanspec spanname="spa7-8" namest="col7" nameend="col8"/>
|
|
721 <spanspec spanname="spa9-10" namest="col9" nameend="col10"/>
|
|
722 <spanspec spanname="spa11-12" namest="col11" nameend="col12"/>
|
|
723 <spanspec spanname="spa13-14" namest="col13" nameend="col14"/>
|
|
724 <spanspec spanname="spa15-16" namest="col15" nameend="col16"/>
|
|
725 <tbody>
|
|
726 <row>
|
|
727 <entry namest="col1" nameend="col8">Верхнее поле</entry>
|
|
728 <entry namest="col9" nameend="col16">Нижнее поле</entry>
|
|
729 </row>
|
|
730 <row>
|
|
731 <entry>L</entry>
|
|
732 <entry>L</entry>
|
|
733 <entry>L</entry>
|
|
734 <entry>L</entry>
|
|
735 <entry>L</entry>
|
|
736 <entry>L</entry>
|
|
737 <entry>L</entry>
|
|
738 <entry>L</entry>
|
|
739 <entry></entry>
|
|
740 <entry></entry>
|
|
741 <entry></entry>
|
|
742 <entry></entry>
|
|
743 <entry></entry>
|
|
744 <entry></entry>
|
|
745 <entry></entry>
|
|
746 <entry></entry>
|
|
747 </row>
|
|
748 <row>
|
|
749 <entry spanname="spa1-2">C</entry>
|
|
750 <entry spanname="spa3-4">C</entry>
|
|
751 <entry spanname="spa5-6">C</entry>
|
|
752 <entry spanname="spa7-8">C</entry>
|
|
753 <entry></entry>
|
|
754 <entry></entry>
|
|
755 <entry></entry>
|
|
756 <entry></entry>
|
|
757 <entry></entry>
|
|
758 <entry></entry>
|
|
759 <entry></entry>
|
|
760 <entry></entry>
|
|
761 </row>
|
|
762 <row>
|
|
763 <entry></entry>
|
|
764 <entry></entry>
|
|
765 <entry></entry>
|
|
766 <entry></entry>
|
|
767 <entry></entry>
|
|
768 <entry></entry>
|
|
769 <entry></entry>
|
|
770 <entry></entry>
|
|
771 <entry>L</entry>
|
|
772 <entry>L</entry>
|
|
773 <entry>L</entry>
|
|
774 <entry>L</entry>
|
|
775 <entry>L</entry>
|
|
776 <entry>L</entry>
|
|
777 <entry>L</entry>
|
|
778 <entry>L</entry>
|
|
779 </row>
|
|
780 <row>
|
|
781 <entry>L</entry>
|
|
782 <entry>L</entry>
|
|
783 <entry>L</entry>
|
|
784 <entry>L</entry>
|
|
785 <entry>L</entry>
|
|
786 <entry>L</entry>
|
|
787 <entry>L</entry>
|
|
788 <entry>L</entry>
|
|
789 <entry></entry>
|
|
790 <entry></entry>
|
|
791 <entry></entry>
|
|
792 <entry></entry>
|
|
793 <entry></entry>
|
|
794 <entry></entry>
|
|
795 <entry></entry>
|
|
796 <entry></entry>
|
|
797 </row>
|
|
798 <row>
|
|
799 <entry></entry>
|
|
800 <entry></entry>
|
|
801 <entry></entry>
|
|
802 <entry></entry>
|
|
803 <entry></entry>
|
|
804 <entry></entry>
|
|
805 <entry></entry>
|
|
806 <entry></entry>
|
|
807 <entry spanname="spa9-10">C</entry>
|
|
808 <entry spanname="spa11-12">C</entry>
|
|
809 <entry spanname="spa13-14">C</entry>
|
|
810 <entry spanname="spa15-16">C</entry>
|
|
811 </row>
|
|
812 <row>
|
|
813 <entry></entry>
|
|
814 <entry></entry>
|
|
815 <entry></entry>
|
|
816 <entry></entry>
|
|
817 <entry></entry>
|
|
818 <entry></entry>
|
|
819 <entry></entry>
|
|
820 <entry></entry>
|
|
821 <entry>L</entry>
|
|
822 <entry>L</entry>
|
|
823 <entry>L</entry>
|
|
824 <entry>L</entry>
|
|
825 <entry>L</entry>
|
|
826 <entry>L</entry>
|
|
827 <entry>L</entry>
|
|
828 <entry>L</entry>
|
|
829 </row>
|
|
830 <row>
|
|
831 <entry>L</entry>
|
|
832 <entry>L</entry>
|
|
833 <entry>L</entry>
|
|
834 <entry>L</entry>
|
|
835 <entry>L</entry>
|
|
836 <entry>L</entry>
|
|
837 <entry>L</entry>
|
|
838 <entry>L</entry>
|
|
839 <entry></entry>
|
|
840 <entry></entry>
|
|
841 <entry></entry>
|
|
842 <entry></entry>
|
|
843 <entry></entry>
|
|
844 <entry></entry>
|
|
845 <entry></entry>
|
|
846 <entry></entry>
|
|
847 </row>
|
|
848 <row>
|
|
849 <entry spanname="spa1-2">C</entry>
|
|
850 <entry spanname="spa3-4">C</entry>
|
|
851 <entry spanname="spa5-6">C</entry>
|
|
852 <entry spanname="spa7-8">C</entry>
|
|
853 <entry></entry>
|
|
854 <entry></entry>
|
|
855 <entry></entry>
|
|
856 <entry></entry>
|
|
857 <entry></entry>
|
|
858 <entry></entry>
|
|
859 <entry></entry>
|
|
860 <entry></entry>
|
|
861 </row>
|
|
862 <row>
|
|
863 <entry></entry>
|
|
864 <entry></entry>
|
|
865 <entry></entry>
|
|
866 <entry></entry>
|
|
867 <entry></entry>
|
|
868 <entry></entry>
|
|
869 <entry></entry>
|
|
870 <entry></entry>
|
|
871 <entry>L</entry>
|
|
872 <entry>L</entry>
|
|
873 <entry>L</entry>
|
|
874 <entry>L</entry>
|
|
875 <entry>L</entry>
|
|
876 <entry>L</entry>
|
|
877 <entry>L</entry>
|
|
878 <entry>L</entry>
|
|
879 </row>
|
|
880 <row>
|
|
881 <entry>L</entry>
|
|
882 <entry>L</entry>
|
|
883 <entry>L</entry>
|
|
884 <entry>L</entry>
|
|
885 <entry>L</entry>
|
|
886 <entry>L</entry>
|
|
887 <entry>L</entry>
|
|
888 <entry>L</entry>
|
|
889 <entry></entry>
|
|
890 <entry></entry>
|
|
891 <entry></entry>
|
|
892 <entry></entry>
|
|
893 <entry></entry>
|
|
894 <entry></entry>
|
|
895 <entry></entry>
|
|
896 <entry></entry>
|
|
897 </row>
|
|
898 <row>
|
|
899 <entry></entry>
|
|
900 <entry></entry>
|
|
901 <entry></entry>
|
|
902 <entry></entry>
|
|
903 <entry></entry>
|
|
904 <entry></entry>
|
|
905 <entry></entry>
|
|
906 <entry></entry>
|
|
907 <entry spanname="spa9-10">C</entry>
|
|
908 <entry spanname="spa11-12">C</entry>
|
|
909 <entry spanname="spa13-14">C</entry>
|
|
910 <entry spanname="spa15-16">C</entry>
|
|
911 </row>
|
|
912 <row>
|
|
913 <entry></entry>
|
|
914 <entry></entry>
|
|
915 <entry></entry>
|
|
916 <entry></entry>
|
|
917 <entry></entry>
|
|
918 <entry></entry>
|
|
919 <entry></entry>
|
|
920 <entry></entry>
|
|
921 <entry>L</entry>
|
|
922 <entry>L</entry>
|
|
923 <entry>L</entry>
|
|
924 <entry>L</entry>
|
|
925 <entry>L</entry>
|
|
926 <entry>L</entry>
|
|
927 <entry>L</entry>
|
|
928 <entry>L</entry>
|
|
929 </row>
|
|
930 </tbody>
|
|
931 </tgroup>
|
|
932 </informaltable>
|
|
933
|
|
934 <para>
|
|
935 Как Вы видите, структура повторяется только после 4 строк.
|
|
936 Так что для чересстрочного видео Ваше y-смещение и высота
|
|
937 усечения должны быть кратны 4.
|
|
938 </para>
|
|
939
|
|
940 <para>
|
|
941 Естественные разрешения DVD составляют 720x480 для NTSC и 720x576
|
|
942 для PAL, но существует флаг соотношения сторон, который указывает
|
|
943 является ли видео полноэкранным (4:3) или широкоэкранным (16:9).
|
|
944 Многие (если не большинство) широкоэкранных DVD не точно соответсвуют
|
|
945 <!-- FIXME: Есть ли перевод названия формата cinescope (он же CinemaScope) ?? -->
|
|
946 формату 16:9 и он может быть как 1.85:1, так и 2.35:1 (формат cinescope).
|
|
947 Это означает, что в видео будут чёрные полосы, которые нужно усечь.
|
|
948 </para>
|
|
949
|
|
950 <para>
|
|
951 <application>MPlayer</application> предоставляет фильтр обнаружения
|
|
952 усечения, который определяет прямоугольник, до которго нужно усечь
|
|
953 (<option>-vf cropdetect</option>).
|
|
954 Запустите <application>MPlayer</application> с
|
|
955 <option>-vf cropdetect</option> и он выдаст настройки
|
|
956 усечения для удаления полей.
|
|
957 С целью получения точных параметров усечения, Вы должны проигрывать
|
|
958 фильм достаточно долго для того, чтоб была использована вся область
|
|
959 изображения.
|
|
960 </para>
|
|
961
|
|
962 <para>
|
|
963 Затем проверьте значения, полученные с помощью
|
|
964 <application>MPlayer</application>, используя командную строку,
|
|
965 выведенную <option>cropdetect</option>, и подстройте прямоугольник
|
|
966 при необходимости.
|
|
967 Фильтр <option>rectangle</option> может быть полезен, позволив
|
|
968 Вам интерактивно менять прямоугольник усечения для Вашего фильма.
|
|
969 Не забывайте следовать указанным выше руководствам по делимости,
|
|
970 чтобы не испортить выравнивание хромы.
|
|
971 </para>
|
|
972
|
|
973 <para>
|
|
974 В ряде случаев масштабирование может быть нежелательным.
|
|
975 Масштабирование по вертикальному направлению затруднено для
|
|
976 чересстрочного видео, и если Вы хотите сохранить чересстрочность,
|
|
977 Вам в большинстве случаев будет необходимо воздерживаться от
|
|
978 масштабирования.
|
|
979 Если Вы не будете масштабировать, но всё ещё желаете размеры,
|
|
980 кратные 16, то Вам придётся проводить излишнее усечение.
|
|
981 Не проводите неполное усечение, поскольку чёрные полосы очень
|
|
982 плохи для кодирования!
|
|
983 </para>
|
|
984
|
|
985 <para>
|
|
986 Посокльку MPEG-4 использует макроблоки 16х16, Вы должны убедиться,
|
|
987 что каждое измерение кодируемого видео кратно 16; иначе Вы ухудшите
|
|
988 качество, особенно на малых битпотоках. Вы можете сделать это,
|
|
989 округлив ширину и высоту прямоугольника усечения до ближайшего
|
|
990 меньшего целого, кратного 16.
|
|
991 Учитывая установленное ранее, при усечении Вы можете захотеть увеличить
|
|
992 смещение по Y на половину разности старой и новой высоты, так что
|
|
993 полученное видео будет браться из центра кадра.
|
|
994
|
|
995 И из-за способа дискретизации DVD видео, убедитесь, что смещение
|
|
996 есть чётное число. (Фактически, возьмите за правило никогда не
|
|
997 использовать нечётные величины для любых параметров усечения или
|
|
998 масштабирования видео.) Если Вы беспокоитесь из-за нескольких
|
|
999 излишне отброшенных битов, возможно, Вы предпочтёте взамен
|
|
1000 масштабировать видео.
|
|
1001 В действительности, Вы можете доверить фильтру
|
|
1002 <option>cropdetect</option> сделать для Вас всё вышеупомянутое,
|
|
1003 т.к. у него есть необязательный параметр округления
|
|
1004 <option>round</option>, равный 16 по умолчанию.
|
|
1005 </para>
|
|
1006
|
|
1007 <para>
|
|
1008 Также будьте осторожны с "полутёмными" пикселями на краях. Убедитесь,
|
|
1009 что они тоже отрезаются, иначе Вы будете тратить биты, которым есть
|
|
1010 лучшее применение.
|
|
1011 </para>
|
|
1012
|
|
1013 <para>
|
|
1014 После всего выше сказанного и сделанного, Вы, вероятно, получите
|
|
1015 видео не точно формата 1:85.1 или 2.35:1, а с чем-то близким
|
|
1016 к этому. Вы можете вычислить новый коэффициент соотношения
|
|
1017 сторон вручную, но <application>MEncoder</application>
|
|
1018 предоставляет опцию для <systemitem class="library">libavcodec</systemitem>,
|
|
1019 называемую <option>autoaspect</option>, которая сделает это для
|
|
1020 Вас. Ни в коем случае не увеличивайте размер этого видео с целью
|
|
1021 квадратизации пикселей, если Вы не желаете впустую потратить
|
|
1022 место на жёстком диске.
|
|
1023 Масштабирование должно выполняться при воспроизведении, и плеер
|
|
1024 использует коэффициент соотношения сторон, сохранённый в AVI, для
|
|
1025 определения правильного разрешения.
|
|
1026 К сожалению, не все плееры используют эту информацию автомасштабирования,
|
|
1027 поэтому Вам всё ещё может быть необходимо перемасштабирование.
|
|
1028 </para>
|
|
1029 </sect2>
|
|
1030
|
|
1031
|
|
1032 <sect2 id="menc-feat-dvd-mpeg4-resolution-bitrate">
|
|
1033 <title>Выбор разрешения и битпотока</title>
|
|
1034
|
|
1035 <para>
|
|
1036 Если Вы не собираетеся кодировать в режиме постоянного квантователя,
|
|
1037 Вам нужно выбрать битпоток.
|
|
1038 Понятие битпотока очень просто: это среднее число битов, которые
|
|
1039 будут использованы для сохранения Вашего фильма, в секунду.
|
|
1040 Обычно битпоток измеряется в килобитах (1000 бит) в секунду.
|
|
1041 Размер Вашего фильма на диске есть битпоток, умноженный на
|
|
1042 длительность фильма, плюс небольшие накладные расходы
|
|
1043 (см. раздел
|
|
1044 <link linkend="menc-feat-dvd-mpeg4-muxing-avi-limitations">контейнер AVI</link>
|
|
1045 для примера).
|
|
1046 Остальные параметры, такие как масштабирование, усечение и т.п.
|
|
1047 <emphasis role="bold">не</emphasis> изменят размер файла, пока
|
|
1048 Вы также не измените битпоток!
|
|
1049 </para>
|
|
1050 <para>
|
|
1051 Битпоток изменяется <emphasis role="bold">не</emphasis>
|
|
1052 пропорционально разрешению.
|
|
1053 То есть файл разрешением 320х240 с 200 кбит/сек не будет
|
|
1054 того же качества, что этот же фильм разрешением 640х480
|
|
1055 и 800 кбит/сек!
|
|
1056 Для этого есть две причины:
|
|
1057 <orderedlist>
|
|
1058 <listitem><para>
|
|
1059 <emphasis role="bold">Восприятие</emphasis>: Вы сильнее
|
|
1060 замечаете MPEG артефакты, если они больше!
|
|
1061 Артефакты возникают на масштабе блоков (8х8).
|
|
1062 Ваш глаз не увидит ошибки в 4800 маленьких блоков так же
|
|
1063 легко, как и в 1200 больших блоков (предполагая
|
|
1064 масштабирование обоих фильмов на полный экран).
|
|
1065 </para></listitem>
|
|
1066 <listitem><para>
|
|
1067 <emphasis role="bold">Теоретическая</emphasis>: Когда Вы
|
|
1068 уменьшаете размер изображения, но продолжаете использовать
|
|
1069 блоки того же размера (8х8) для пространственных частотных
|
|
1070 преобразований, Вы перемещаете больше данных в высокочастотные
|
|
1071 полосы. Грубо говоря, каждый пиксель содержит больше деталей,
|
|
1072 чем раньше.
|
|
1073 Так что несмотря на то, что ваша картинка с уменьшенным
|
|
1074 масштабом содержит 1/4 информации в пространственных направлениях,
|
|
1075 она всё ещё может содержать большУю часть информации в
|
|
1076 частотных интервалах (предполагая, что высокие частоты были
|
|
1077 не использованы в оригинальном 640х480 изображении).
|
|
1078 </para></listitem>
|
|
1079 </orderedlist>
|
|
1080 </para>
|
|
1081 <para>
|
|
1082 Последние руководства рекомендовали выбор битпотока и разрешения,
|
|
1083 основываясь на приближении "бит на пиксель", но это обычно не
|
|
1084 верно из-за упомянутых выше причин.
|
|
1085 Похоже, лучшей оценкой является рост битпотока пропорционально
|
|
1086 квадратному корню разрешения, так что 320х240 и 400 кбит/сек
|
|
1087 должно быть сравнимо с 640х480 и 800 кбит/сек.
|
|
1088 Однако, это не было строго проверено теоретически или эмпирически.
|
|
1089 Кроме того, из-за существенного отличия фильмов по уровню шума,
|
|
1090 деталей, степеней свободы и т.п., тщетно давать общие рекомендации
|
|
1091 для "битов на длину диагонали" (аналог битов на пиксель, используя
|
|
1092 квадратный корень).
|
|
1093 </para>
|
|
1094 <para>
|
|
1095 Таким образом, мы обсудили сложность выбора битпотока и разрешения.
|
|
1096 </para>
|
|
1097
|
|
1098
|
|
1099 <sect3 id="menc-feat-dvd-mpeg4-resolution-bitrate-compute">
|
|
1100 <title>Расчёт разрешения</title>
|
|
1101 <para>
|
|
1102 Следующие шаги помогут Вам расчитать разрешение для Вашего
|
|
1103 кодирования без слишком сильного искажения видео, учитывая
|
|
1104 некоторую информацию об исходном видео.
|
|
1105 Прежде всего, Вам необходимо расчитать коэффициент соотношения
|
|
1106 сторон для кодированного видео:
|
|
1107 <systemitem>ARc = (Wc x (ARa / PRdvd )) / Hc</systemitem>
|
|
1108 <itemizedlist>
|
|
1109 <title>где:</title>
|
|
1110 <listitem><para>
|
|
1111 Wc и Hc — ширина и высота усечённого видео,
|
|
1112 </para></listitem>
|
|
1113 <listitem><para>
|
|
1114 ARa — коэффициент соотношения сторон изображения, обычно 4/3 или 16/9,
|
|
1115 </para></listitem>
|
|
1116 <listitem><para>
|
|
1117 PRdvd — отношение пикселей DVD, что равно 1.25=(720/576) для PAL
|
|
1118 DVD и 1.5=(720/480) для NTSC DVD.
|
|
1119 </para></listitem>
|
|
1120 </itemizedlist>
|
|
1121 </para>
|
|
1122
|
|
1123 <para>
|
|
1124 Затем Вы можете расчитать разрешение по X и Y, согласно определённому
|
|
1125 фактору качества сжатия (CQ):
|
|
1126 <systemitem>ResY = INT(SQRT( 1000*Битпоток/25/ARc/CQ )/16) * 16</systemitem>
|
|
1127 и <systemitem>ResX = INT( ResY * ARc / 16) * 16</systemitem>.
|
|
1128 </para>
|
|
1129
|
|
1130 <para>
|
|
1131 Хорошо, но что такое CQ?
|
|
1132 CQ соответсвует числу битов на пиксель и на кадр для кодирования.
|
|
1133 Грубо говоря, чем больше CQ, тем меньше вероятность увидеть
|
|
1134 артефакты кодирования.
|
|
1135 Однако, если у Вас есть заданный размер для Вашего фильма
|
|
1136 (например, 1 или 2 CD), есть ограниченное общее число битов,
|
|
1137 которые Вы можете потратить; поэтому важно найти хороший
|
|
1138 компромисс между сжимаемостью и качеством.
|
|
1139 </para>
|
|
1140
|
|
1141 <para>
|
|
1142 CQ зависит от битпотока, эффективности видеокодека и разрешения фильма.
|
|
1143 Обычно, в целях увеличеиня CQ, Вам нужно будет уменьшить размер
|
|
1144 фильма при постоянном битпотоке, заданном размере и длине фильма.
|
|
1145 С MPEG-4 ASP кодеками, такими как <systemitem class="library">XviD</systemitem>
|
|
1146 и <systemitem class="library">libavcodec</systemitem>, CQ
|
|
1147 меньше 0.18 обычно приводит к изображению с большим числом
|
|
1148 сегментов "квадратиками", из-за недостаточного числа битов для
|
|
1149 кодирования информации в каждом макроблоке.
|
|
1150 (MPEG4, как и многие другие кодеки, группирует пиксели в блоки по
|
|
1151 несколько пикселей для сжатия изображения; если битов не хватает,
|
|
1152 границы этих блоков становятся заметными.)
|
|
1153 Следовательно, благоразумно выбрать CQ в диапазоне от 0.20 до 0.22
|
|
1154 для рипа на 1 CD и 0.26-0.28 для рипа на 2 CD при использовании
|
|
1155 стандартных опций кодирования.
|
|
1156 Более продвинутые опции кодирования, такие как указанные для
|
|
1157 <link linkend="menc-feat-mpeg4-lavc-example-settings"><systemitem class="library">libavcodec</systemitem></link>
|
|
1158 и
|
|
1159 <link linkend="menc-feat-xvid-example-settings"><systemitem class="library">XviD</systemitem></link>
|
|
1160 должны сделать возможным получение того же качества с CQ в диапазоне
|
|
1161 от 0.18 до 0.20 для рипа на 1 CD и 0.24-0.26 для рипа на 2 CD.
|
|
1162 Используя MPEG-4 ASP кодеки, такие как
|
|
1163 <systemitem class="library">x264</systemitem>, Вы можете использовать
|
|
1164 CQ в диапазоне от 0.14 до 0.16 со стандартными опциями кодирования
|
|
1165 и должны суметь достичь таких низких значений, как 0.10-0.12
|
|
1166 с помощью
|
|
1167 <link linkend="menc-feat-x264-example-settings">продвинутых опций кодирования <systemitem class="library">x264</systemitem></link>.
|
|
1168 </para>
|
|
1169
|
|
1170 <para>
|
|
1171 Пожалуйста, обратите внимание, что CQ — лишь показательная величина,
|
|
1172 т.к. она зависит от кодируемого содержимого; CQ 0.18 может хорошо
|
|
1173 смотреться для Бергмана (Bergman), в отличии от такого фильма как
|
|
1174 Матрица (The Matrix), содержащего много сцен с быстрым движением.
|
|
1175 С другой стороны, бесполезно увеличивать CQ выше 0.30, т.к. Вы
|
|
1176 будете тратить биты без заметного увеличения качества.
|
|
1177 Так же обратите внимание, что, как было указано выше в данном
|
|
1178 руководстве, фильмам с низким разрешением (например, по сравнению с DVD)
|
|
1179 необходим более высокий CQ для того, чтоб они выглядели хорошо.
|
|
1180 </para>
|
|
1181 </sect3>
|
|
1182
|
|
1183 </sect2>
|
|
1184
|
|
1185 <sect2 id="menc-feat-dvd-mpeg4-filtering">
|
|
1186 <title>Фильтрация</title>
|
|
1187
|
|
1188 <para>
|
|
1189 Изучение использования видео фильтров <application>MEncoder</application>
|
|
1190 важно для получения хороших результатов кодирования.
|
|
1191 Вся обработка видео выполняется посредством фильтров: усечение,
|
|
1192 масштабирование, подстройка цвета, удаление шума, увеличение
|
|
1193 чёткости, деинтерлейс (преобразование видео из чересстрочной
|
|
1194 развёртки в построчную), телесин, обратный телесин и удаление
|
|
1195 блочной сегментации — и это лишь некоторые из них.
|
|
1196 Вместе с огромным количеством поддерживаемых входных форматов,
|
|
1197 разнообразие фильтров, доступных в <application>MEncoder</application>,
|
|
1198 является одним из его основных достоинств над другими аналогичными
|
|
1199 программами.
|
|
1200 </para>
|
|
1201
|
|
1202 <para>
|
|
1203 Фильтры загружаются в цепочки с помощью опции -vf:
|
|
1204
|
|
1205 <screen>-vf фильтр1=опции,фильтр2=опции,...</screen>
|
|
1206
|
|
1207 Большинство фильтров используют численные значения опций,
|
|
1208 разделённые двоеточиями, но синтаксис этих параметров различается
|
|
1209 у разных фильтров, так что читайте мануал для детальной
|
|
1210 информации о фильтрах, которые Вы желаете использовать.
|
|
1211 </para>
|
|
1212
|
|
1213 <para>
|
|
1214 Фильтры действуют на видео в порядке их загрузки.
|
|
1215 Например, следующая цепочка:
|
|
1216
|
|
1217 <screen>-vf crop=688:464:12:4,scale=640:464</screen>
|
|
1218
|
|
1219 сперва усечёт область изображения до 688х464 с верхним левым
|
|
1220 углом (12,4), а затем масштабирует результат до 640х464.
|
|
1221 </para>
|
|
1222
|
|
1223 <para>
|
|
1224 Некоторые фильтры нужно загружать в начале цепочки фильтров (или
|
|
1225 рядом с ним) с целью получения преимущества от использования
|
|
1226 информации после видеодекодера, которая будет потеряна или
|
|
1227 искажена другими фильтрами.
|
|
1228 Важнейшими примерами являются: <option>pp</option> (постобработка,
|
|
1229 только при выполнении операций удаления блочной сегментации
|
|
1230 (deblocking) или увеличения чёткости краёв (deringing)),
|
|
1231 <option>spp</option> (другой фильтр постобработки, служащий для
|
|
1232 удаления артефактов MPEG), <option>pullup</option> (обратный
|
|
1233 телесин), и <option>softpulldown</option> (для преобразования
|
|
1234 мягкого телесина в жёсткий).
|
|
1235 </para>
|
|
1236
|
|
1237 <para>
|
|
1238 В общем случае, Вам следует делать настолько мало фильтрации,
|
|
1239 насколько это возможно, для того чтоб остаться близко к оригинальному
|
|
1240 DVD источнику. Усечение часто необходимо (как описано выше), но
|
|
1241 избегайте масштабирования видео. Несмотря на то, что уменьшение
|
|
1242 размера иногда предпочтительно при использовании больших
|
|
1243 квантователей, нужно избегать и того, и другого: помните,
|
|
1244 что мы с самого начала решили обменять биты на качество.
|
|
1245 </para>
|
|
1246
|
|
1247 <para>
|
|
1248 Также не корректируйте гамму, контрастность, яркость и т.п.. То,
|
|
1249 что хорошо выглядит на Вашем мониторе, может плохо выглядеть
|
|
1250 на других. Коррекция должна выполняться только при воспроизведении.
|
|
1251 </para>
|
|
1252
|
|
1253 <para>
|
|
1254 Однако, есть одна вещь, которую Вы, быть может, захотите сделать —
|
|
1255 это пропустить видео через очень слабый фильтр удаления шумов,
|
|
1256 такой как <option>-vf hqdn3d=2:1:2</option>.
|
|
1257 Ещё раз, причиной этому является то, что этим битам можно найти
|
|
1258 лучшее применение: зачем тратить их, кодируя шум, если Вы просто
|
|
1259 можете вернуть этот шум в процессе воспроизведения?
|
|
1260 Увеличение параметров для <option>hqdn3d</option> дополнительно
|
|
1261 улучшит сжимаемость, но увеличив значения слишком сильно, Вы рискуете
|
|
1262 ухудшить различимость изображения.
|
|
1263 Рекомендованные выше значения (<option>2:1:2</option>) слегка
|
|
1264 консервативны; не бойтесь экспериментировать с более высокими
|
|
1265 значениями и самостоятельно оценивать результаты.
|
|
1266 </para>
|
|
1267
|
|
1268 </sect2>
|
|
1269
|
|
1270
|
|
1271 <sect2 id="menc-feat-dvd-mpeg4-interlacing">
|
|
1272 <title>Чересстрочная развёртка и телесин</title>
|
|
1273
|
|
1274 <para>
|
|
1275 Почти все фильмы снимаются при 24 fps [кадр/сек]. Поскольку
|
|
1276 в NTSC ниспользуется 30000/1001 fps, нужно выполнить некоторую
|
|
1277 обработку для такого 24 fps видео, чтобы оно корректно
|
|
1278 воспроизводилось при кадровой частоте NTSC. Этот процесс называется
|
|
1279 3:2 пулдаун, обычно называемый телесин (поскольку пулдаун часто
|
|
1280 применяется в процессе показа телевизионного фильма, англ. telecine);
|
|
1281 и в упрощенном описании это работает путём замедления фильма до
|
|
1282 24000/1001 fps и повтора каждого четвёртого кадра.
|
|
1283 </para>
|
|
1284
|
|
1285 <para>
|
|
1286 Однако, никакой специальной обработки не выполняется для видео
|
|
1287 на PAL DVD, которое воспроизводится при 25 fps. (Технически PAL
|
|
1288 может быть подверженым телесину, называемому 2:2 пулдаун, но на
|
|
1289 практике это не применяется).
|
|
1290 24 fps фильм просто проигрывается на 25 fps. В результате фильм
|
|
1291 воспроизводится слегка быстрее, но если Вы не пришелец, то,
|
|
1292 вероятно, не заметите разницы.
|
|
1293 У большинства PAL DVD аудио корректируемо по высоте звука, так
|
|
1294 что, воспроизводясь при 25 fps, оно звучит нормально, даже если
|
|
1295 аудиодорожка (и, следовательно, весь фильм) проигрываются на
|
|
1296 4% быстрее, чем NTSC DVD.
|
|
1297 </para>
|
|
1298
|
|
1299 <para>
|
|
1300 Поскольку видео на PAL DVD не переделывается, Вам не стоит
|
|
1301 беспокоится о частоте кадров. У источника 25 fps и у Вашего
|
|
1302 рипа будет 25 fps. Однако, если Вы делаете рип NTSC DVD фильма,
|
|
1303 Вам, быть может, придётся выполнить обратный телесин.
|
|
1304 </para>
|
|
1305
|
|
1306 <para>
|
|
1307 Для фильмов, снятых на 24 fps, видео на NTSC DVD идёт либо с телесином
|
|
1308 30000/1001, либо с построчной развёрткой 24000/1001 fps и
|
|
1309 предназначается для телесина на лету с помощью DVD плеера.
|
|
1310 С другой стороны, TV сериалы идут обычно только с чересстрочной развёрткой,
|
|
1311 но без телесина. Это не строгое правило: есть сериалы с
|
|
1312 чересстрочной развёрткой (например, Баффи, Убийца Вампиров
|
|
1313 [Buffy the Vampire Slayer]), в то время как другие представляют
|
|
1314 собой смесь построчной и чересстрочной развёртки (такие как
|
|
1315 Ангел [Angel] или 24).
|
|
1316 </para>
|
|
1317
|
|
1318 <para>
|
|
1319 Настоятельно рекомендуется прочитать раздел о
|
|
1320 <link linkend="menc-feat-telecine">работе с телесином и чересстрочной развёрткой в NTSC DVD</link>
|
|
1321 для изучения способов обработки в разных ситуациях.
|
|
1322 </para>
|
|
1323
|
|
1324 <para>
|
|
1325 Однако, если Вы преимущественно делаете рипы фильмов, Вы, скорее
|
|
1326 всего, имеете дело с 24 fps видео либо с построчной развёрткой,
|
|
1327 либо с подвергнутым телесину; в последнем случае Вы можете использовать
|
|
1328 <option>pullup</option> фильтр: <option>-vf
|
|
1329 pullup,softskip</option>.
|
|
1330 </para>
|
|
1331
|
|
1332 </sect2>
|
|
1333
|
|
1334 <sect2 id="menc-feat-dvd-mpeg4-encoding-interlaced">
|
|
1335 <title>Кодирование чересстрочного видео</title>
|
|
1336
|
|
1337 <para>
|
|
1338 Если Вы желаете кодировать фильм с чересстрочной развёрткой
|
|
1339 (NTSC или PAL видео), Вам нужно решить, будете ли Вы его
|
|
1340 преобразовывать в построчную развёртку или нет.
|
|
1341 Хотя такое преобразование (деинтерлейс) сделает Ваш фильм
|
|
1342 пригодным для дисплеев с построчной развёрткой, таких как
|
|
1343 компьютерные мониторы и проекторы, это будет иметь свою цену:
|
|
1344 частота полей уменьшится вдвое от 50 или 60000/1001 до 25 или
|
|
1345 30000/1001 поля в секунду, и примерно половина информации в
|
|
1346 Вашем фильме будет потеряна в сценах со значительным движением.
|
|
1347 </para>
|
|
1348
|
|
1349 <para>
|
|
1350 Поэтому, если Вы кодируете для высококачественных архивных целей,
|
|
1351 не рекомендуется делать деинтерлейс. Вы всегда можете преобразовать
|
|
1352 развёртку фильма в процессе воспроизведения (при воспроизведении
|
|
1353 на устройствах с построчной развёрткой).
|
|
1354 Мощность современных компьютеров вынуждает плееры использовать
|
|
1355 фильтр деинтерлейса, что слегка ухудшает качество изображения.
|
|
1356 Но плееры будущего будут способны имитировать дисплей TV с
|
|
1357 чересстрочной развёрткой, выполняя деинтерлейс на полной частоте
|
|
1358 полей и интерполируя 50 или 60000/1001 кадров в секунду для
|
|
1359 чересстрочного видео.
|
|
1360 </para>
|
|
1361
|
|
1362 <para>
|
|
1363 С чересстрочным видео нужно работать особым образом:
|
|
1364 </para>
|
|
1365
|
|
1366 <orderedlist>
|
|
1367 <listitem><para>
|
|
1368 Высота усечения и смещение по оси y должны быть кратны 4.
|
|
1369 </para></listitem>
|
|
1370 <listitem><para>
|
|
1371 Любое вертикальное масштабирование должно выполняться в режиме
|
|
1372 чересстрочной развёртки.
|
|
1373 </para></listitem>
|
|
1374 <listitem><para>
|
|
1375 Фильтры постобработки и удаления шума могут не работать как
|
|
1376 ожидается, только если Вы особо не позаботитесь об их
|
|
1377 одновременном применении на частоте полей, иначе они могут
|
|
1378 повредить видео при неверном использовании.
|
|
1379 </para></listitem>
|
|
1380 </orderedlist>
|
|
1381
|
|
1382 <para>
|
|
1383 Учитывая вышесказанное, вот наш первый пример:
|
|
1384 </para>
|
|
1385 <screen>
|
|
1386 mencoder <replaceable>захват.avi</replaceable> -mc 0 -oac lavc -ovc lavc -lavcopts \
|
|
1387 vcodec=mpeg2video:vbitrate=6000:ilme:ildct:acodec=mp2:abitrate=224
|
|
1388 </screen>
|
|
1389 <para>
|
|
1390 Обратите внимание на опции <option>ilme</option> и <option>ildct</option>.
|
|
1391 </para>
|
|
1392 </sect2>
|
|
1393
|
|
1394
|
|
1395 <sect2 id="menc-feat-dvd-mpeg4-av-sync">
|
|
1396 <title>Замечания об аудио/видео синхронизации</title>
|
|
1397
|
|
1398 <para>
|
|
1399 Алгоритмы аудио/видео (A/V) синхронизации <application>MEncoder</application>
|
|
1400 были разработаны с целью восстановления файлов с повреждённой
|
|
1401 синхронизацией.
|
|
1402 Однако, в ряде случаев они могут привести к ненужному пропуску
|
|
1403 или повторению кадров и, возможно, к лёгкой A/V десинхронизации
|
|
1404 корректных входных данных (конечно, проблемы A/V синхронизации
|
|
1405 возникают только при обработке или копировании аудиотрека при
|
|
1406 кодировании видео, что настоятельно рекомендуется).
|
|
1407 Поэтому Вы можете переключиться на базовую A/V синхронизацию
|
|
1408 с помощью опции <option>-mc 0</option> или разместить это в
|
|
1409 конфигурационном файле <systemitem>~/.mplayer/mencoder</systemitem>,
|
|
1410 если Вы работаете только с хорошими источниками (DVD, TV-захват,
|
|
1411 высококачественные MPEG-4 рипы и т.п.), а не с повреждёнными
|
|
1412 файлами ASF/RM/MOV.
|
|
1413 </para>
|
|
1414 <para>
|
|
1415 Если Вы хотите дополнительно защититься от странных пропусков
|
|
1416 и повторений кадров, вы можете одновременно использовать опции
|
|
1417 <option>-mc 0</option> и <option>-noskip</option>.
|
|
1418 Это предотвратит <emphasis>любую</emphasis> A/V коррекцию, и
|
|
1419 будет копировать кадры один в один, так что Вы не сможете это
|
|
1420 использовать, если будете применять какие-либо фильтры, которые
|
|
1421 непредсказуемо добавляют или отбрасывают кадры, либо если у
|
|
1422 Вашего входного файла переменный битопоток!
|
|
1423 Поэтому использование <option>-noskip</option> в общем случае не
|
|
1424 рекомендуется.
|
|
1425 </para>
|
|
1426 <para>
|
|
1427 Сообщалось о том, что так называемое трёхпроходное аудиокодирование,
|
|
1428 поддерживаемое <application>MEncoder</application>, вызывало
|
|
1429 A/V десинхронизацию.
|
|
1430 Это наверняка произойдёт при использовании совместно с некоторыми
|
|
1431 фильтрами, поэтому сейчас <emphasis>не</emphasis> рекомендуется
|
|
1432 использовать трёхпроходный аудио режим.
|
|
1433 Эта возможность оставлена только для совместимости и для опытных
|
|
1434 пользователей, понимающих когда это безопасно, а когда нет.
|
|
1435 Если Вы ранее никогда не слышали о трёхпроходном режиме, забудьте
|
|
1436 даже о том, что мы его упоминали!
|
|
1437 </para>
|
|
1438 <para>
|
|
1439 Также были сообщения об A/V десинхронизации при кодировании
|
|
1440 со стандартного ввода (stdin) с помощью <application>MEncoder</application>.
|
|
1441 Не делайте этого! Всегда взамен используйте файл или CD/DVD и т.п.
|
|
1442 устройство.
|
|
1443 </para>
|
|
1444 </sect2>
|
|
1445
|
|
1446 <sect2 id="menc-feat-dvd-mpeg4-codec">
|
|
1447 <title>Выбор видеокодека</title>
|
|
1448
|
|
1449 <para>
|
|
1450 То, какой видеокодек лучше выбрать, зависит от нескольких
|
|
1451 факторов, таких как размер, качество, устойчивость к ошибкам,
|
|
1452 практичность и распостранённость, многие из которых сильно
|
|
1453 зависят от личных предпочтений и технических ограничений.
|
|
1454 </para>
|
|
1455 <itemizedlist>
|
|
1456 <listitem><para>
|
|
1457 <emphasis role="bold">Эффективность сжатия</emphasis>:
|
|
1458 Достаточно очевидно, что большинство кодеков нового поколения
|
|
1459 разработаны для увеличения качества и степени сжатия.
|
|
1460 Поэтому, авторы данного руководства и многие другие люди полагают,
|
|
1461 что Вы не можете ошибиться
|
|
1462 <footnote id='fn-menc-feat-dvd-mpeg4-codec-cpu'>
|
|
1463 <para>
|
|
1464 Несмотря на это, будьте осторожны: для декодирования MPEG-4 AVC
|
|
1465 видео с DVD разрешением необходима быстрая машина (например,
|
|
1466 Pentium 4 свыше 1.5 ГГц или Pentium M свыше 1 ГГц).
|
|
1467 </para></footnote>,
|
|
1468 выбирая MPEG-4 AVC кодеки (например,
|
|
1469 <systemitem class="library">x264</systemitem>)
|
|
1470 вместо таких MPEG-4 ASP кодеков, как
|
|
1471 <systemitem class="library">libavcodec</systemitem> MPEG-4 или
|
|
1472 <systemitem class="library">XviD</systemitem>.
|
|
1473 (Опытные разработчики кодеков могут быть заинтересованы в
|
|
1474 ознакомлении с точкой зрения Михаэля Найдермауэра (Michael
|
|
1475 Niedermayer)
|
|
1476 "<ulink url="http://guru.multimedia.cx/?p=10">почему MPEG4-ASP отстой</ulink>".)
|
|
1477 Аналогично, Вы должны получить лучшее качество с MPEG-4 ASP, по
|
|
1478 сравнению с MPEG-2 кодеками.
|
|
1479 </para>
|
|
1480 <para>
|
|
1481 Однако, новые кодеки, находящиеся в интенсивной разработке,
|
|
1482 могут страдать от ещё не замеченных ошибок, которые могут
|
|
1483 испортить кодирование. Просто это плата за использование
|
|
1484 передовых технологий.
|
|
1485 </para>
|
|
1486 <para>
|
|
1487 Более существенно то, что для начала использования нового кодека
|
|
1488 необходимо потратить время на изучение его опций так, чтобы Вы
|
|
1489 знали, что нужно подстраивать для достижения заданного качества
|
|
1490 изображения.
|
|
1491 </para></listitem>
|
|
1492
|
|
1493 <listitem><para>
|
|
1494 <emphasis role="bold">Аппаратная совместимость</emphasis>:
|
|
1495 Обычно необходимо длительное время для включения поддержки
|
|
1496 последних видеокодеков в автономные видеоплееры.
|
|
1497 В итоге, большинство поддерживает только MPEG-1 (наподобие
|
|
1498 VCD, XVCD и KVCD), MPEG-2 (например, DVD, SVCD и KVCD) и MPEG-4
|
|
1499 ASP (например, DivX,
|
|
1500 <systemitem class="library">libavcodec</systemitem> LMP4 и
|
|
1501 <systemitem class="library">XviD</systemitem>)
|
|
1502 (Осторожно: обычно поддерживаются не все возможности MPEG-4 ASP).
|
|
1503 Пожалуйста, обратитесь к технической спецификации Вашего плеера
|
|
1504 (если она доступна) или к гугл (google) для детальной информации.
|
|
1505 </para></listitem>
|
|
1506
|
|
1507 <listitem><para>
|
|
1508 <emphasis role="bold">Лучшее соотношение качества и времени кодирования</emphasis>:
|
|
1509 Кодеки, уже использующиеся определённое время (например,
|
|
1510 <systemitem class="library">libavcodec</systemitem> MPEG-4 и
|
|
1511 <systemitem class="library">XviD</systemitem>) обычно сильно
|
|
1512 оптимизированы всевозможными остроумными алгоритмами и
|
|
1513 ассемблерным SIMD кодом. Поэтому они обладают тенденцией
|
|
1514 достижения лучшего соотношения качества к времени кодирования.
|
|
1515 Однако, у них могут быть некоторые очень продвинутые опции,
|
|
1516 которые, будучи включенными, сделают кодирование очень медленным
|
|
1517 ради несущественного выигрыша.
|
|
1518 </para>
|
|
1519 <para>
|
|
1520 Если Вам нужна высокая скорость, примерно придерживайтесь настроек
|
|
1521 видеокодека по умолчанию (хотя Вам стоит попробовать другие опции,
|
|
1522 упоминаемые в иных разделах данного руководства).
|
|
1523 </para>
|
|
1524 <para>
|
|
1525 Вы так же можете рассмотреть вариант использования многопоточного
|
|
1526 кодека, хотя это полезно только для пользователей машин с
|
|
1527 несколькими процессорами.
|
|
1528 <systemitem class="library">libavcodec</systemitem> MPEG-4 позволяет
|
|
1529 это, но выигрыш в скорости ограничен и есть небольшой отрицательный
|
|
1530 эффект для качества картинки.
|
|
1531 Многопоточное кодирование <systemitem class="library">XviD</systemitem>,
|
|
1532 включаемое опцией <option>threads</option>, может использоваться для
|
|
1533 ускорения кодирования (на примерно 40-60% в типичных случаях)
|
|
1534 с небольшим ухудшением картинки или вообще без него.
|
|
1535 <systemitem class="library">x264</systemitem> также позволяет
|
|
1536 многопоточное кодирование, что обычно ускоряет процесс на 15-30%
|
|
1537 (в зависимости от настроек кодирования) с уменьшением PSNR примерно
|
|
1538 на 0.05 дБ.
|
|
1539 </para></listitem>
|
|
1540
|
|
1541 <listitem><para>
|
|
1542 <emphasis role="bold">Личные предпочтения</emphasis>:
|
|
1543 Здесь всё становится почти неразумным: из-за тех же причин, по
|
|
1544 которым одни придерживаются DivX 3 в течении лет, в то время
|
|
1545 как новые кодеки уже творят чудеса, другие люди предпочитают
|
|
1546 <systemitem class="library">XviD</systemitem> или
|
|
1547 <systemitem class="library">libavcodec</systemitem> MPEG-4
|
|
1548 использованиию <systemitem class="library">x264</systemitem>.
|
|
1549 </para>
|
|
1550 <para>
|
|
1551 Вам нужно принимать решение самостоятельно; не слушайте советов
|
|
1552 людей, признающих только один кодек.
|
|
1553 Сделайте несколько образцов клипов из искомых источников и
|
|
1554 сравните разные опции кодирования и кодеки, с целью выбора
|
|
1555 того, что Вам наиболее подходит.
|
|
1556 Лучший кодек — это тот, которым Вы сами овладели, и
|
|
1557 который выглядит лучше всего для Ваших глаз на Вашем дисплее
|
|
1558 <footnote id='fn-menc-feat-dvd-mpeg4-codec-playback'>
|
|
1559 <para>
|
|
1560 Один и тот же результат кодирования может не выглядеть таким же
|
|
1561 на чьём-либо другом мониторе или при воспроизведении с помощью
|
|
1562 другого декодера, так что проверяйте Ваши результаты кодирования
|
|
1563 на жизнеспособность, воспроизводя их в разных начальных условиях.
|
|
1564 </para></footnote>!
|
|
1565 </para></listitem>
|
|
1566 </itemizedlist>
|
|
1567 <para>
|
|
1568 Пожалуйста, обратитесь к разделу
|
|
1569 <link linkend="menc-feat-selecting-codec">выбор кодеков и форматов контейнера</link>
|
|
1570 для получения списка поддерживаемых кодеков.
|
|
1571 </para>
|
|
1572 </sect2>
|
|
1573
|
|
1574 <sect2 id="menc-feat-dvd-mpeg4-audio">
|
|
1575 <title>Аудио</title>
|
|
1576
|
|
1577 <para>
|
|
1578 Аудио — это гораздо более простая проблема: если Вы
|
|
1579 беспокоитесь о качестве, просто оставьте всё как есть.
|
|
1580 Даже потоки AC3 5.1 не более чем 448 Кбит/с и они стоят каждого
|
|
1581 бита. Вы можете соблазниться перекодированием аудио в
|
|
1582 высококачественный Vorbis (он же ogg формат), но лишь то, что
|
|
1583 у Вас сегодня нет A/V приёмника для пропускания AC3, не означает,
|
|
1584 что у Вас не будет его завтра. Для жизнеспособности Ваших DVD
|
|
1585 рипов в будущем, сохраняйте поток AC3.
|
|
1586 Вы можете сохранить поток AC3, копируя его непосредственно в
|
|
1587 видеопоток <link linkend="menc-feat-mpeg4">в процессе кодирования</link>.
|
|
1588 Вы также можете извлечь AC3 поток с целью мультиплексирования его
|
|
1589 в контейнеры наподобие NUT или Matroska (Матрёшка).
|
|
1590 <screen>
|
|
1591 mplayer <replaceable>файл_источника.vob</replaceable> -aid 129 -dumpaudio -dumpfile <replaceable>звук.ac3</replaceable></screen>
|
|
1592 сохранит в файл <replaceable>звук.ac3</replaceable> аудиодорожку
|
|
1593 с номером 129 из файла
|
|
1594 <replaceable>файл_источника.vob</replaceable> (Обратите внимание:
|
|
1595 DVD VOB файлы обычно импользуют нумерацию аудио, отличную от
|
|
1596 стандартной, что означает, что аудиодорожка VOB 129 — это вторая
|
|
1597 аудиодорожка файла).
|
|
1598 </para>
|
|
1599
|
|
1600 <para>
|
|
1601 Но иногда у Вас действительно нет иного выбора, чем далее сжимать
|
|
1602 звук для того, чтоб больше битов могло быть потрачено на видео.
|
|
1603 Большинство людей предпочитают сжимать звук с помощью MP3 или
|
|
1604 Vorbis аудиокодеков.
|
|
1605 Последний является очень эффективным, но MP3 лучше поддерживается
|
|
1606 аппаратными плеерами, хотя эта тенденция меняется.
|
|
1607 </para>
|
|
1608
|
|
1609 <para>
|
|
1610 <emphasis>Не</emphasis> используйте <option>-nosound</option> при
|
|
1611 кодировании файла с аудио, даже если Вы будете позже кодировать и
|
|
1612 мультеплексировать аудио отдельно.
|
|
1613 Хотя это может работать в идеальных случаях, использование
|
|
1614 <option>-nosound</option> обычно скрывает ряд проблем в Ваших
|
|
1615 настройках кодирования в командной строке.
|
|
1616 Другими словами, наличие звуковой дорожки в процессе кодирования
|
|
1617 гарантирует Вам, что в случае отсутствия сообщений, подобных
|
|
1618 <quote>Слишком много аудиопакетов в буфере</quote>, у Вас будет
|
|
1619 получена правильная синхронизация.
|
|
1620 </para>
|
|
1621
|
|
1622 <para>
|
|
1623 Вам необходим <application>MEncoder</application> для обработки
|
|
1624 звука.
|
|
1625 Например, Вы можете копировать исходную звуковую дорожку в
|
|
1626 процессе кодирования с помощью <option>-oac copy</option> или
|
|
1627 преобразовать её в "лёгкий" 4 кГц моно WAV PCM с помощью
|
|
1628 <option>-oac pcm -channels 1 -srate 4000</option>.
|
|
1629 Иначе, в ряде случаев, будет создаваться видео файл,
|
|
1630 десинхронизированный с аудио.
|
|
1631 Такие случаи происходят, когда число кадров видео исходного файла
|
|
1632 не совпадает с полной длиной кадров аудио, или когда были
|
|
1633 разрывы/сшивания потока, где появились пропущенные или излишние
|
|
1634 аудиокадры.
|
|
1635 Правильным решением подобных проблем является вставка тишины или
|
|
1636 усечение аудио в таких точках.
|
|
1637 Однако, <application>MPlayer</application> не может это сделать
|
|
1638 и если Вы демультиплексируете AC3 аудио и кодируете его отдельным
|
|
1639 приложением (или создаёте дамп в PCM с помощью
|
|
1640 <application>MPlayer</application>), сшивания останутся
|
|
1641 нескорректированными и единственный испособ их исправить —
|
|
1642 пропускать/дублировать видеокадры в местах сшивки.
|
|
1643 Пока <application>MEncoder</application> видит аудио при
|
|
1644 кодировании видео, он может выполнять этот пропуск/дублирование
|
|
1645 (что обычно не вызывыет проблем, т.к. происходит при полностью
|
|
1646 чёрных кадрах или при смене сцен), но если
|
|
1647 <application>MEncoder</application> не доступно аудио, он просто
|
|
1648 будет обрабатывать все кадры "как есть" и они не будут совпадать
|
|
1649 с окончательным аудиопотоком, когда Вы, например, объедините
|
|
1650 аудио и видео дорожки в Matroska файл.
|
|
1651 </para>
|
|
1652
|
|
1653 <para>
|
|
1654 Прежде всего, Вам необходимо преобразовать DVD звук в WAV файл,
|
|
1655 который может использоваться аудиокодеком в качестве входных
|
|
1656 данных. Например:
|
|
1657 <screen>
|
|
1658 mplayer <replaceable>исходный_файл.vob</replaceable> \
|
|
1659 -ao pcm:file=<replaceable>звук.wav</replaceable> -vc dummy -aid 1 -vo null</screen>
|
|
1660 сохранит вторую аудиодорожку из файла
|
|
1661 <replaceable>исходный_файл.vob</replaceable> в файл
|
|
1662 <replaceable>звук.wav</replaceable>.
|
|
1663 Возможно, Вы захотите нормализировать звук перед кодированием,
|
|
1664 поскольку аудиодорожки DVD обычно записываются с маленькой
|
|
1665 громкостью.
|
|
1666 Вы можете использовать, например, утилиту <application>normalize</application>,
|
|
1667 доступную в большинстве дистрибутивов.
|
|
1668 Если вы пользуетесь Window$, утилита <application>BeSweet</application>
|
|
1669 делает то же самое.
|
|
1670 Вы можете сжать в Vorbis или MP3. Например:
|
|
1671 <screen>oggenc -q1 <replaceable>звук.wav</replaceable></screen>
|
|
1672 кодирует <replaceable>звук.wav</replaceable> с качеством 1,
|
|
1673 что примерно эквивалентно 80 Кб/с и является минимальным качеством,
|
|
1674 при котором Вам нужно кодировать, если Вы заботитесь о качестве.
|
|
1675 Пожалуйста, обратите внимание, что <application>MEncoder</application>
|
|
1676 на данный момент не поддерживает мультиплексирование аудиопотоков
|
|
1677 Vorbis в выходной файл, поскольку он поддерживает только AVI и
|
|
1678 MPEG контейнеры для выходных файлов, использование каждого из
|
|
1679 которых может привести к проблемам A/V синхронизации с
|
|
1680 некоторыми плеерами, в случае когда AVI файл содержит VBR
|
|
1681 аудиопотоки наподобие Vorbis.
|
|
1682 Не беспокойтесь, в данном документе будет рассказано как Вы
|
|
1683 можете это сделать с помощью сторонних программ.
|
|
1684 </para>
|
|
1685
|
|
1686 </sect2>
|
|
1687
|
|
1688
|
|
1689 <sect2 id="menc-feat-dvd-mpeg4-muxing">
|
|
1690 <title>Мультиплексирование</title>
|
|
1691 <para>
|
|
1692 Теперь, после того как Вы кодировали видео, скорее всего, Вы
|
|
1693 захотите мультиплексировать его с одним или несколькими
|
|
1694 аудиопотоками в такие видео контейнеры как AVI, MPEG,
|
|
1695 Matroska или NUT.
|
|
1696 На данный момент встроенная поддержка вывода аудио и видео в
|
|
1697 <application>MEncoder</application> есть только для форматов
|
|
1698 контейнеров MPEG и AVI.
|
|
1699 Например:
|
|
1700 <screen>
|
|
1701 mencoder -oac copy -ovc copy -o <replaceable>выходной_фильм.avi</replaceable> \
|
|
1702 -audiofile <replaceable>исходный_звук.mp2</replaceable> <replaceable>исходное_видео.avi</replaceable></screen>
|
|
1703 Это объединит видеофайл <replaceable>исходное_видео.avi</replaceable>
|
|
1704 и аудиофайл <replaceable>исходный_звук.mp2</replaceable>
|
|
1705 в AVI файл <replaceable>выходной_фильм.avi</replaceable>.
|
|
1706 Эта команда работает с MPEG-1 слой I, II и III (более
|
|
1707 известный как MP3) аудио, WAV, а также с некоторыми иными
|
|
1708 форматами аудио.
|
|
1709 </para>
|
|
1710
|
|
1711 <para>
|
|
1712 <application>MEncoder</application>
|
|
1713 обладает экспериментальной поддержкой
|
|
1714 <systemitem class="library">libavformat</systemitem> —
|
|
1715 библиотеки из проекта FFmpeg, поддерживающей мультиплексирование
|
|
1716 и демультиплексирование множества контейнеров.
|
|
1717 Например:
|
|
1718 <screen>
|
|
1719 mencoder -oac copy -ovc copy -o <replaceable>выходной_фильм.asf</replaceable> \
|
|
1720 -audiofile <replaceable>исходный_звук.mp2</replaceable> <replaceable>исходное_видео.avi</replaceable> \
|
|
1721 -of lavf -lavfopts format=asf</screen>
|
|
1722 Это сделает то же самое, что и предыдущий пример, но выходным
|
|
1723 контейнером будет ASF.
|
|
1724 Пожалуйста, обратите внимание, что эта поддержка весьма
|
|
1725 экспериментальна (но становится лучше c каждым днём), и будет
|
|
1726 работать только в случае компиляции <application>MPlayer</application>
|
|
1727 с включенной поддержкой
|
|
1728 <systemitem class="library">libavformat</systemitem> (что означает,
|
|
1729 что в большинстве случаев бинарная версия из пакетов не будет
|
|
1730 работать).
|
|
1731 </para>
|
|
1732
|
|
1733
|
|
1734 <sect3 id="menc-feat-dvd-mpeg4-muxing-filter-issues">
|
|
1735 <title>Улучшение мультиплексирования и надёжности A/V синхронизации</title>
|
|
1736 <para>
|
|
1737 Вы можете столкнуться с некоторыми серьёзными проблемами A/V
|
|
1738 синхронизации при попытке мультиплексирования вашего видео
|
|
1739 с некоторыми аудиодорожками, где, как бы Вы не подбирали задержку
|
|
1740 аудио, никогда не получается правильная синхронизация.
|
|
1741 Это может происходить при использовании некоторых видеофильтров,
|
|
1742 пропускающих или дублирующих некоторые кадры, например фильтров
|
|
1743 обратного телесина.
|
|
1744 Настоятельно рекомендуется добавлять видеофильтр
|
|
1745 <option>harddup</option> в конце цепочки фильтров для избежания
|
|
1746 подобных проблем.
|
|
1747 </para>
|
|
1748
|
|
1749 <para>
|
|
1750 Без опции <option>harddup</option>, в случае когда
|
|
1751 <application>MEncoder</application> хочет дублировать кадр, он
|
|
1752 полагается на то, что мультиплексор расположит отметку в
|
|
1753 контейнере таким образом, что последний кадр будет повторен для
|
|
1754 достижения синхронизации без реальной записи кадра.
|
|
1755 С опцией <option>harddup</option>, <application>MEncoder</application>
|
|
1756 вместо этого просто ещё раз поместит последний кадр в цепочку
|
|
1757 фильтров.
|
|
1758 Это означает, что кодер получит <emphasis>точно</emphasis>
|
|
1759 такой же кадр дважды и сожмёт его.
|
|
1760 Это приведёт у несколько большему файлу, но избавит от проблем
|
|
1761 при демультиплексировании или ремультиплексировании с другими
|
|
1762 форматами контейнеров.
|
|
1763 </para>
|
|
1764
|
|
1765 <para>
|
|
1766 Также у Вас может не быть иного выбора, как использовать
|
|
1767 <option>harddup</option> с форматами контейнеров, которые
|
|
1768 не слишком плотно связаны с
|
|
1769 <application>MEncoder</application>, например, с форматами,
|
|
1770 поддерживаемыми с помощью
|
|
1771 <systemitem class="library">libavformat</systemitem>,
|
|
1772 которые могут не поддерживать дублирование кадров на уровне
|
|
1773 контейнера.
|
|
1774 </para>
|
|
1775 </sect3>
|
|
1776
|
|
1777
|
|
1778 <sect3 id="menc-feat-dvd-mpeg4-muxing-avi-limitations">
|
|
1779 <title>Ограничения контейнера AVI</title>
|
|
1780 <para>
|
|
1781 Хотя это самый широко распостранённый формат контейнера после
|
|
1782 MPEG-1, он также обладает некоторыми существенными недостатками.
|
|
1783 Пожалуй, они наиболее очевидны в его избыточности.
|
|
1784 Для каждой цепочки AVI файла теряется 24 байта на заголовки и
|
|
1785 индекс.
|
|
1786 Это приводит к чуть более 5 МБ/час или 1.0-2.5% избыточности
|
|
1787 для 700 МБ фильма. Это не кажется большим, но может означать
|
|
1788 разницу между возможностью использования 700 кбит/сек или
|
|
1789 714 кбит/сек в случаях, когда каждый бит на счету.
|
|
1790 </para>
|
|
1791
|
|
1792 <para>
|
|
1793 В дополнение к малой эффективности, AVI также обладает следующими
|
|
1794 серьёзными ограничениями:
|
|
1795 </para>
|
|
1796
|
|
1797 <orderedlist>
|
|
1798 <listitem>
|
|
1799 <para>
|
|
1800 Может быть сохранено только содержимое с фиксированной частотой
|
|
1801 кадров. В частности, это особенно ограничивает, когда Ваш
|
|
1802 исходный материал смешанного содержимого: например, является
|
|
1803 смесью NTSC видео и киноматериала.
|
|
1804 В действительности, есть хаки, позволяющие сохранять содержимое
|
|
1805 с переменным fps в AVI, но они увеличивают (и без того большую)
|
|
1806 избыточность впятеро или более того и поэтому непрактичны.
|
|
1807 </para>
|
|
1808 </listitem>
|
|
1809 <listitem>
|
|
1810 <para>
|
|
1811 Аудио в AVI файлах должно быть или с постоянным битпотоком (CBR)
|
|
1812 или с постоянным размером кадра (т.е. все кадры декодируются
|
|
1813 в одно и то же число выборок).
|
|
1814 К сожалению, самый эффективный кодек, Vorbis, не удовлетворяет
|
|
1815 ни одному из данных требований.
|
|
1816 Поэтому, если Вы планируете сохранять Ваш фильм в AVI, Вы должны
|
|
1817 использовать менее эффективный кодек, такой как MP3 или AC3.
|
|
1818 </para>
|
|
1819 </listitem>
|
|
1820 </orderedlist>
|
|
1821
|
|
1822 <para>
|
|
1823 Сказав всё это, отметим, что <application>MEncoder</application>
|
|
1824 на данный момент не поддерживает вывод с переменным fps или
|
|
1825 Vorbis кодирование.
|
|
1826 Поэтому Вы можете не рассматривать всё это как ограничения, если
|
|
1827 <application>MEncoder</application> — это единственный
|
|
1828 инструмент, который Вы используете для кодирования.
|
|
1829 Однако, возможно использовать <application>MEncoder</application>
|
|
1830 только для кодирования видео и затем использовать внешние
|
|
1831 утилиты для кодирования аудио и мультиплексирования его в
|
|
1832 контейнер другого формата.
|
|
1833 </para>
|
|
1834 </sect3>
|
|
1835
|
|
1836 <sect3 id="menc-feat-dvd-mpeg4-muxing-matroska">
|
|
1837 <title>Мультиплексирование в контейнер Matroska (Матрёшка)</title>
|
|
1838 <para>
|
|
1839 Matroska — это свободный, открытый стандарт формата
|
|
1840 контейнера, нацеленный на предоставление большого количества
|
|
1841 продвинутых возможностей, которые старые контейнеры (наподобие
|
|
1842 AVI) не поддерживают.
|
|
1843 Например, Matroska поддерживает аудиосодержимое с переменным
|
|
1844 битпотоком (VBR), переменные частоты кадров (VFR), разделы,
|
|
1845 файловые вложения, код обнаружения ошибок (EDC) и современные
|
|
1846 A/V кодеки, такие как "Продвинутое Аудио Кодирование" ("Advanced
|
|
1847 Audio Coding", AAC), "Vorbis" или "MPEG-4 AVC" (H.264), также
|
|
1848 не поддерживаемые AVI.
|
|
1849 </para>
|
|
1850
|
|
1851 <para>
|
|
1852 Утилиты, необходимые для создания Matroska файлов, сообща
|
|
1853 называются <application>mkvtoolnix</application>, и доступны
|
|
1854 для большиства Unix платформ, так же как и для Window$.
|
|
1855 Поскольку Matroska — открытый формат, Вы можете найти
|
|
1856 иные утилиты, которые лучше Вам подходят, но поскольку
|
|
1857 <application>mkvtoolnix</application> — наиболее общие
|
|
1858 и поддерживаются самой командой разработчиков Matroska, мы
|
|
1859 будем обсуждать только их использование.
|
|
1860 </para>
|
|
1861
|
|
1862 <para>
|
|
1863 Возможно, самым простым способом начать использовать Matroska
|
|
1864 является использование <application>MMG</application>,
|
|
1865 графической оболочки, поставляемой с
|
|
1866 <application>mkvtoolnix</application>. Следуйте
|
|
1867 <ulink url="http://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge-gui.html">руководству к mkvmerge GUI (mmg)</ulink>.
|
|
1868 </para>
|
|
1869
|
|
1870 <para>
|
|
1871 Также Вы можете мультиплексировать аудио и видео файлы используя
|
|
1872 командную строку:
|
|
1873 <screen>
|
|
1874 mkvmerge -o <replaceable>выходной_файл.mkv</replaceable> <replaceable>входное_видео.avi</replaceable> \
|
|
1875 <replaceable>входное_аудио1.mp3</replaceable> <replaceable>входное_аудио2.ac3</replaceable></screen>
|
|
1876 Это объединит видеофайл <replaceable>входное_видео.avi</replaceable>
|
|
1877 и два аудиофайла <replaceable>входное_аудио1.mp3</replaceable>
|
|
1878 и <replaceable>входное_аудио2.ac3</replaceable> в Matroska
|
|
1879 файл <replaceable>выходной_файл.mkv</replaceable>.
|
|
1880 Как было отмечено ранее, Matroska способна реализовать гораздо
|
|
1881 большее, например, множественные аудиодорожки (включая тонкую
|
|
1882 настройку аудио/видео синхронизации), разделы, субтитры,
|
|
1883 разбиение и т.д..
|
|
1884 Пожалуйста, обратитесь к документации на эти приложения для
|
|
1885 деталей.
|
|
1886 </para>
|
|
1887
|
|
1888 </sect3>
|
|
1889
|
|
1890 </sect2>
|
|
1891
|
|
1892 </sect1>
|
|
1893
|
|
1894 <sect1 id="menc-feat-telecine">
|
|
1895 <title>How to deal with telecine and interlacing within NTSC DVDs</title>
|
|
1896
|
|
1897 <sect2 id="menc-feat-telecine-intro">
|
|
1898 <title>Introduction</title>
|
|
1899 <formalpara>
|
|
1900 <title>What is telecine?</title>
|
|
1901 <para>
|
|
1902 If you do not understand much of what is written in this document,
|
|
1903 read the
|
|
1904 <ulink url="http://en.wikipedia.org/wiki/Telecine">Wikipedia entry on telecine</ulink>.
|
|
1905 It is an understandable and reasonably comprehensive
|
|
1906 description of what telecine is.
|
|
1907 </para></formalpara>
|
|
1908
|
|
1909 <formalpara>
|
|
1910 <title>A note about the numbers.</title>
|
|
1911 <para>
|
|
1912 Many documents, including the guide linked above, refer to the fields
|
|
1913 per second value of NTSC video as 59.94 and the corresponding frames
|
|
1914 per second values as 29.97 (for telecined and interlaced) and 23.976
|
|
1915 (for progressive). For simplicity, some documents even round these
|
|
1916 numbers to 60, 30, and 24.
|
|
1917 </para></formalpara>
|
|
1918
|
|
1919 <para>
|
|
1920 Strictly speaking, all those numbers are approximations. Black and
|
|
1921 white NTSC video was exactly 60 fields per second, but 60000/1001
|
|
1922 was later chosen to accomodate color data while remaining compatible
|
|
1923 with contemporary black and white televisions. Digital NTSC video
|
|
1924 (such as on a DVD) is also 60000/1001 fields per second. From this,
|
|
1925 interlaced and telecined video are derived to be 30000/1001 frames
|
|
1926 per second; progressive video is 24000/1001 frames per second.
|
|
1927 </para>
|
|
1928
|
|
1929 <para>
|
|
1930 Older versions of the <application>MEncoder</application> documentation
|
|
1931 and many archived mailing list posts refer to 59.94, 29.97, and 23.976.
|
|
1932 All <application>MEncoder</application> documentation has been updated
|
|
1933 to use the fractional values, and you should use them too.
|
|
1934 </para>
|
|
1935
|
|
1936 <para>
|
|
1937 <option>-ofps 23.976</option> is incorrect.
|
|
1938 <option>-ofps 24000/1001</option> should be used instead.
|
|
1939 </para>
|
|
1940
|
|
1941 <formalpara>
|
|
1942 <title>How telecine is used.</title>
|
|
1943 <para>
|
|
1944 All video intended to be displayed on an NTSC
|
|
1945 television set must be 60000/1001 fields per second. Made-for-TV movies
|
|
1946 4 and shows are often filmed directly at 60000/1001 fields per second, but
|
|
1947 the majority of cinema is filmed at 24 or 24000/1001 frames per
|
|
1948 second. When cinematic movie DVDs are mastered, the video is then
|
|
1949 converted for television using a process called telecine.
|
|
1950 </para></formalpara>
|
|
1951
|
|
1952 <para>
|
|
1953 On a DVD, the video is never actually stored as 60000/1001 fields per
|
|
1954 second. For video that was originally 60000/1001, each pair of fields is
|
|
1955 combined to form a frame, resulting in 30000/1001 frames per
|
|
1956 second. Hardware DVD players then read a flag embedded in the video
|
|
1957 stream to determine whether the odd- or even-numbered lines should
|
|
1958 form the first field.
|
|
1959 </para>
|
|
1960
|
|
1961 <para>
|
|
1962 Usually, 24000/1001 frames per second content stays as it is when
|
|
1963 encoded for a DVD, and the DVD player must perform telecining
|
|
1964 on-the-fly. Sometimes, however, the video is telecined
|
|
1965 <emphasis>before</emphasis> being stored on the DVD; even though it
|
|
1966 was originally 24000/1001 frames per second, it becomes 60000/1001 fields per
|
|
1967 second. When it is stored on the DVD, pairs of fields are combined to form
|
|
1968 30000/1001 frames per second.
|
|
1969 </para>
|
|
1970
|
|
1971 <para>
|
|
1972 When looking at individual frames formed from 60000/10001 fields per
|
|
1973 second video, telecined or otherwise, interlacing is clearly visible
|
|
1974 wherever there is any motion, because one field (say, the
|
|
1975 even-numbered lines) represents a moment in time 1/(60000/1001)
|
|
1976 seconds later than the other. Playing interlaced video on a computer
|
|
1977 looks ugly both because the monitor is higher resolution and because
|
|
1978 the video is shown frame-after-frame instead of field-after-field.
|
|
1979 </para>
|
|
1980
|
|
1981 <itemizedlist>
|
|
1982 <title>Notes:</title>
|
|
1983 <listitem><para>
|
|
1984 This section only applies to NTSC DVDs, and not PAL.
|
|
1985 </para></listitem>
|
|
1986 <listitem><para>
|
|
1987 The example <application>MEncoder</application> lines throughout the
|
|
1988 document are <emphasis role="bold">not</emphasis> intended for
|
|
1989 actual use. They are simply the bare minimum required to encode the
|
|
1990 pertaining video category. How to make good DVD rips or fine-tune
|
|
1991 <systemitem class="library">libavcodec</systemitem> for maximal
|
|
1992 quality is not within the scope of this document.
|
|
1993 </para></listitem>
|
|
1994 <listitem><para>
|
|
1995 There are a couple footnotes specific to this guide, linked like this:
|
|
1996 <link linkend="menc-feat-telecine-footnotes">[1]</link>
|
|
1997 </para></listitem>
|
|
1998 </itemizedlist>
|
|
1999 </sect2>
|
|
2000
|
|
2001 <sect2 id="menc-feat-telecine-ident">
|
|
2002 <title>How to tell what type of video you have</title>
|
|
2003
|
|
2004 <sect3 id="menc-feat-telecine-ident-progressive">
|
|
2005 <title>Progressive</title>
|
|
2006 <para>
|
|
2007 Progressive video was originally filmed at 24000/1001 fps, and stored
|
|
2008 on the DVD without alteration.
|
|
2009 </para>
|
|
2010
|
|
2011 <para>
|
|
2012 When you play a progressive DVD in <application>MPlayer</application>,
|
|
2013 <application>MPlayer</application> will print the following line as
|
|
2014 soon as the movie begins to play:
|
|
2015
|
|
2016 <screen> demux_mpg: 24000/1001 fps progressive NTSC content detected, switching framerate.</screen>
|
|
2017
|
|
2018 From this point forward, demux_mpg should never say it finds
|
|
2019 "30000/1001 fps NTSC content."
|
|
2020 </para>
|
|
2021
|
|
2022 <para>
|
|
2023 When you watch progressive video, you should never see any
|
|
2024 interlacing. Beware, however, because sometimes there is a tiny bit
|
|
2025 of telecine mixed in where you would not expect. I have encountered TV
|
|
2026 show DVDs that have one second of telecine at every scene change, or
|
|
2027 at seemingly random places. I once watched a DVD that had a
|
|
2028 progressive first half, and the second half was telecined. If you
|
|
2029 want to be <emphasis>really</emphasis> thorough, you can scan the
|
|
2030 entire movie:
|
|
2031
|
|
2032 <screen>mplayer dvd://1 -nosound -vo null -benchmark</screen>
|
|
2033
|
|
2034 Using <option>-benchmark</option> makes
|
|
2035 <application>MPlayer</application> play the movie as quickly as it
|
|
2036 possibly can; still, depending on your hardware, it can take a
|
|
2037 while. Every time demux_mpg reports a framerate change, the line
|
|
2038 immediately above will show you the time at which the change
|
|
2039 occurred.
|
|
2040 </para>
|
|
2041
|
|
2042 <para>
|
|
2043 Sometimes progressive video on DVDs is referred to as
|
|
2044 "soft-telecine" because it is intended to
|
|
2045 be telecined by the DVD player.
|
|
2046 </para>
|
|
2047 </sect3>
|
|
2048
|
|
2049 <sect3 id="menc-feat-telecine-ident-telecined">
|
|
2050 <title>Telecined</title>
|
|
2051 <para>
|
|
2052 Telecined video was originally filmed at 24000/1001, but was telecined
|
|
2053 <emphasis>before</emphasis> it was written to the DVD.
|
|
2054 </para>
|
|
2055
|
|
2056 <para>
|
|
2057 <application>MPlayer</application> does not (ever) report any
|
|
2058 framerate changes when it plays telecined video.
|
|
2059 </para>
|
|
2060
|
|
2061 <para>
|
|
2062 Watching a telecined video, you will see interlacing artifacts that
|
|
2063 seem to "blink": they repeatedly appear and disappear.
|
|
2064 You can look closely at this by
|
|
2065 <orderedlist>
|
|
2066 <listitem>
|
|
2067 <screen>mplayer dvd://1</screen>
|
|
2068 </listitem>
|
|
2069 <listitem><para>
|
|
2070 Seek to a part with motion.
|
|
2071 </para></listitem>
|
|
2072 <listitem><para>
|
|
2073 Use the <keycap>.</keycap> key to step forward one frame at a time.
|
|
2074 </para></listitem>
|
|
2075 <listitem><para>
|
|
2076 Look at the pattern of interlaced-looking and progressive-looking
|
|
2077 frames. If the pattern you see is PPPII,PPPII,PPPII,... then the
|
|
2078 video is telecined. If you see some other pattern, then the video
|
|
2079 may have been telecined using some non-standard method;
|
|
2080 <application>MEncoder</application> cannot losslessly convert
|
|
2081 non-standard telecine to progressive. If you do not see any
|
|
2082 pattern at all, then it is most likely interlaced.
|
|
2083 </para></listitem>
|
|
2084 </orderedlist>
|
|
2085 </para>
|
|
2086
|
|
2087 <para>
|
|
2088 Sometimes telecined video on DVDs is referred to as
|
|
2089 "hard-telecine". Since hard-telecine is already 60000/1001 fields
|
|
2090 per second, the DVD player plays the video without any manipulation.
|
|
2091 </para>
|
|
2092
|
|
2093 <para>
|
|
2094 Another way to tell if your source is telecined or not is to play
|
|
2095 the source with the <option>-vf pullup</option> and <option>-v</option>
|
|
2096 command line options to see how <option>pullup</option> matches frames.
|
|
2097 If the source is telecined, you should see on the console a 3:2 pattern
|
|
2098 with <systemitem>0+.1.+2</systemitem> and <systemitem>0++1</systemitem>
|
|
2099 alternating.
|
|
2100 This technique has the advantage that you do not need to watch the
|
|
2101 source to identify it, which could be useful if you wish to automate
|
|
2102 the encoding procedure, or to carry out said procedure remotely via
|
|
2103 a slow connection.
|
|
2104 </para>
|
|
2105
|
|
2106 </sect3>
|
|
2107
|
|
2108 <sect3 id="menc-feat-telecine-ident-interlaced">
|
|
2109 <title>Interlaced</title>
|
|
2110 <para>
|
|
2111 Interlaced video was originally filmed at 60000/1001 fields per second,
|
|
2112 and stored on the DVD as 30000/1001 frames per second. The interlacing effect
|
|
2113 (often called "combing") is a result of combining pairs of
|
|
2114 fields into frames. Each field is supposed to be 1/(60000/1001) seconds apart,
|
|
2115 and when they are displayed simultaneously the difference is apparent.
|
|
2116 </para>
|
|
2117
|
|
2118 <para>
|
|
2119 As with telecined video, <application>MPlayer</application> should
|
|
2120 not ever report any framerate changes when playing interlaced content.
|
|
2121 </para>
|
|
2122
|
|
2123 <para>
|
|
2124 When you view an interlaced video closely by frame-stepping with the
|
|
2125 <keycap>.</keycap> key, you will see that every single frame is interlaced.
|
|
2126 </para>
|
|
2127 </sect3>
|
|
2128
|
|
2129 <sect3 id="menc-feat-telecine-ident-mixedpt">
|
|
2130 <title>Mixed progressive and telecine</title>
|
|
2131 <para>
|
|
2132 All of a "mixed progressive and telecine" video was originally
|
|
2133 24000/1001 frames per second, but some parts of it ended up being telecined.
|
|
2134 </para>
|
|
2135
|
|
2136 <para>
|
|
2137 When <application>MPlayer</application> plays this category, it will
|
|
2138 (often repeatedly) switch back and forth between "30000/1001 fps NTSC"
|
|
2139 and "24000/1001 fps progressive NTSC". Watch the bottom of
|
|
2140 <application>MPlayer</application>'s output to see these messages.
|
|
2141 </para>
|
|
2142
|
|
2143 <para>
|
|
2144 You should check the "30000/1001 fps NTSC" sections to make sure
|
|
2145 they are actually telecine, and not just interlaced.
|
|
2146 </para>
|
|
2147 </sect3>
|
|
2148
|
|
2149 <sect3 id="menc-feat-telecine-ident-mixedpi">
|
|
2150 <title>Mixed progressive and interlaced</title>
|
|
2151 <para>
|
|
2152 In "mixed progressive and interlaced" content, progressive
|
|
2153 and interlaced video have been spliced together.
|
|
2154 </para>
|
|
2155
|
|
2156 <para>
|
|
2157 This category looks just like "mixed progressive and telecine",
|
|
2158 until you examine the 30000/1001 fps sections and see that they do not have the
|
|
2159 telecine pattern.
|
|
2160 </para>
|
|
2161 </sect3>
|
|
2162
|
|
2163 </sect2>
|
|
2164
|
|
2165 <sect2 id="menc-feat-telecine-encode">
|
|
2166 <title>How to encode each category</title>
|
|
2167 <para>
|
|
2168 As I mentioned in the beginning, example <application>MEncoder</application>
|
|
2169 lines below are <emphasis role="bold">not</emphasis> meant to actually be used;
|
|
2170 they only demonstrate the minimum parameters to properly encode each category.
|
|
2171 </para>
|
|
2172
|
|
2173 <sect3 id="menc-feat-telecine-encode-progressive">
|
|
2174 <title>Progressive</title>
|
|
2175 <para>
|
|
2176 Progressive video requires no special filtering to encode. The only
|
|
2177 parameter you need to be sure to use is
|
|
2178 <option>-ofps 24000/1001</option>. Otherwise, <application>MEncoder</application>
|
|
2179 will try to encode at 30000/1001 fps and will duplicate frames.
|
|
2180 </para>
|
|
2181
|
|
2182 <para>
|
|
2183 <screen>mencoder dvd://1 -oac copy -ovc lavc -ofps 24000/1001</screen>
|
|
2184 </para>
|
|
2185
|
|
2186 <para>
|
|
2187 It is often the case, however, that a video that looks progressive
|
|
2188 actually has very short parts of telecine mixed in. Unless you are
|
|
2189 sure, it is safest to treat the video as
|
|
2190 <link linkend="menc-feat-telecine-encode-mixedpt">mixed progressive and telecine</link>.
|
|
2191 The performance loss is small
|
|
2192 <link linkend="menc-feat-telecine-footnotes">[3]</link>.
|
|
2193 </para>
|
|
2194 </sect3>
|
|
2195
|
|
2196 <sect3 id="menc-feat-telecine-encode-telecined">
|
|
2197 <title>Telecined</title>
|
|
2198 <para>
|
|
2199 Telecine can be reversed to retrieve the original 24000/1001 content,
|
|
2200 using a process called inverse-telecine.
|
|
2201 <application>MPlayer</application> contains several filters to
|
|
2202 accomplish this; the best filter, <option>pullup</option>, is described
|
|
2203 in the <link linkend="menc-feat-telecine-encode-mixedpt">mixed
|
|
2204 progressive and telecine</link> section.
|
|
2205 </para>
|
|
2206 </sect3>
|
|
2207
|
|
2208 <sect3 id="menc-feat-telecine-encode-interlaced">
|
|
2209 <title>Interlaced</title>
|
|
2210 <para>
|
|
2211 For most practical cases it is not possible to retrieve a complete
|
|
2212 progressive video from interlaced content. The only way to do so
|
|
2213 without losing half of the vertical resolution is to double the
|
|
2214 framerate and try to "guess" what ought to make up the
|
|
2215 corresponding lines for each field (this has drawbacks - see method
|
|
2216 3).
|
|
2217 </para>
|
|
2218
|
|
2219 <orderedlist>
|
|
2220 <listitem><para>
|
|
2221
|
|
2222 Encode the video in interlaced form. Normally, interlacing wreaks
|
|
2223 havoc with the encoder's ability to compress well, but
|
|
2224 <systemitem class="library">libavcodec</systemitem> has two
|
|
2225 parameters specifically for dealing with storing interlaced video a
|
|
2226 bit better: <option> ildct</option> and <option>ilme</option>. Also,
|
|
2227 using <option>mbd=2</option> is strongly recommended
|
|
2228 <link linkend="menc-feat-telecine-footnotes">[2] </link> because it
|
|
2229 will encode macroblocks as non-interlaced in places where there is
|
|
2230 no motion. Note that <option>-ofps</option> is NOT needed here.
|
|
2231
|
|
2232 <screen>mencoder dvd://1 -oac copy -ovc lavc -lavcopts ildct:ilme:mbd=2</screen>
|
|
2233 </para></listitem>
|
|
2234 <listitem><para>
|
|
2235 Use a deinterlacing filter before encoding. There are several of
|
|
2236 these filters available to choose from, each with its own advantages
|
|
2237 and disadvantages. Consult <option>mplayer -pphelp</option> to see
|
|
2238 what is available (grep for "deint"), and search the
|
|
2239 <ulink url="http://www.mplayerhq.hu/design7/info.html#mailing_lists">
|
|
2240 MPlayer mailing lists</ulink> to find many discussions about the
|
|
2241 various filters. Again, the framerate is not changing, so no
|
|
2242 <option>-ofps</option>. Also, deinterlacing should be done after
|
|
2243 cropping <link linkend="menc-feat-telecine-footnotes">[1]</link> and
|
|
2244 before scaling.
|
|
2245
|
|
2246 <screen>mencoder dvd://1 -oac copy -vf pp=lb -ovc lavc</screen>
|
|
2247 </para></listitem>
|
|
2248 <listitem><para>
|
|
2249 Unfortunately, this option is buggy with
|
|
2250 <application>MEncoder</application>; it ought to work well with
|
|
2251 <application>MEncoder G2</application>, but that is not here yet. You
|
|
2252 might experience crahes. Anyway, the purpose of <option> -vf
|
|
2253 tfields</option> is to create a full frame out of each field, which
|
|
2254 makes the framerate 60000/1001. The advantage of this approach is that no
|
|
2255 data is ever lost; however, since each frame comes from only one
|
|
2256 field, the missing lines have to be interpolated somehow. There are
|
|
2257 no very good methods of generating the missing data, and so the
|
|
2258 result will look a bit similar to when using some deinterlacing
|
|
2259 filters. Generating the missing lines creates other issues, as well,
|
|
2260 simply because the amount of data doubles. So, higher encoding
|
|
2261 bitrates are required to maintain quality, and more CPU power is
|
|
2262 used for both encoding and decoding. tfields has several different
|
|
2263 options for how to create the missing lines of each frame. If you
|
|
2264 use this method, then Reference the manual, and chose whichever
|
|
2265 option looks best for your material. Note that when using
|
|
2266 <option>tfields</option> you
|
|
2267 <emphasis role="bold">have to</emphasis> specify both
|
|
2268 <option>-fps</option> and <option>-ofps</option> to be twice the
|
|
2269 framerate of your original source.
|
|
2270
|
|
2271 <screen>mencoder dvd://1 -oac copy -vf tfields=2 -ovc lavc -fps 60000/1001 -ofps 60000/1001</screen>
|
|
2272 </para></listitem>
|
|
2273 <listitem><para>
|
|
2274 If you plan on downscaling dramatically, you can extract and encode
|
|
2275 only one of the two fields. Of course, you will lose half the vertical
|
|
2276 resolution, but if you plan on downscaling to at most 1/2 of the
|
|
2277 original, the loss will not matter much. The result will be a
|
|
2278 progressive 30000/1001 frames per second file. The procedure is to use
|
|
2279 <option>-vf field</option>, then crop
|
|
2280 <link linkend="menc-feat-telecine-footnotes">[1]</link> and scale
|
|
2281 appropriately. Remember that you will have to adjust the scale to
|
|
2282 compensate for the vertical resolution being halved.
|
|
2283 <screen>mencoder dvd://1 -oac copy -vf field=0 -ovc lavc</screen>
|
|
2284 </para></listitem>
|
|
2285 </orderedlist>
|
|
2286 </sect3>
|
|
2287
|
|
2288 <sect3 id="menc-feat-telecine-encode-mixedpt">
|
|
2289 <title>Mixed progressive and telecine</title>
|
|
2290 <para>
|
|
2291 In order to turn mixed progressive and telecine video into entirely
|
|
2292 progressive video, the telecined parts have to be
|
|
2293 inverse-telecined. There are three ways to accomplish this,
|
|
2294 described below. Note that you should
|
|
2295 <emphasis role="bold">always</emphasis> inverse-telecine before any
|
|
2296 rescaling; unless you really know what you are doing,
|
|
2297 inverse-telecine before cropping, too
|
|
2298 <link linkend="menc-feat-telecine-footnotes">[1]</link>.
|
|
2299 <option>-ofps 24000/1001</option> is needed here because the output video
|
|
2300 will be 24000/1001 frames per second.
|
|
2301 </para>
|
|
2302
|
|
2303 <itemizedlist>
|
|
2304 <listitem><para>
|
|
2305 <option>-vf pullup</option> is designed to inverse-telecine
|
|
2306 telecined material while leaving progressive data alone. In order to
|
|
2307 work properly, <option>pullup</option> <emphasis role="bold">must</emphasis>
|
|
2308 be followed by the <option>softskip</option> filter or
|
|
2309 else <application>MEncoder</application> will crash.
|
|
2310 <option>pullup</option> is, however, the cleanest and most
|
|
2311 accurate method available for encoding both telecine and
|
|
2312 "mixed progressive and telecine".
|
|
2313
|
|
2314 <screen>mencoder dvd://1 -oac copy -vf pullup,softskip -ovc lavc -ofps 24000/1001</screen>
|
|
2315 </para>
|
|
2316
|
|
2317
|
|
2318 </listitem>
|
|
2319 <listitem><para>
|
|
2320 An older method
|
|
2321 is to, rather than inverse-telecine the telecined parts, telecine
|
|
2322 the non-telecined parts and then inverse-telecine the whole
|
|
2323 video. Sound confusing? softpulldown is a filter that goes through
|
|
2324 a video and makes the entire file telecined. If we follow
|
|
2325 softpulldown with either <option>detc</option> or
|
|
2326 <option>ivtc</option>, the final result will be entirely
|
|
2327 progressive. <option>-ofps 24000/1001</option> is needed.
|
|
2328
|
|
2329 <screen>mencoder dvd://1 -oac copy -vf softpulldown,ivtc=1 -ovc lavc -ofps 24000/1001</screen>
|
|
2330 </para>
|
|
2331 </listitem>
|
|
2332
|
|
2333 <listitem><para>
|
|
2334 I have not used <option>-vf filmdint</option> myself, but here is what
|
|
2335 D Richard Felker III has to say:
|
|
2336
|
|
2337 <blockquote><para>It is OK, but IMO it tries to deinterlace rather
|
|
2338 than doing inverse telecine too often (much like settop DVD
|
|
2339 players & progressive TVs) which gives ugly flickering and
|
|
2340 other artifacts. If you are going to use it, you at least need to
|
|
2341 spend some time tuning the options and watching the output first
|
|
2342 to make sure it is not messing up.</para></blockquote>
|
|
2343 </para></listitem>
|
|
2344 </itemizedlist>
|
|
2345 </sect3>
|
|
2346
|
|
2347 <sect3 id="menc-feat-telecine-encode-mixedpi">
|
|
2348 <title>Mixed progressive and interlaced</title>
|
|
2349 <para>
|
|
2350 There are two options for dealing with this category, each of
|
|
2351 which is a compromise. You should decide based on the
|
|
2352 duration/location of each type.
|
|
2353 </para>
|
|
2354
|
|
2355 <itemizedlist>
|
|
2356 <listitem><para>
|
|
2357 Treat it as progressive. The interlaced parts will look interlaced,
|
|
2358 and some of the interlaced fields will have to be dropped, resulting
|
|
2359 in a bit of uneven jumpiness. You can use a postprocessing filter if
|
|
2360 you want to, but it may slightly degrade the progressive parts.
|
|
2361 </para>
|
|
2362
|
|
2363 <para>
|
|
2364 This option should definitely not be used if you want to eventually
|
|
2365 display the video on an interlaced device (with a TV card, for
|
|
2366 example). If you have interlaced frames in a 24000/1001 frames per
|
|
2367 second video, they will be telecined along with the progressive
|
|
2368 frames. Half of the interlaced "frames" will be displayed for three
|
|
2369 fields' duration (3/(60000/1001) seconds), resulting in a flicking
|
|
2370 "jump back in time" effect that looks quite bad. If you
|
|
2371 even attempt this, you <emphasis role="bold">must</emphasis> use a
|
|
2372 deinterlacing filter like <option>lb</option> or
|
|
2373 <option>l5</option>.
|
|
2374 </para>
|
|
2375
|
|
2376 <para>
|
|
2377 It may also be a bad idea for progressive display, too. It will drop
|
|
2378 pairs of consecutive interlaced fields, resulting in a discontinuity
|
|
2379 that can be more visible than with the second method, which shows
|
|
2380 some progressive frames twice. 30000/1001 frames per second interlaced
|
|
2381 video is already a bit choppy because it really should be shown at
|
|
2382 60000/1001 fields per second, so the duplicate frames do not stand out as
|
|
2383 much.
|
|
2384 </para>
|
|
2385
|
|
2386 <para>
|
|
2387 Either way, it is best to consider your content and how you intend to
|
|
2388 display it. If your video is 90% progressive and you never intend to
|
|
2389 show it on a TV, you should favor a progressive approach. If it is
|
|
2390 only half progressive, you probably want to encode it as if it is all
|
|
2391 interlaced.
|
|
2392 </para>
|
|
2393 </listitem>
|
|
2394
|
|
2395 <listitem><para>
|
|
2396 Treat it as interlaced. Some frames of the progressive parts will
|
|
2397 need to be duplicated, resulting in uneven jumpiness. Again,
|
|
2398 deinterlacing filters may slightly degrade the progressive parts.
|
|
2399 </para></listitem>
|
|
2400
|
|
2401 </itemizedlist>
|
|
2402 </sect3>
|
|
2403
|
|
2404 </sect2>
|
|
2405
|
|
2406 <sect2 id="menc-feat-telecine-footnotes">
|
|
2407 <title>Footnotes</title>
|
|
2408 <orderedlist>
|
|
2409 <listitem><formalpara>
|
|
2410 <title>About cropping:</title>
|
|
2411 <para>
|
|
2412 Video data on DVDs are stored in a format called YUV 4:2:0. In YUV
|
|
2413 video, luma ("brightness") and chroma ("color")
|
|
2414 are stored separately. Because the human eye is somewhat less
|
|
2415 sensitive to color than it is to brightness, in a YUV 4:2:0 picture
|
|
2416 there is only one chroma pixel for every four luma pixels. In a
|
|
2417 progressive picture, each square of four luma pixels (two on each
|
|
2418 side) has one common chroma pixel. You must crop progressive YUV
|
|
2419 4:2:0 to even resolutions, and use even offsets. For example,
|
|
2420 <option>crop=716:380:2:26</option> is OK but
|
|
2421 <option>crop=716:380:3:26 </option> is not.
|
|
2422 </para>
|
|
2423 </formalpara>
|
|
2424
|
|
2425 <para>
|
|
2426 When you are dealing with interlaced YUV 4:2:0, the situation is a
|
|
2427 bit more complicated. Instead of every four luma pixels in the
|
|
2428 <emphasis>frame</emphasis> sharing a chroma pixel, every four luma
|
|
2429 pixels in each <emphasis> field</emphasis> share a chroma
|
|
2430 pixel. When fields are interlaced to form a frame, each scanline is
|
|
2431 one pixel high. Now, instead of all four luma pixels being in a
|
|
2432 square, there are two pixels side-by-side, and the other two pixels
|
|
2433 are side-by-side two scanlines down. The two luma pixels in the
|
|
2434 intermediate scanline are from the other field, and so share a
|
|
2435 different chroma pixel with two luma pixels two scanlines away. All
|
|
2436 this confusion makes it necessary to have vertical crop dimensions
|
|
2437 and offsets be multiples of four. Horizontal can stay even.
|
|
2438 </para>
|
|
2439
|
|
2440 <para>
|
|
2441 For telecined video, I recommend that cropping take place after
|
|
2442 inverse telecining. Once the video is progressive you only need to
|
|
2443 crop by even numbers. If you really want to gain the slight speedup
|
|
2444 that cropping first may offer, you must crop vertically by multiples
|
|
2445 of four or else the inverse-telecine filter will not have proper data.
|
|
2446 </para>
|
|
2447
|
|
2448 <para>
|
|
2449 For interlaced (not telecined) video, you must always crop
|
|
2450 vertically by multiples of four unless you use <option>-vf
|
|
2451 field</option> before cropping.
|
|
2452 </para>
|
|
2453 </listitem>
|
|
2454
|
|
2455 <listitem><formalpara>
|
|
2456 <title>About encoding parameters and quality:</title>
|
|
2457 <para>
|
|
2458 Just because I recommend <option>mbd=2</option> here does not mean it
|
|
2459 should not be used elsewhere. Along with <option>trell</option>,
|
|
2460 <option>mbd=2</option> is one of the two
|
|
2461 <systemitem class="library">libavcodec</systemitem> options that
|
|
2462 increases quality the most, and you should always use at least those
|
|
2463 two unless the drop in encoding speed is prohibitive (e.g. realtime
|
|
2464 encoding). There are many other options to
|
|
2465 <systemitem class="library">libavcodec</systemitem> that increase
|
|
2466 encoding quality (and decrease encoding speed) but that is beyond
|
|
2467 the scope of this document.
|
|
2468 </para>
|
|
2469 </formalpara>
|
|
2470 </listitem>
|
|
2471
|
|
2472 <listitem><formalpara>
|
|
2473 <title>About the performance of pullup:</title>
|
|
2474 <para>
|
|
2475 It is safe to use <option>pullup</option> (along with <option>softskip
|
|
2476 </option>) on progressive video, and is usually a good idea unless
|
|
2477 the source has been definitively verified to be entirely progressive.
|
|
2478 The performace loss is small for most cases. On a bare-minimum encode,
|
|
2479 <option>pullup</option> causes <application>MEncoder</application> to
|
|
2480 be 50% slower. Adding sound processing and advanced <option>lavcopts
|
|
2481 </option> overshadows that difference, bringing the performance
|
|
2482 decrease of using <option>pullup</option> down to 2%.
|
|
2483 </para>
|
|
2484 </formalpara>
|
|
2485 </listitem>
|
|
2486
|
|
2487 </orderedlist>
|
|
2488
|
|
2489 </sect2>
|
|
2490
|
|
2491 </sect1>
|
|
2492
|
|
2493
|
|
2494 <sect1 id="menc-feat-enc-libavcodec">
|
|
2495 <title>Encoding with the <systemitem class="library">libavcodec</systemitem>
|
|
2496 codec family</title>
|
|
2497
|
|
2498 <para>
|
|
2499 <link linkend="ffmpeg"><systemitem class="library">libavcodec</systemitem></link>
|
|
2500 provides simple encoding to a lot of interesting video and audio formats.
|
|
2501 You can encode to the following codecs (more or less up to date):
|
|
2502 </para>
|
|
2503
|
|
2504 <sect2 id="menc-feat-enc-libavcodec-video-codecs">
|
|
2505 <title><systemitem class="library">libavcodec</systemitem>'s video codecs</title>
|
|
2506
|
|
2507 <para>
|
|
2508 <informaltable frame="all">
|
|
2509 <tgroup cols="2">
|
|
2510 <thead>
|
|
2511 <row><entry>Video codec name</entry><entry>Description</entry></row>
|
|
2512 </thead>
|
|
2513 <tbody>
|
|
2514 <row><entry>mjpeg</entry><entry>
|
|
2515 Motion JPEG
|
|
2516 </entry></row>
|
|
2517 <row><entry>ljpeg</entry><entry>
|
|
2518 lossless JPEG
|
|
2519 </entry></row>
|
|
2520 <row><entry>h261</entry><entry>
|
|
2521 H.261
|
|
2522 </entry></row>
|
|
2523 <row><entry>h263</entry><entry>
|
|
2524 H.263
|
|
2525 </entry></row>
|
|
2526 <row><entry>h263p</entry><entry>
|
|
2527 H.263+
|
|
2528 </entry></row>
|
|
2529 <row><entry>mpeg4</entry><entry>
|
|
2530 ISO standard MPEG-4 (DivX, XviD compatible)
|
|
2531 </entry></row>
|
|
2532 <row><entry>msmpeg4</entry><entry>
|
|
2533 pre-standard MPEG-4 variant by MS, v3 (AKA DivX3)
|
|
2534 </entry></row>
|
|
2535 <row><entry>msmpeg4v2</entry><entry>
|
|
2536 pre-standard MPEG-4 by MS, v2 (used in old ASF files)
|
|
2537 </entry></row>
|
|
2538 <row><entry>wmv1</entry><entry>
|
|
2539 Windows Media Video, version 1 (AKA WMV7)
|
|
2540 </entry></row>
|
|
2541 <row><entry>wmv2</entry><entry>
|
|
2542 Windows Media Video, version 2 (AKA WMV8)
|
|
2543 </entry></row>
|
|
2544 <row><entry>rv10</entry><entry>
|
|
2545 RealVideo 1.0
|
|
2546 </entry></row>
|
|
2547 <row><entry>rv20</entry><entry>
|
|
2548 RealVideo 2.0
|
|
2549 </entry></row>
|
|
2550 <row><entry>mpeg1video</entry><entry>
|
|
2551 MPEG-1 video
|
|
2552 </entry></row>
|
|
2553 <row><entry>mpeg2video</entry><entry>
|
|
2554 MPEG-2 video
|
|
2555 </entry></row>
|
|
2556 <row><entry>huffyuv</entry><entry>
|
|
2557 lossless compression
|
|
2558 </entry></row>
|
|
2559 <row><entry>asv1</entry><entry>
|
|
2560 ASUS Video v1
|
|
2561 </entry></row>
|
|
2562 <row><entry>asv2</entry><entry>
|
|
2563 ASUS Video v2
|
|
2564 </entry></row>
|
|
2565 <row><entry>ffv1</entry><entry>
|
|
2566 FFmpeg's lossless video codec
|
|
2567 </entry></row>
|
|
2568 <row><entry>svq1</entry><entry>
|
|
2569 Sorenson video 1
|
|
2570 </entry></row>
|
|
2571 <row><entry>flv</entry><entry>
|
|
2572 Sorenson H.263 used in Flash Video
|
|
2573 </entry></row>
|
|
2574 <row><entry>dvvideo</entry><entry>
|
|
2575 Sony Digital Video
|
|
2576 </entry></row>
|
|
2577 <row><entry>snow</entry><entry>
|
|
2578 FFmpeg's experimental wavelet-based codec
|
|
2579 </entry></row>
|
|
2580 </tbody>
|
|
2581 </tgroup>
|
|
2582 </informaltable>
|
|
2583
|
|
2584 The first column contains the codec names that should be passed after the
|
|
2585 <literal>vcodec</literal> config, like: <option>-lavcopts vcodec=msmpeg4</option>
|
|
2586 </para>
|
|
2587 <informalexample>
|
|
2588 <para>
|
|
2589 An example with MJPEG compression:
|
|
2590 <screen>mencoder dvd://2 -o title2.avi -ovc lavc -lavcopts vcodec=mjpeg -oac copy</screen>
|
|
2591 </para>
|
|
2592 </informalexample>
|
|
2593 </sect2>
|
|
2594
|
|
2595 <sect2 id="menc-feat-enc-libavcodec-audio-codecs">
|
|
2596 <title><systemitem class="library">libavcodec</systemitem>'s audio codecs</title>
|
|
2597 <para>
|
|
2598 <informaltable frame="all">
|
|
2599 <tgroup cols="2">
|
|
2600 <thead>
|
|
2601 <row><entry>Audio codec name</entry><entry>Description</entry></row>
|
|
2602 </thead>
|
|
2603 <tbody>
|
|
2604 <row>
|
|
2605 <entry>mp2</entry>
|
|
2606 <entry>MPEG Layer 2</entry>
|
|
2607 </row>
|
|
2608 <row>
|
|
2609 <entry>ac3</entry>
|
|
2610 <entry>AC3, AKA Dolby Digital</entry>
|
|
2611 </row>
|
|
2612 <row>
|
|
2613 <entry>adpcm_ima_wav</entry>
|
|
2614 <entry>IMA adaptive PCM (4 bits per sample, 4:1 compression)</entry>
|
|
2615 </row>
|
|
2616 <row>
|
|
2617 <entry>sonic</entry>
|
|
2618 <entry>experimental lossy/lossless codec</entry>
|
|
2619 </row>
|
|
2620 </tbody>
|
|
2621 </tgroup>
|
|
2622 </informaltable>
|
|
2623
|
|
2624 The first column contains the codec names that should be passed after the
|
|
2625 <literal>acodec</literal> option, like: <option>-lavcopts acodec=ac3</option>
|
|
2626 </para>
|
|
2627
|
|
2628 <informalexample>
|
|
2629 <para>
|
|
2630 An example with AC3 compression:
|
|
2631 <screen>mencoder dvd://2 -o title2.avi -oac lavc -lavcopts acodec=ac3 -ovc copy</screen>
|
|
2632 </para>
|
|
2633 </informalexample>
|
|
2634
|
|
2635 <para>
|
|
2636 Contrary to <systemitem class="library">libavcodec</systemitem>'s video
|
|
2637 codecs, its audio codecs do not make a wise usage of the bits they are
|
|
2638 given as they lack some minimal psychoacoustic model (if at all)
|
|
2639 which most other codec implementations feature.
|
|
2640 However, note that all these audio codecs are very fast and work
|
|
2641 out-of-the-box everywhere <application>MEncoder</application> has been
|
|
2642 compiled with <systemitem class="library">libavcodec</systemitem> (which
|
|
2643 is the case most of time), and do not depend on external libraries.
|
|
2644 </para>
|
|
2645 </sect2>
|
|
2646
|
|
2647
|
|
2648 <sect2 id="menc-feat-dvd-mpeg4-lavc-encoding-options">
|
|
2649 <title>Encoding options of libavcodec</title>
|
|
2650
|
|
2651 <para>
|
|
2652 Ideally, you would probably want to be able to just tell the encoder to switch
|
|
2653 into "high quality" mode and move on.
|
|
2654 That would probably be nice, but unfortunately hard to implement as different
|
|
2655 encoding options yield different quality results depending on the source material.
|
|
2656 That is because compression depends on the visual properties of the video
|
|
2657 in question.
|
|
2658 For example, anime and live action have very different properties and
|
|
2659 thus require different options to obtain optimum encoding.
|
|
2660 The good news is that some options should never be left out, like
|
|
2661 <option>mbd=2</option>, <option>trell</option>, and <option>v4mv</option>.
|
|
2662 See below for a detailed description of common encoding options.
|
|
2663 </para>
|
|
2664
|
|
2665
|
|
2666 <itemizedlist>
|
|
2667 <title>Options to adjust:</title>
|
|
2668 <listitem><para>
|
|
2669 <emphasis role="bold">vmax_b_frames</emphasis>: 1 or 2 is good, depending on
|
|
2670 the movie.
|
|
2671 Note that if you need to have your encode be decodable by DivX5, you
|
|
2672 need to activate closed GOP support, using
|
|
2673 <systemitem class="library">libavcodec</systemitem>'s <option>cgop</option>
|
|
2674 option, but you need to deactivate scene detection, which
|
|
2675 is not a good idea as it will hurt encode efficiency a bit.
|
|
2676 </para></listitem>
|
|
2677
|
|
2678 <listitem><para>
|
|
2679 <emphasis role="bold">vb_strategy=1</emphasis>: helps in high-motion scenes.
|
|
2680 On some videos, vmax_b_frames may hurt quality, but vmax_b_frames=2 along
|
|
2681 with vb_strategy=1 helps.
|
|
2682 </para></listitem>
|
|
2683
|
|
2684 <listitem><para>
|
|
2685 <emphasis role="bold">dia</emphasis>: motion search range. Bigger is better
|
|
2686 and slower.
|
|
2687 Negative values are a completely different scale.
|
|
2688 Good values are -1 for a fast encode, or 2-4 for slower.
|
|
2689 </para></listitem>
|
|
2690
|
|
2691 <listitem><para>
|
|
2692 <emphasis role="bold">predia</emphasis>: motion search pre-pass.
|
|
2693 Not as important as dia. Good values are 1 (default) to 4. Requires preme=2
|
|
2694 to really be useful.
|
|
2695 </para></listitem>
|
|
2696
|
|
2697 <listitem><para>
|
|
2698 <emphasis role="bold">cmp, subcmp, precmp</emphasis>: Comparison function for
|
|
2699 motion estimation.
|
|
2700 Experiment with values of 0 (default), 2 (hadamard), 3 (dct), and 6 (rate
|
|
2701 distortion).
|
|
2702 0 is fastest, and sufficient for precmp.
|
|
2703 For cmp and subcmp, 2 is good for anime, and 3 is good for live action.
|
|
2704 6 may or may not be slightly better, but is slow.
|
|
2705 </para></listitem>
|
|
2706
|
|
2707 <listitem><para>
|
|
2708 <emphasis role="bold">last_pred</emphasis>: Number of motion predictors to
|
|
2709 take from the previous frame.
|
|
2710 1-3 or so help at little speed cost.
|
|
2711 Higher values are slow for no extra gain.
|
|
2712 </para></listitem>
|
|
2713
|
|
2714 <listitem><para>
|
|
2715 <emphasis role="bold">cbp, mv0</emphasis>: Controls the selection of macroblocks.
|
|
2716 Small speed cost for small quality gain.
|
|
2717 </para></listitem>
|
|
2718
|
|
2719 <listitem><para>
|
|
2720 <emphasis role="bold">qprd</emphasis>: adaptive quantization based on the
|
|
2721 macroblock's complexity.
|
|
2722 May help or hurt depending on the video and other options.
|
|
2723 This can cause artifacts unless you set vqmax to some reasonably small value
|
|
2724 (6 is good, maybe as low as 4); vqmin=1 should also help.
|
|
2725 </para></listitem>
|
|
2726
|
|
2727 <listitem><para>
|
|
2728 <emphasis role="bold">qns</emphasis>: very slow, especially when combined
|
|
2729 with qprd.
|
|
2730 This option will make the encoder minimize noise due to compression
|
|
2731 artifacts instead of making the encoded video strictly match the source.
|
|
2732 Do not use this unless you have already tweaked everything else as far as it
|
|
2733 will go and the results still are not good enough.
|
|
2734 </para></listitem>
|
|
2735
|
|
2736 <listitem><para>
|
|
2737 <emphasis role="bold">vqcomp</emphasis>: Tweak ratecontrol.
|
|
2738 What values are good depends on the movie.
|
|
2739 You can safely leave this alone if you want.
|
|
2740 Reducing vqcomp puts more bits on low-complexity scenes, increasing it puts
|
|
2741 them on high-complexity scenes (default: 0.5, range: 0-1. recommended range:
|
|
2742 0.5-0.7).
|
|
2743 </para></listitem>
|
|
2744
|
|
2745 <listitem><para>
|
|
2746 <emphasis role="bold">vlelim, vcelim</emphasis>: Sets the single coefficient
|
|
2747 elimination threshold for luminance and chroma planes.
|
|
2748 These are encoded separately in all MPEG-like algorithms.
|
|
2749 The idea behind these options is to use some good heuristics to determine
|
|
2750 when the change in a block is less than the threshold you specify, and in
|
|
2751 such a case, to just encode the block as "no change".
|
|
2752 This saves bits and perhaps speeds up encoding. vlelim=-4 and vcelim=9
|
|
2753 seem to be good for live movies, but seem not to help with anime;
|
|
2754 when encoding animation, you should probably leave them unchanged.
|
|
2755 </para></listitem>
|
|
2756
|
|
2757 <listitem><para>
|
|
2758 <emphasis role="bold">qpel</emphasis>: Quarter pixel motion estimation.
|
|
2759 MPEG-4 uses half pixel precision for its motion search by default,
|
|
2760 therefore this option comes with an overhead as more information will be
|
|
2761 stored in the encoded file.
|
|
2762 The compression gain/loss depends on the movie, but it is usually not very
|
|
2763 effective on anime.
|
|
2764 qpel always incurs a significant cost in CPU decode time (+25% in
|
|
2765 practice).
|
|
2766 </para></listitem>
|
|
2767
|
|
2768 <listitem><para>
|
|
2769 <emphasis role="bold">psnr</emphasis>: does not affect the actual encoding,
|
|
2770 but writes a log file giving the type/size/quality of each frame, and
|
|
2771 prints a summary of PSNR (Peak Signal to Noise Ratio) at the end.
|
|
2772 </para></listitem>
|
|
2773
|
|
2774 </itemizedlist>
|
|
2775
|
|
2776 <itemizedlist>
|
|
2777 <title>Options not recommended to play with:</title>
|
|
2778 <listitem><para>
|
|
2779 <emphasis role="bold">vme</emphasis>: The default is best.
|
|
2780 </para></listitem>
|
|
2781
|
|
2782 <listitem><para>
|
|
2783 <emphasis role="bold">lumi_mask, dark_mask</emphasis>: Psychovisual adaptive
|
|
2784 quantization.
|
|
2785 You do not want to play with those options if you care about quality.
|
|
2786 Reasonable values may be effective in your case, but be warned this is very
|
|
2787 subjective.
|
|
2788 </para></listitem>
|
|
2789
|
|
2790 <listitem><para>
|
|
2791 <emphasis role="bold">scplx_mask</emphasis>: Tries to prevent blocky
|
|
2792 artifacts, but postprocessing is better.
|
|
2793 </para></listitem>
|
|
2794 </itemizedlist>
|
|
2795 </sect2>
|
|
2796
|
|
2797 <sect2 id="menc-feat-mpeg4-lavc-example-settings">
|
|
2798 <title>Encoding setting examples</title>
|
|
2799
|
|
2800 <para>
|
|
2801 The following settings are examples of different encoding
|
|
2802 option combinations that affect the speed vs quality tradeoff
|
|
2803 at the same target bitrate.
|
|
2804 </para>
|
|
2805
|
|
2806 <para>
|
|
2807 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
2808 video sample, the target bitrate was 900kbps, and the machine was an
|
|
2809 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
2810 Each encoding setting features the measured encoding speed (in
|
|
2811 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
2812 high quality" setting.
|
|
2813 Please understand that depending on your source, your machine type
|
|
2814 and development advancements, you may get very different results.
|
|
2815 </para>
|
|
2816
|
|
2817 <para>
|
|
2818 <informaltable frame="all">
|
|
2819 <tgroup cols="4">
|
|
2820 <thead>
|
|
2821 <row><entry>Description</entry><entry>Encoding options</entry><entry>speed (in fps)</entry><entry>Relative PSNR loss (in dB)</entry></row>
|
|
2822 </thead>
|
|
2823 <tbody>
|
|
2824 <row>
|
|
2825 <entry>Very high quality</entry>
|
|
2826 <entry><option>vcodec=mpeg4:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=2:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2</option></entry>
|
|
2827 <entry>6fps</entry>
|
|
2828 <entry>0dB</entry>
|
|
2829 </row>
|
|
2830 <row>
|
|
2831 <entry>High quality</entry>
|
|
2832 <entry><option>vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:turbo</option></entry>
|
|
2833 <entry>15fps</entry>
|
|
2834 <entry>-0.5dB</entry>
|
|
2835 </row>
|
|
2836 <row>
|
|
2837 <entry>Fast</entry>
|
|
2838 <entry><option>vcodec=mpeg4:mbd=2:trell:v4mv:turbo</option></entry>
|
|
2839 <entry>42fps</entry>
|
|
2840 <entry>-0.74dB</entry>
|
|
2841 </row>
|
|
2842 <row>
|
|
2843 <entry>Realtime</entry>
|
|
2844 <entry><option>vcodec=mpeg4:mbd=2:turbo</option></entry>
|
|
2845 <entry>54fps</entry>
|
|
2846 <entry>-1.21dB</entry>
|
|
2847 </row>
|
|
2848 </tbody>
|
|
2849 </tgroup>
|
|
2850 </informaltable>
|
|
2851 </para>
|
|
2852 </sect2>
|
|
2853
|
|
2854 <sect2 id="custommatrices"><title>Custom inter/intra matrices</title>
|
|
2855
|
|
2856 <para>
|
|
2857 With this feature of
|
|
2858 <link linkend="ffmpeg"><systemitem class="library">libavcodec</systemitem></link>
|
|
2859 you are able to set custom inter (I-frames/keyframes) and intra
|
|
2860 (P-frames/predicted frames) matrices. It is supported by many of the codecs:
|
|
2861 <systemitem>mpeg1video</systemitem> and <systemitem>mpeg2video</systemitem>
|
|
2862 are reported as working.
|
|
2863 </para>
|
|
2864
|
|
2865 <para>
|
|
2866 A typical usage of this feature is to set the matrices preferred by the
|
|
2867 <ulink url="http://www.kvcd.net/">KVCD</ulink> specifications.
|
|
2868 </para>
|
|
2869
|
|
2870 <para>
|
|
2871 The <emphasis role="bold">KVCD "Notch" Quantization Matrix:</emphasis>
|
|
2872 </para>
|
|
2873
|
|
2874 <para>
|
|
2875 Intra:
|
|
2876 <screen>
|
|
2877 8 9 12 22 26 27 29 34
|
|
2878 9 10 14 26 27 29 34 37
|
|
2879 12 14 18 27 29 34 37 38
|
|
2880 22 26 27 31 36 37 38 40
|
|
2881 26 27 29 36 39 38 40 48
|
|
2882 27 29 34 37 38 40 48 58
|
|
2883 29 34 37 38 40 48 58 69
|
|
2884 34 37 38 40 48 58 69 79
|
|
2885 </screen>
|
|
2886
|
|
2887 Inter:
|
|
2888 <screen>
|
|
2889 16 18 20 22 24 26 28 30
|
|
2890 18 20 22 24 26 28 30 32
|
|
2891 20 22 24 26 28 30 32 34
|
|
2892 22 24 26 30 32 32 34 36
|
|
2893 24 26 28 32 34 34 36 38
|
|
2894 26 28 30 32 34 36 38 40
|
|
2895 28 30 32 34 36 38 42 42
|
|
2896 30 32 34 36 38 40 42 44
|
|
2897 </screen>
|
|
2898 </para>
|
|
2899
|
|
2900 <para>
|
|
2901 Usage:
|
|
2902 <screen>
|
|
2903 $ mencoder <replaceable>input.avi</replaceable> -o <replaceable>output.avi</replaceable> -oac copy -ovc lavc -lavcopts inter_matrix=...:intra_matrix=...
|
|
2904 </screen>
|
|
2905 </para>
|
|
2906
|
|
2907 <para>
|
|
2908 <screen>
|
|
2909 $ mencoder <replaceable>input.avi</replaceable> -ovc lavc -lavcopts
|
|
2910 vcodec=mpeg2video:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,
|
|
2911 12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29,36,39,38,40,48,27,
|
|
2912 29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79
|
|
2913 :inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,
|
|
2914 28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,36,38,26,28,30,32,34,
|
|
2915 36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 -oac copy -o svcd.mpg
|
|
2916 </screen>
|
|
2917 </para>
|
|
2918 </sect2>
|
|
2919
|
|
2920
|
|
2921 <sect2 id="menc-feat-dvd-mpeg4-example">
|
|
2922 <title>Example</title>
|
|
2923
|
|
2924 <para>
|
|
2925 So, you have just bought your shiny new copy of Harry Potter and the Chamber
|
|
2926 of Secrets (widescreen edition, of course), and you want to rip this DVD
|
|
2927 so that you can add it to your Home Theatre PC. This is a region 1 DVD,
|
|
2928 so it is NTSC. The example below will still apply to PAL, except you will
|
|
2929 omit <option>-ofps 24000/1001</option> (because the output framerate is the
|
|
2930 same as the input framerate), and of course the crop dimensions will be
|
|
2931 different.
|
|
2932 </para>
|
|
2933
|
|
2934 <para>
|
|
2935 After running <option>mplayer dvd://1</option>, we follow the process
|
|
2936 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
2937 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
2938 24000/1001 fps progressive video, which means that we need not use an inverse
|
|
2939 telecine filter, such as <option>pullup</option> or
|
|
2940 <option>filmdint</option>.
|
|
2941 </para>
|
|
2942
|
|
2943 <para>
|
|
2944 Next, we want to determine the appropriate crop rectangle, so we use the
|
|
2945 cropdetect filter:
|
|
2946
|
|
2947 <screen>mplayer dvd://1 -vf cropdetect</screen>
|
|
2948
|
|
2949 Make sure you seek to a fully filled frame (such as a bright scene), and
|
|
2950 you will see in <application>MPlayer</application>'s console output:
|
|
2951
|
|
2952 <screen>crop area: X: 0..719 Y: 57..419 (-vf crop=720:362:0:58)</screen>
|
|
2953
|
|
2954 We then play the movie back with this filter to test its correctness:
|
|
2955
|
|
2956 <screen>mplayer dvd://1 -vf crop=720:362:0:58</screen>
|
|
2957
|
|
2958 And we see that it looks perfectly fine. Next, we ensure the width and
|
|
2959 height are a multiple of 16. The width is fine, however the height is
|
|
2960 not. Since we did not fail 7th grade math, we know that the nearest
|
|
2961 multiple of 16 lower than 362 is 352.
|
|
2962 </para>
|
|
2963
|
|
2964 <para>
|
|
2965 We could just use <option>crop=720:352:0:58</option>, but it would be nice
|
|
2966 to take a little off the top and a little off the bottom so that we
|
|
2967 retain the center. We have shrunk the height by 10 pixels, but we do not
|
|
2968 want to increase the y-offset by 5-pixels since that is an odd number and
|
|
2969 will adversely affect quality. Instead, we will increase the y-offset by
|
|
2970 4 pixels:
|
|
2971
|
|
2972 <screen>mplayer dvd://1 -vf crop=720:352:0:62</screen>
|
|
2973
|
|
2974 Another reason to shave pixels from both the top and the bottom is that we
|
|
2975 ensure we have eliminated any half-black pixels if they exist. Note that if
|
|
2976 your video is telecined, make sure the <option>pullup</option> filter (or
|
|
2977 whichever inverse telecine filter you decide to use) appears in the filter
|
|
2978 chain before you crop. If it is interlaced, deinterlace before cropping.
|
|
2979 (If you choose to preserve the interlaced video, then make sure your
|
|
2980 vertical crop offset is a multiple of 4.)
|
|
2981 </para>
|
|
2982
|
|
2983 <para>
|
|
2984 If you are really concerned about losing those 10 pixels, you might
|
|
2985 prefer instead to scale the dimensions down to the nearest multiple of 16.
|
|
2986 The filter chain would look like:
|
|
2987
|
|
2988 <screen>-vf crop=720:362:0:58,scale=720:352</screen>
|
|
2989
|
|
2990 Scaling the video down like this will mean that some small amount of
|
|
2991 detail is lost, though it probably will not be perceptible. Scaling up will
|
|
2992 result in lower quality (unless you increase the bitrate). Cropping
|
|
2993 discards those pixels altogether. It is a tradeoff that you will want to
|
|
2994 consider for each circumstance. For example, if the DVD video was made
|
|
2995 for television, you might want to avoid vertical scaling, since the line
|
|
2996 sampling corresponds to the way the content was originally recorded.
|
|
2997 </para>
|
|
2998
|
|
2999 <para>
|
|
3000 On inspection, we see that our movie has a fair bit of action and high
|
|
3001 amounts of detail, so we pick 2400Kbit for our bitrate.
|
|
3002 </para>
|
|
3003
|
|
3004 <para>
|
|
3005 We are now ready to do the two pass encode. Pass one:
|
|
3006
|
|
3007 <screen>mencoder dvd://1 -ofps 24000/1001 -oac copy -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2 -ovc lavc \
|
|
3008 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:mbcmp=3:autoaspect:vpass=1 \
|
|
3009 -o Harry_Potter_2.avi</screen>
|
|
3010
|
|
3011 And pass two is the same, except that we specify <option>vpass=2</option>:
|
|
3012
|
|
3013 <screen>mencoder dvd://1 -ofps 24000/1001 -oac copy -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2 -ovc lavc \
|
|
3014 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:mbcmp=3:autoaspect:vpass=2 \
|
|
3015 -o Harry_Potter_2.avi</screen>
|
|
3016 </para>
|
|
3017
|
|
3018 <para>
|
|
3019 The options <option>v4mv:mbd=2:trell</option> will greatly increase the
|
|
3020 quality at the expense of encoding time. There is little reason to leave
|
|
3021 these options out when the primary goal is quality. The options
|
|
3022 <option>cmp=3:subcmp=3:mbcmp=3</option> select a comparison function that
|
|
3023 yields higher quality than the defaults. You might try experimenting with
|
|
3024 this parameter (refer to the man page for the possible values) as
|
|
3025 different functions can have a large impact on quality depending on the
|
|
3026 source material. For example, if you find
|
|
3027 <systemitem class="library">libavcodec</systemitem> produces too much
|
|
3028 blocky artifacting, you could try selecting the experimental NSSE as
|
|
3029 comparison function via <option>*cmp=10</option>.
|
|
3030 </para>
|
|
3031
|
|
3032 <para>
|
|
3033 For this movie, the resulting AVI will be 138 minutes long and nearly
|
|
3034 3GB. And because you said that file size does not matter, this is a
|
|
3035 perfectly acceptable size. However, if you had wanted it smaller, you
|
|
3036 could try a lower bitrate. Increasing bitrates have diminishing
|
|
3037 returns, so while we might clearly see an improvement from 1800Kbit to
|
|
3038 2000Kbit, it might not be so noticeable above 2000Kbit. Feel
|
|
3039 free to experiment until you are happy.
|
|
3040 </para>
|
|
3041
|
|
3042 <para>
|
|
3043 Because we passed the source video through a denoise filter, you may want
|
|
3044 to add some of it back during playback. This, along with the
|
|
3045 <option>spp</option> post-processing filter, drastically improves the
|
|
3046 perception of quality and helps eliminate blocky artifacts in the video.
|
|
3047 With <application>MPlayer</application>'s <option>autoq</option> option,
|
|
3048 you can vary the amount of post-processing done by the spp filter
|
|
3049 depending on available CPU. Also, at this point, you may want to apply
|
|
3050 gamma and/or color correction to best suit your display. For example:
|
|
3051
|
|
3052 <screen>mplayer Harry_Potter_2.avi -vf spp,noise=9ah:5ah,eq2=1.2 -autoq 3</screen>
|
|
3053
|
|
3054 </para>
|
|
3055 </sect2>
|
|
3056 </sect1>
|
|
3057
|
|
3058
|
|
3059 <sect1 id="menc-feat-xvid">
|
|
3060 <title>Encoding with the <systemitem class="library">XviD</systemitem>
|
|
3061 codec</title>
|
|
3062 <para>
|
|
3063 <systemitem class="library">XviD</systemitem> is a free library for
|
|
3064 encoding MPEG-4 ASP video streams.
|
|
3065 Before starting to encode, you need to <link linkend="xvid">
|
|
3066 set up <application>MEncoder</application> to support it</link>.
|
|
3067 </para>
|
|
3068 <para>
|
|
3069 This guide mainly aims at featuring the same kind of information
|
|
3070 as x264's encoding guide.
|
|
3071 Therefore, please begin by reading
|
|
3072 <link linkend="menc-feat-x264-encoding-options-intro">the first part</link>
|
|
3073 of that guide.
|
|
3074 </para>
|
|
3075
|
|
3076
|
|
3077 <sect2 id="menc-feat-xvid-intro">
|
|
3078 <title>What options should I use to get the best results?</title>
|
|
3079
|
|
3080 <para>
|
|
3081 Please begin by reviewing the
|
|
3082 <systemitem class="library">XviD</systemitem> section of
|
|
3083 <application>MPlayer</application>'s man page.
|
|
3084 This section is intended to be a supplement to the man page.
|
|
3085 </para>
|
|
3086 <para>
|
|
3087 The XviD default settings are already a good tradeoff between
|
|
3088 speed and quality, therefore you can safely stick to them if
|
|
3089 the following section puzzles you.
|
|
3090 </para>
|
|
3091 </sect2>
|
|
3092
|
|
3093 <sect2 id="menc-feat-xvid-encoding-options">
|
|
3094 <title>Encoding options of <systemitem class="library">XviD</systemitem></title>
|
|
3095
|
|
3096 <itemizedlist>
|
|
3097 <listitem><para>
|
|
3098 <emphasis role="bold">vhq</emphasis>
|
|
3099 This setting affects the macroblock decision algorithm, where the
|
|
3100 higher the setting, the wiser the decision.
|
|
3101 The default setting may be safely used for every encode, while
|
|
3102 higher settings always help PSNR but are significantly slower.
|
|
3103 Please note that a better PSNR does not necessarily mean
|
|
3104 that the picture will look better, but tells you that it is
|
|
3105 closer to the original.
|
|
3106 Turning it off will noticeably speed up encoding; if speed is
|
|
3107 critical for you, the tradeoff may be worth it.
|
|
3108 </para></listitem>
|
|
3109
|
|
3110 <listitem><para>
|
|
3111 <emphasis role="bold">bvhq</emphasis>
|
|
3112 This does the same job as vhq, but does it on B-frames.
|
|
3113 It has a negligible impact on speed, and slightly improves quality
|
|
3114 (around +0.1dB PSNR).
|
|
3115 </para></listitem>
|
|
3116
|
|
3117 <listitem><para>
|
|
3118 <emphasis role="bold">max_bframes</emphasis>
|
|
3119 A higher number of consecutive allowed B-frames usually improves
|
|
3120 compressibility, although it may also lead to more blocking artifacts.
|
|
3121 The default setting is a good tradeoff between compressibility and
|
|
3122 quality, but you may increase it up to 3 if you are bitrate-starved.
|
|
3123 You may also decrease it to 1 or 0 if you are aiming at perfect
|
|
3124 quality, though in that case you should make sure your
|
|
3125 target bitrate is high enough to ensure that the encoder does not
|
|
3126 have to increase quantizers to reach it.
|
|
3127 </para></listitem>
|
|
3128
|
|
3129 <listitem><para>
|
|
3130 <emphasis role="bold">bf_threshold</emphasis>
|
|
3131 This controls the B-frame sensitivity of the encoder, where a higher
|
|
3132 value leads to more B-frames being used (and vice versa).
|
|
3133 This setting is to be used together with <option>max_bframes</option>;
|
|
3134 if you are bitrate-starved, you should increase both
|
|
3135 <option>max_bframes</option> and <option>bf_threshold</option>,
|
|
3136 while you may increase <option>max_bframes</option> and reduce
|
|
3137 <option>bf_threshold</option> so that the encoder may use more
|
|
3138 B-frames in places that only <emphasis role="bold">really</emphasis>
|
|
3139 need them.
|
|
3140 A low number of <option>max_bframes</option> and a high value of
|
|
3141 <option>bf_threshold</option> is probably not a wise choice as it
|
|
3142 will force the encoder to put B-frames in places that would not
|
|
3143 benefit from them, therefore reducing visual quality.
|
|
3144 However, if you need to be compatible with standalone players that
|
|
3145 only support old DivX profiles (which only supports up to 1
|
|
3146 consecutive B-frame), this would be your only way to
|
|
3147 increase compressibility through using B-frames.
|
|
3148 </para></listitem>
|
|
3149
|
|
3150 <listitem><para>
|
|
3151 <emphasis role="bold">trellis</emphasis>
|
|
3152 Optimizes the quantization process to get an optimal tradeoff
|
|
3153 between PSNR and bitrate, which allows significant bit saving.
|
|
3154 These bits will in return be spent elsewhere on the video,
|
|
3155 raising overall visual quality.
|
|
3156 You should always leave it on as its impact on quality is huge.
|
|
3157 Even if you are looking for speed, do not disable it until you
|
|
3158 have turned down <option>vhq</option> and all other more
|
|
3159 CPU-hungry options to the minimum.
|
|
3160 </para></listitem>
|
|
3161
|
|
3162 <listitem><para>
|
|
3163 <emphasis role="bold">hq_ac</emphasis>
|
|
3164 Activates a better coefficient cost estimation method, which slightly
|
|
3165 reduces filesize by around 0.15 to 0.19% (which corresponds to less
|
|
3166 than 0.01dB PSNR increase), while having a negligible impact on speed.
|
|
3167 It is therefore recommended to always leave it on.
|
|
3168 </para></listitem>
|
|
3169
|
|
3170 <listitem><para>
|
|
3171 <emphasis role="bold">cartoon</emphasis>
|
|
3172 Designed to better encode cartoon content, and has no impact on
|
|
3173 speed as it just tunes the mode decision heuristics for this type
|
|
3174 of content.
|
|
3175 </para></listitem>
|
|
3176
|
|
3177 <listitem><para>
|
|
3178 <emphasis role="bold">me_quality</emphasis>
|
|
3179 This setting is to control the precision of the motion estimation.
|
|
3180 The higher <option>me_quality</option>, the more
|
|
3181 precise the estimation of the original motion will be, and the
|
|
3182 better the resulting clip will capture the original motion.
|
|
3183 </para>
|
|
3184 <para>
|
|
3185 The default setting is best in all cases;
|
|
3186 thus it is not recommended to turn it down unless you are
|
|
3187 really looking for speed, as all the bits saved by a good motion
|
|
3188 estimation would be spent elsewhere, raising overall quality.
|
|
3189 Therefore, do not go any lower than 5, and even that only as a last
|
|
3190 resort.
|
|
3191 </para></listitem>
|
|
3192
|
|
3193 <listitem><para>
|
|
3194 <emphasis role="bold">chroma_me</emphasis>
|
|
3195 Improves motion estimation by also taking the chroma (color)
|
|
3196 information into account, whereas <option>me_quality</option>
|
|
3197 alone only uses luma (grayscale).
|
|
3198 This slows down encoding by 5-10% but improves visual quality
|
|
3199 quite a bit by reducing blocking effects and reduces filesize by
|
|
3200 around 1.3%.
|
|
3201 If you are looking for speed, you should disable this option before
|
|
3202 starting to consider reducing <option>me_quality</option>.
|
|
3203 </para></listitem>
|
|
3204
|
|
3205 <listitem><para>
|
|
3206 <emphasis role="bold">chroma_opt</emphasis>
|
|
3207 Is intended to increase chroma image quality around pure
|
|
3208 white/black edges, rather than improving compression.
|
|
3209 This can help to reduce the "red stairs" effect.
|
|
3210 </para></listitem>
|
|
3211
|
|
3212 <listitem><para>
|
|
3213 <emphasis role="bold">lumi_mask</emphasis>
|
|
3214 Tries to give less bitrate to part of the picture that the
|
|
3215 human eye cannot see very well, which should allow the encoder
|
|
3216 to spend the saved bits on more important parts of the picture.
|
|
3217 The quality of the encode yielded by this option highly depends
|
|
3218 on personal preferences and on the type and monitor settings
|
|
3219 used to watch it (typically, it will not look as good if it is
|
|
3220 bright or if it is a TFT monitor).
|
|
3221 </para></listitem>
|
|
3222
|
|
3223 <listitem><para>
|
|
3224 <emphasis role="bold">qpel</emphasis>
|
|
3225 Raise the number of candidate motion vectors by increasing
|
|
3226 the precision of the motion estimation from halfpel to
|
|
3227 quarterpel.
|
|
3228 The idea is to find better motion vectors which will in return
|
|
3229 reduce bitrate (hence increasing quality).
|
|
3230 However, motion vectors with quarterpel precision require a
|
|
3231 few extra bits to code, but the candidate vectors do not always
|
|
3232 give (much) better results.
|
|
3233 Quite often, the codec still spends bits on the extra precision,
|
|
3234 but little or no extra quality is gained in return.
|
|
3235 Unfortunately, there is no way to foresee the possible gains of
|
|
3236 <option>qpel</option>, so you need to actually encode with and
|
|
3237 without it to know for sure.
|
|
3238 </para><para>
|
|
3239 <option>qpel</option> can be almost double encoding time, and
|
|
3240 requires as much as 25% more processing power to decode.
|
|
3241 It is not supported by all standalone players.
|
|
3242 </para></listitem>
|
|
3243
|
|
3244 <listitem><para>
|
|
3245 <emphasis role="bold">gmc</emphasis>
|
|
3246 Tries to save bits on panning scenes by using a single motion
|
|
3247 vector for the whole frame.
|
|
3248 This almost always raises PSNR, but significantly slows down
|
|
3249 encoding (as well as decoding).
|
|
3250 Therefore, you should only use it when you have turned
|
|
3251 <option>vhq</option> to the maximum.
|
|
3252 <systemitem class="library">XviD</systemitem>'s GMC is more
|
|
3253 sophisticated than DivX's, but is only supported by few
|
|
3254 standalone players.
|
|
3255 </para></listitem>
|
|
3256
|
|
3257 </itemizedlist>
|
|
3258 </sect2>
|
|
3259
|
|
3260 <sect2 id="menc-feat-xvid-encoding-profiles">
|
|
3261 <title>Encoding profiles</title>
|
|
3262 <para>
|
|
3263 XviD supports encoding profiles through the <option>profile</option> option,
|
|
3264 which are used to impose restrictions on the properties of the XviD video
|
|
3265 stream such that it will be playable on anything which supports the
|
|
3266 chosen profile.
|
|
3267 The restrictions relate to resolutions, bitrates and certain MPEG-4
|
|
3268 features.
|
|
3269 The following table shows what each profile supports.
|
|
3270 </para>
|
|
3271 <informaltable>
|
|
3272 <tgroup cols="16" align="center">
|
|
3273 <colspec colnum="1" colname="col1"/>
|
|
3274 <colspec colnum="2" colname="col2"/>
|
|
3275 <colspec colnum="3" colname="col3"/>
|
|
3276 <colspec colnum="4" colname="col4"/>
|
|
3277 <colspec colnum="5" colname="col5"/>
|
|
3278 <colspec colnum="6" colname="col6"/>
|
|
3279 <colspec colnum="7" colname="col7"/>
|
|
3280 <colspec colnum="8" colname="col8"/>
|
|
3281 <colspec colnum="9" colname="col9"/>
|
|
3282 <colspec colnum="10" colname="col10"/>
|
|
3283 <colspec colnum="11" colname="col11"/>
|
|
3284 <colspec colnum="12" colname="col12"/>
|
|
3285 <colspec colnum="13" colname="col13"/>
|
|
3286 <colspec colnum="14" colname="col14"/>
|
|
3287 <colspec colnum="15" colname="col15"/>
|
|
3288 <colspec colnum="16" colname="col16"/>
|
|
3289 <colspec colnum="17" colname="col17"/>
|
|
3290 <spanspec spanname="spa2-5" namest="col2" nameend="col5"/>
|
|
3291 <spanspec spanname="spa6-11" namest="col6" nameend="col11"/>
|
|
3292 <spanspec spanname="spa12-17" namest="col12" nameend="col17"/>
|
|
3293 <tbody>
|
|
3294 <row>
|
|
3295 <entry></entry>
|
|
3296 <entry spanname="spa2-5">Simple</entry>
|
|
3297 <entry spanname="spa6-11">Advanced Simple</entry>
|
|
3298 <entry spanname="spa12-17">DivX</entry>
|
|
3299 </row>
|
|
3300 <row>
|
|
3301 <entry>Profile name</entry>
|
|
3302 <entry>0</entry>
|
|
3303 <entry>1</entry>
|
|
3304 <entry>2</entry>
|
|
3305 <entry>3</entry>
|
|
3306 <entry>0</entry>
|
|
3307 <entry>1</entry>
|
|
3308 <entry>2</entry>
|
|
3309 <entry>3</entry>
|
|
3310 <entry>4</entry>
|
|
3311 <entry>5</entry>
|
|
3312 <entry>Handheld</entry>
|
|
3313 <entry>Portable NTSC</entry>
|
|
3314 <entry>Portable PAL</entry>
|
|
3315 <entry>Home Theater NTSC</entry>
|
|
3316 <entry>Home Theater PAL</entry>
|
|
3317 <entry>HDTV</entry>
|
|
3318 </row>
|
|
3319 <row>
|
|
3320 <entry>Width [pixels]</entry>
|
|
3321 <entry>176</entry>
|
|
3322 <entry>176</entry>
|
|
3323 <entry>352</entry>
|
|
3324 <entry>352</entry>
|
|
3325 <entry>176</entry>
|
|
3326 <entry>176</entry>
|
|
3327 <entry>352</entry>
|
|
3328 <entry>352</entry>
|
|
3329 <entry>352</entry>
|
|
3330 <entry>720</entry>
|
|
3331 <entry>176</entry>
|
|
3332 <entry>352</entry>
|
|
3333 <entry>352</entry>
|
|
3334 <entry>720</entry>
|
|
3335 <entry>720</entry>
|
|
3336 <entry>1280</entry>
|
|
3337 </row>
|
|
3338 <row>
|
|
3339 <entry>Height [pixels]</entry>
|
|
3340 <entry>144</entry>
|
|
3341 <entry>144</entry>
|
|
3342 <entry>288</entry>
|
|
3343 <entry>288</entry>
|
|
3344 <entry>144</entry>
|
|
3345 <entry>144</entry>
|
|
3346 <entry>288</entry>
|
|
3347 <entry>288</entry>
|
|
3348 <entry>576</entry>
|
|
3349 <entry>576</entry>
|
|
3350 <entry>144</entry>
|
|
3351 <entry>240</entry>
|
|
3352 <entry>288</entry>
|
|
3353 <entry>480</entry>
|
|
3354 <entry>576</entry>
|
|
3355 <entry>720</entry>
|
|
3356 </row>
|
|
3357 <row>
|
|
3358 <entry>Frame rate [fps]</entry>
|
|
3359 <entry>15</entry>
|
|
3360 <entry>15</entry>
|
|
3361 <entry>15</entry>
|
|
3362 <entry>15</entry>
|
|
3363 <entry>30</entry>
|
|
3364 <entry>30</entry>
|
|
3365 <entry>15</entry>
|
|
3366 <entry>30</entry>
|
|
3367 <entry>30</entry>
|
|
3368 <entry>30</entry>
|
|
3369 <entry>15</entry>
|
|
3370 <entry>30</entry>
|
|
3371 <entry>25</entry>
|
|
3372 <entry>30</entry>
|
|
3373 <entry>25</entry>
|
|
3374 <entry>30</entry>
|
|
3375 </row>
|
|
3376 <row>
|
|
3377 <entry>Max average bitrate [kbps]</entry>
|
|
3378 <entry>64</entry>
|
|
3379 <entry>64</entry>
|
|
3380 <entry>128</entry>
|
|
3381 <entry>384</entry>
|
|
3382 <entry>128</entry>
|
|
3383 <entry>128</entry>
|
|
3384 <entry>384</entry>
|
|
3385 <entry>768</entry>
|
|
3386 <entry>3000</entry>
|
|
3387 <entry>8000</entry>
|
|
3388 <entry>537.6</entry>
|
|
3389 <entry>4854</entry>
|
|
3390 <entry>4854</entry>
|
|
3391 <entry>4854</entry>
|
|
3392 <entry>4854</entry>
|
|
3393 <entry>9708.4</entry>
|
|
3394 </row>
|
|
3395 <row>
|
|
3396 <entry>Peak average bitrate over 3 secs [kbps]</entry>
|
|
3397 <entry></entry>
|
|
3398 <entry></entry>
|
|
3399 <entry></entry>
|
|
3400 <entry></entry>
|
|
3401 <entry></entry>
|
|
3402 <entry></entry>
|
|
3403 <entry></entry>
|
|
3404 <entry></entry>
|
|
3405 <entry></entry>
|
|
3406 <entry></entry>
|
|
3407 <entry>800</entry>
|
|
3408 <entry>8000</entry>
|
|
3409 <entry>8000</entry>
|
|
3410 <entry>8000</entry>
|
|
3411 <entry>8000</entry>
|
|
3412 <entry>16000</entry>
|
|
3413 </row>
|
|
3414 <row>
|
|
3415 <entry>Max. B-frames</entry>
|
|
3416 <entry>0</entry>
|
|
3417 <entry>0</entry>
|
|
3418 <entry>0</entry>
|
|
3419 <entry>0</entry>
|
|
3420 <entry></entry>
|
|
3421 <entry></entry>
|
|
3422 <entry></entry>
|
|
3423 <entry></entry>
|
|
3424 <entry></entry>
|
|
3425 <entry></entry>
|
|
3426 <entry>0</entry>
|
|
3427 <entry>1</entry>
|
|
3428 <entry>1</entry>
|
|
3429 <entry>1</entry>
|
|
3430 <entry>1</entry>
|
|
3431 <entry>2</entry>
|
|
3432 </row>
|
|
3433 <row>
|
|
3434 <entry>MPEG quantization</entry>
|
|
3435 <entry></entry>
|
|
3436 <entry></entry>
|
|
3437 <entry></entry>
|
|
3438 <entry></entry>
|
|
3439 <entry>X</entry>
|
|
3440 <entry>X</entry>
|
|
3441 <entry>X</entry>
|
|
3442 <entry>X</entry>
|
|
3443 <entry>X</entry>
|
|
3444 <entry>X</entry>
|
|
3445 <entry></entry>
|
|
3446 <entry></entry>
|
|
3447 <entry></entry>
|
|
3448 <entry></entry>
|
|
3449 <entry></entry>
|
|
3450 <entry></entry>
|
|
3451 </row>
|
|
3452 <row>
|
|
3453 <entry>Adaptive quantization</entry>
|
|
3454 <entry></entry>
|
|
3455 <entry></entry>
|
|
3456 <entry></entry>
|
|
3457 <entry></entry>
|
|
3458 <entry>X</entry>
|
|
3459 <entry>X</entry>
|
|
3460 <entry>X</entry>
|
|
3461 <entry>X</entry>
|
|
3462 <entry>X</entry>
|
|
3463 <entry>X</entry>
|
|
3464 <entry>X</entry>
|
|
3465 <entry>X</entry>
|
|
3466 <entry>X</entry>
|
|
3467 <entry>X</entry>
|
|
3468 <entry>X</entry>
|
|
3469 <entry>X</entry>
|
|
3470 </row>
|
|
3471 <row>
|
|
3472 <entry>Interlaced encoding</entry>
|
|
3473 <entry></entry>
|
|
3474 <entry></entry>
|
|
3475 <entry></entry>
|
|
3476 <entry></entry>
|
|
3477 <entry>X</entry>
|
|
3478 <entry>X</entry>
|
|
3479 <entry>X</entry>
|
|
3480 <entry>X</entry>
|
|
3481 <entry>X</entry>
|
|
3482 <entry>X</entry>
|
|
3483 <entry></entry>
|
|
3484 <entry></entry>
|
|
3485 <entry></entry>
|
|
3486 <entry>X</entry>
|
|
3487 <entry>X</entry>
|
|
3488 <entry>X</entry>
|
|
3489 </row>
|
|
3490 <row>
|
|
3491 <entry>Quaterpixel</entry>
|
|
3492 <entry></entry>
|
|
3493 <entry></entry>
|
|
3494 <entry></entry>
|
|
3495 <entry></entry>
|
|
3496 <entry>X</entry>
|
|
3497 <entry>X</entry>
|
|
3498 <entry>X</entry>
|
|
3499 <entry>X</entry>
|
|
3500 <entry>X</entry>
|
|
3501 <entry>X</entry>
|
|
3502 <entry></entry>
|
|
3503 <entry></entry>
|
|
3504 <entry></entry>
|
|
3505 <entry></entry>
|
|
3506 <entry></entry>
|
|
3507 <entry></entry>
|
|
3508 </row>
|
|
3509 <row>
|
|
3510 <entry>Global motion compensation</entry>
|
|
3511 <entry></entry>
|
|
3512 <entry></entry>
|
|
3513 <entry></entry>
|
|
3514 <entry></entry>
|
|
3515 <entry>X</entry>
|
|
3516 <entry>X</entry>
|
|
3517 <entry>X</entry>
|
|
3518 <entry>X</entry>
|
|
3519 <entry>X</entry>
|
|
3520 <entry>X</entry>
|
|
3521 <entry></entry>
|
|
3522 <entry></entry>
|
|
3523 <entry></entry>
|
|
3524 <entry></entry>
|
|
3525 <entry></entry>
|
|
3526 <entry></entry>
|
|
3527 </row>
|
|
3528 </tbody>
|
|
3529 </tgroup>
|
|
3530 </informaltable>
|
|
3531 </sect2>
|
|
3532
|
|
3533 <sect2 id="menc-feat-xvid-example-settings">
|
|
3534 <title>Encoding setting examples</title>
|
|
3535
|
|
3536 <para>
|
|
3537 The following settings are examples of different encoding
|
|
3538 option combinations that affect the speed vs quality tradeoff
|
|
3539 at the same target bitrate.
|
|
3540 </para>
|
|
3541
|
|
3542 <para>
|
|
3543 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
3544 video sample, the target bitrate was 900kbps, and the machine was an
|
|
3545 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
3546 Each encoding setting features the measured encoding speed (in
|
|
3547 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
3548 high quality" setting.
|
|
3549 Please understand that depending on your source, your machine type
|
|
3550 and development advancements, you may get very different results.
|
|
3551 </para>
|
|
3552
|
|
3553 <para>
|
|
3554 <informaltable frame="all">
|
|
3555 <tgroup cols="4">
|
|
3556 <thead>
|
|
3557 <row><entry>Description</entry><entry>Encoding options</entry><entry>speed (in fps)</entry><entry>Relative PSNR loss (in dB)</entry></row>
|
|
3558 </thead>
|
|
3559 <tbody>
|
|
3560 <row>
|
|
3561 <entry>Very high quality</entry>
|
|
3562 <entry><option>chroma_opt:vhq=4:bvhq=1:quant_type=mpeg</option></entry>
|
|
3563 <entry>16fps</entry>
|
|
3564 <entry>0dB</entry>
|
|
3565 </row>
|
|
3566 <row>
|
|
3567 <entry>High quality</entry>
|
|
3568 <entry><option>vhq=2:bvhq=1:chroma_opt:quant_type=mpeg</option></entry>
|
|
3569 <entry>18fps</entry>
|
|
3570 <entry>-0.1dB</entry>
|
|
3571 </row>
|
|
3572 <row>
|
|
3573 <entry>Fast</entry>
|
|
3574 <entry><option>turbo:vhq=0</option></entry>
|
|
3575 <entry>28fps</entry>
|
|
3576 <entry>-0.69dB</entry>
|
|
3577 </row>
|
|
3578 <row>
|
|
3579 <entry>Realtime</entry>
|
|
3580 <entry><option>turbo:nochroma_me:notrellis:max_bframes=0:vhq=0</option></entry>
|
|
3581 <entry>38fps</entry>
|
|
3582 <entry>-1.48dB</entry>
|
|
3583 </row>
|
|
3584 </tbody>
|
|
3585 </tgroup>
|
|
3586 </informaltable>
|
|
3587 </para>
|
|
3588 </sect2>
|
|
3589
|
|
3590 </sect1>
|
|
3591
|
|
3592 <sect1 id="menc-feat-x264">
|
|
3593 <title>Encoding with the <systemitem class="library">x264</systemitem> codec</title>
|
|
3594 <para>
|
|
3595 <systemitem class="library">x264</systemitem> is a free library for
|
|
3596 encoding H.264/AVC video streams.
|
|
3597 Before starting to encode, you need to <link linkend="codec-x264-encode">
|
|
3598 set up <application>MEncoder</application> to support it</link>.
|
|
3599 </para>
|
|
3600
|
|
3601 <sect2 id="menc-feat-x264-encoding-options">
|
|
3602 <title>Encoding options of x264</title>
|
|
3603
|
|
3604 <para>
|
|
3605 Please begin by reviewing the
|
|
3606 <systemitem class="library">x264</systemitem> section of
|
|
3607 <application>MPlayer</application>'s man page.
|
|
3608 This section is intended to be a supplement to the man page.
|
|
3609 Here you will find quick hints about which options are most
|
|
3610 likely to interest most people. The man page is more terse,
|
|
3611 but also more exhaustive, and it sometimes offers much better
|
|
3612 technical detail.
|
|
3613 </para>
|
|
3614
|
|
3615 <sect3 id="menc-feat-x264-encoding-options-intro">
|
|
3616 <title>Introduction</title>
|
|
3617 <para>This guide considers two major categories of encoding options:</para>
|
|
3618
|
|
3619 <orderedlist>
|
|
3620 <listitem><para>Options which mainly trade off encoding time vs. quality
|
|
3621 </para></listitem>
|
|
3622 <listitem><para>Options which may be useful for fulfilling various personal
|
|
3623 preferences and special requirements</para></listitem>
|
|
3624 </orderedlist>
|
|
3625
|
|
3626 <para>
|
|
3627 Ultimately, only you can decide which options are best for your
|
|
3628 purposes. The decision for the first class of options is the simplest:
|
|
3629 you only have to decide whether you think the quality differences
|
|
3630 justify the speed differences. For the second class of options,
|
|
3631 preferences may be far more subjective, and more factors may be
|
|
3632 involved. Note that some of the "personal preferences and special
|
|
3633 requirements" options can still have large impacts on speed or quality,
|
|
3634 but that is not what they are primarily useful for. A couple of the
|
|
3635 "personal preference" options may even cause changes that look better
|
|
3636 to some people, but look worse to others.
|
|
3637 </para>
|
|
3638
|
|
3639 <para>
|
|
3640 Before continuing, you need to understand that this guide uses only one
|
|
3641 quality metric: global PSNR.
|
|
3642 For a brief explanation of what PSNR is, see
|
|
3643 <ulink url="http://en.wikipedia.org/wiki/PSNR">the Wikipedia article on PSNR</ulink>.
|
|
3644 Global PSNR is the last PSNR number reported when you include
|
|
3645 the <option>psnr</option> option in <option>x264encopts</option>.
|
|
3646 Any time you read a claim about PSNR, one of the assumptions
|
|
3647 behind the claim is that equal bitrates are used.
|
|
3648 </para>
|
|
3649
|
|
3650 <para>
|
|
3651 Nearly all of this guide's comments assume you are using
|
|
3652 two pass.
|
|
3653 When comparing options, there are two major reasons for using
|
|
3654 two pass encoding.
|
|
3655 First, using two pass often gains around 1dB PSNR, which is a
|
|
3656 very big difference.
|
|
3657 Secondly, testing options by doing direct quality comparisons
|
|
3658 with one pass encodes introduces a major confounding
|
|
3659 factor: bitrate often varies significantly with each encode.
|
|
3660 It is not always easy to tell whether quality changes are due
|
|
3661 mainly to changed options, or if they mostly reflect essentially
|
|
3662 random differences in the achieved bitrate.
|
|
3663 </para>
|
|
3664
|
|
3665 </sect3>
|
|
3666
|
|
3667 <sect3 id="menc-feat-x264-encoding-options-speedvquality">
|
|
3668 <title>Options which primarily affect speed and quality</title>
|
|
3669
|
|
3670 <itemizedlist>
|
|
3671 <listitem><para>
|
|
3672 <emphasis role="bold">subq</emphasis>:
|
|
3673 Of the options which allow you to trade off speed for quality,
|
|
3674 <option>subq</option> and <option>frameref</option> (see below) are usually
|
|
3675 by far the most important.
|
|
3676 If you are interested in tweaking either speed or quality, these
|
|
3677 are the first options you should consider.
|
|
3678 On the speed dimension, the <option>frameref</option> and
|
|
3679 <option>subq</option> options interact with each other fairly
|
|
3680 strongly.
|
|
3681 Experience shows that, with one reference frame,
|
|
3682 <option>subq=5</option> (the default setting) takes about 35% more time than
|
|
3683 <option>subq=1</option>.
|
|
3684 With 6 reference frames, the penalty grows to over 60%.
|
|
3685 <option>subq</option>'s effect on PSNR seems fairly constant
|
|
3686 regardless of the number of reference frames.
|
|
3687 Typically, <option>subq=5</option> achieves 0.2-0.5 dB higher global
|
|
3688 PSNR in comparison <option>subq=1</option>.
|
|
3689 This is usually enough to be visible.
|
|
3690 </para>
|
|
3691 <para>
|
|
3692 <option>subq=6</option> is the slowest, highest quality mode.
|
|
3693 In comparison to <option>subq=5</option>, it usually gains 0.1-0.4 dB
|
|
3694 global PSNR with speed costs varying from 25%-100%.
|
|
3695 Unlike other levels of <option>subq</option>, the behavior of
|
|
3696 <option>subq=6</option> does not depend much on <option>frameref</option>
|
|
3697 and <option>me</option>. Instead, the effectiveness of <option>subq=6
|
|
3698 </option> depends mostly upon the number of B-frames used. In normal
|
|
3699 usage, this means <option>subq=6</option> has a large impact on both speed
|
|
3700 and quality in complex, high motion scenes, but it may not have much effect
|
|
3701 in low-motion scenes. Note that it is still recommended to always set
|
|
3702 <option>bframes</option> to something other than zero (see below).
|
|
3703 </para></listitem>
|
|
3704 <listitem><para>
|
|
3705 <emphasis role="bold">frameref</emphasis>:
|
|
3706 <option>frameref</option> is set to 1 by default, but this
|
|
3707 should not be taken to imply that it is reasonable to set it
|
|
3708 to 1.
|
|
3709 Merely raising <option>frameref</option> to 2 gains around
|
|
3710 0.15dB PSNR with a 5-10% speed penalty; this seems like a
|
|
3711 good tradeoff.
|
|
3712 <option>frameref=3</option> gains around 0.25dB PSNR over
|
|
3713 <option>frameref=1</option>, which should be a visible
|
|
3714 difference.
|
|
3715 <option>frameref=3</option> is around 15% slower than
|
|
3716 <option>frameref=1</option>.
|
|
3717 Unfortunately, diminishing returns set in rapidly.
|
|
3718 <option>frameref=6</option> can be expected to gain only
|
|
3719 0.05-0.1 dB over <option>frameref=3</option> at an additional
|
|
3720 15% speed penalty.
|
|
3721 Above <option>frameref=6</option>, the quality gains are
|
|
3722 usually very small (although you should keep in mind throughout
|
|
3723 this whole discussion that it can vary quite a lot depending on
|
|
3724 your source).
|
|
3725 In a fairly typical case, <option>frameref=12</option>
|
|
3726 will improve global PSNR by a tiny 0.02dB over
|
|
3727 <option>frameref=6</option>, at a speed cost of 15%-20%.
|
|
3728 At such high <option>frameref</option> values, the only really
|
|
3729 good thing that can be said is that increasing it even further will
|
|
3730 almost certainly never <emphasis role="bold">harm</emphasis>
|
|
3731 PSNR, but the additional quality benefits are barely even
|
|
3732 measurable, let alone perceptible.
|
|
3733 </para>
|
|
3734 <note><title>Note:</title>
|
|
3735 <para>
|
|
3736 Raising <option>frameref</option> to unnecessarily high values
|
|
3737 <emphasis role="bold">can</emphasis> and
|
|
3738 <emphasis role="bold">usually does</emphasis>
|
|
3739 hurt coding efficiency if you turn CABAC off.
|
|
3740 With CABAC on (the default behavior), the possibility of setting
|
|
3741 <option>frameref</option> "too high" currently seems too remote
|
|
3742 to even worry about, and in the future, optimizations may remove
|
|
3743 the possibility altogether.
|
|
3744 </para>
|
|
3745 </note>
|
|
3746 <para>
|
|
3747 If you care about speed, a reasonable compromise is to use low
|
|
3748 <option>subq</option> and <option>frameref</option> values on
|
|
3749 the first pass, and then raise them on the second pass.
|
|
3750 Typically, this has a negligible negative effect on the final
|
|
3751 quality: You will probably lose well under 0.1dB PSNR, which
|
|
3752 should be much too small of a difference to see.
|
|
3753 However, different values of <option>frameref</option> can
|
|
3754 occasionally affect frametype decision.
|
|
3755 Most likely, these are rare outlying cases, but if you want to
|
|
3756 be pretty sure, consider whether your video has either
|
|
3757 fullscreen repetitive flashing patterns or very large temporary
|
|
3758 occlusions which might force an I-frame.
|
|
3759 Adjust the first-pass <option>frameref</option> so it is large
|
|
3760 enough to contain the duration of the flashing cycle (or occlusion).
|
|
3761 For example, if the scene flashes back and forth between two images
|
|
3762 over a duration of three frames, set the first pass
|
|
3763 <option>frameref</option> to 3 or higher.
|
|
3764 This issue is probably extremely rare in live action video material,
|
|
3765 but it does sometimes come up in video game captures.
|
|
3766 </para></listitem>
|
|
3767
|
|
3768 <listitem><para>
|
|
3769 <emphasis role="bold">me</emphasis>:
|
|
3770 This option is for choosing the motion estimation search method.
|
|
3771 Altering this option provides a straightforward quality-vs-speed
|
|
3772 tradeoff. <option>me=dia</option> is only a few percent faster than
|
|
3773 the default search, at a cost of under 0.1dB global PSNR. The
|
|
3774 default setting (<option>me=hex</option>) is a reasonable tradeoff
|
|
3775 between speed and quality. <option>me=umh</option> gains a little under
|
|
3776 0.1dB global PSNR, with a speed penalty that varies depending on
|
|
3777 <option>frameref</option>. At high values of
|
|
3778 <option>frameref</option> (e.g. 12 or so), <option>me=umh</option>
|
|
3779 is about 40% slower than the default <option> me=hex</option>. With
|
|
3780 <option>frameref=3</option>, the speed penalty incurred drops to
|
|
3781 25%-30%.
|
|
3782 </para>
|
|
3783 <para>
|
|
3784 <option>me=esa</option> uses an exhaustive search that is too slow for
|
|
3785 practical use.
|
|
3786 </para>
|
|
3787 </listitem>
|
|
3788
|
|
3789 <listitem><para>
|
|
3790 <emphasis role="bold">partitions=all</emphasis>:
|
|
3791 This option enables the use of 8x4, 4x8 and 4x4 subpartitions in
|
|
3792 predicted macroblocks (in addition to the default partitions).
|
|
3793 Enabling it results in a fairly consistent
|
|
3794 10%-15% loss of speed. This option is rather useless in source
|
|
3795 containing only low motion, however in some high-motion source,
|
|
3796 particularly source with lots of small moving objects, gains of
|
|
3797 about 0.1dB can be expected.
|
|
3798 </para>
|
|
3799 </listitem>
|
|
3800
|
|
3801 <listitem><para>
|
|
3802 <emphasis role="bold">bframes</emphasis>:
|
|
3803 If you are used to encoding with other codecs, you may have found
|
|
3804 that B-frames are not always useful.
|
|
3805 In H.264, this has changed: there are new techniques and block
|
|
3806 types that are possible in B-frames.
|
|
3807 Usually, even a naive B-frame choice algorithm can have a
|
|
3808 significant PSNR benefit.
|
|
3809 It is interesting to note that using B-frames usually speeds up
|
|
3810 the second pass somewhat, and may also speed up a single
|
|
3811 pass encode if adaptive B-frame decision is turned off.
|
|
3812 </para>
|
|
3813 <para>
|
|
3814 With adaptive B-frame decision turned off
|
|
3815 (<option>x264encopts</option>'s <option>nob_adapt</option>),
|
|
3816 the optimal value for this setting is usually no more than
|
|
3817 <option>bframes=1</option>, or else high-motion scenes can suffer.
|
|
3818 With adaptive B-frame decision on (the default behavior), it is
|
|
3819 safe to use higher values; the encoder will reduce the use of
|
|
3820 B-frames in scenes where they would hurt compression.
|
|
3821 The encoder rarely chooses to use more than 3 or 4 B-frames;
|
|
3822 setting this option any higher will have little effect.
|
|
3823 </para></listitem>
|
|
3824
|
|
3825 <listitem><para>
|
|
3826 <emphasis role="bold">b_adapt</emphasis>:
|
|
3827 Note: This is on by default.
|
|
3828 </para>
|
|
3829 <para>
|
|
3830 With this option enabled, the encoder will use a reasonably fast
|
|
3831 decision process to reduce the number of B-frames used in scenes that
|
|
3832 might not benefit from them as much.
|
|
3833 You can use <option>b_bias</option> to tweak how B-frame-happy
|
|
3834 the encoder is.
|
|
3835 The speed penalty of adaptive B-frames is currently rather modest,
|
|
3836 but so is the potential quality gain.
|
|
3837 It usually does not hurt, however.
|
|
3838 Note that this only affects speed and frametype decision on the
|
|
3839 first pass.
|
|
3840 <option>b_adapt</option> and <option>b_bias</option> have no
|
|
3841 effect on subsequent passes.
|
|
3842 </para></listitem>
|
|
3843
|
|
3844 <listitem><para>
|
|
3845 <emphasis role="bold">b_pyramid</emphasis>:
|
|
3846 You might as well enable this option if you are using >=2 B-frames;
|
|
3847 as the man page says, you get a little quality improvement at no
|
|
3848 speed cost.
|
|
3849 Note that these videos cannot be read by libavcodec-based decoders
|
|
3850 older than about March 5, 2005.
|
|
3851 </para></listitem>
|
|
3852
|
|
3853 <listitem><para>
|
|
3854 <emphasis role="bold">weight_b</emphasis>:
|
|
3855 In typical cases, there is not much gain with this option.
|
|
3856 However, in crossfades or fade-to-black scenes, weighted
|
|
3857 prediction gives rather large bitrate savings.
|
|
3858 In MPEG-4 ASP, a fade-to-black is usually best coded as a series
|
|
3859 of expensive I-frames; using weighted prediction in B-frames
|
|
3860 makes it possible to turn at least some of these into much smaller
|
|
3861 B-frames.
|
|
3862 Encoding time cost is minimal, as no extra decisions need to be made.
|
|
3863 Also, contrary to what some people seem to guess, the decoder
|
|
3864 CPU requirements are not much affected by weighted prediction,
|
|
3865 all else being equal.
|
|
3866 </para>
|
|
3867 <para>
|
|
3868 Unfortunately, the current adaptive B-frame decision algorithm
|
|
3869 has a strong tendency to avoid B-frames during fades.
|
|
3870 Until this changes, it may be a good idea to add
|
|
3871 <option>nob_adapt</option> to your x264encopts, if you expect
|
|
3872 fades to have a large effect in your particular video
|
|
3873 clip.
|
|
3874 </para></listitem>
|
|
3875 </itemizedlist>
|
|
3876 </sect3>
|
|
3877
|
|
3878 <sect3 id="menc-feat-x264-encoding-options-misc-preferences">
|
|
3879 <title>Options pertaining to miscellaneous preferences</title>
|
|
3880 <itemizedlist>
|
|
3881 <listitem><para>
|
|
3882 <emphasis role="bold">Two pass encoding</emphasis>:
|
|
3883 Above, it was suggested to always use two pass encoding, but there
|
|
3884 are still reasons for not using it. For instance, if you are capturing
|
|
3885 live TV and encoding in realtime, you are forced to use single-pass.
|
|
3886 Also, one pass is obviously faster than two passes; if you use the
|
|
3887 exact same set of options on both passes, two pass encoding is almost
|
|
3888 twice as slow.
|
|
3889 </para>
|
|
3890 <para>
|
|
3891 Still, there are very good reasons for using two pass encoding. For
|
|
3892 one thing, single pass ratecontrol is not psychic, and it often makes
|
|
3893 unreasonable choices because it cannot see the big picture. For example,
|
|
3894 suppose you have a two minute long video consisting of two distinct
|
|
3895 halves. The first half is a very high-motion scene lasting 60 seconds
|
|
3896 which, in isolation, requires about 2500kbps in order to look decent.
|
|
3897 Immediately following it is a much less demanding 60-second scene
|
|
3898 that looks good at 300kbps. Suppose you ask for 1400kbps on the theory
|
|
3899 that this is enough to accomodate both scenes. Single pass ratecontrol
|
|
3900 will make a couple of "mistakes" in such a case. First of all, it
|
|
3901 will target 1400kbps in both segments. The first segment may end up
|
|
3902 heavily overquantized, causing it to look unacceptably and unreasonably
|
|
3903 blocky. The second segment will be heavily underquantized; it may look
|
|
3904 perfect, but the bitrate cost of that perfection will be completely
|
|
3905 unreasonable. What is even harder to avoid is the problem at the
|
|
3906 transition between the two scenes. The first seconds of the low motion
|
|
3907 half will be hugely over-quantized, because the ratecontrol is still
|
|
3908 expecting the kind of bitrate requirements it met in the first half
|
|
3909 of the video. This "error period" of heavily over-quantized low motion
|
|
3910 will look jarringly bad, and will actually use less than the 300kbps
|
|
3911 it would have taken to make it look decent. There are ways to
|
|
3912 mitigate the pitfalls of single-pass encoding, but they may tend to
|
|
3913 increase bitrate misprediction.
|
|
3914 </para>
|
|
3915 <para>
|
|
3916 Multipass ratecontrol can offer huge advantages over a single pass.
|
|
3917 Using the statistics gathered from the first pass encode, the encoder
|
|
3918 can estimate, with reasonable accuracy, the "cost" (in bits) of
|
|
3919 encoding any given frame, at any given quantizer. This allows for
|
|
3920 a much more rational, better planned allocation of bits between the
|
|
3921 expensive (high-motion) and cheap (low-motion) scenes. See
|
|
3922 <option>qcomp</option> below for some ideas on how to tweak this
|
|
3923 allocation to your liking.
|
|
3924 </para>
|
|
3925 <para>
|
|
3926 Moreover, two passes need not take twice as long as one pass. You can
|
|
3927 tweak the options in the first pass for higher speed and lower quality.
|
|
3928 If you choose your options well, you can get a very fast first pass.
|
|
3929 The resulting quality in the second pass will be slightly lower because size
|
|
3930 prediction is less accurate, but the quality difference is normally much
|
|
3931 too small to be visible. Try, for example, adding
|
|
3932 <option>subq=1:frameref=1</option> to the first pass
|
|
3933 <option>x264encopts</option>. Then, on the second pass, use slower,
|
|
3934 higher-quality options:
|
|
3935 <option>subq=6:frameref=15:partitions=all:me=umh</option>
|
|
3936 </para></listitem>
|
|
3937 <listitem><para>
|
|
3938 <emphasis role="bold">Three pass encoding</emphasis>?
|
|
3939
|
|
3940 x264 offers the ability to make an arbitrary number of consecutive
|
|
3941 passes. If you specify <option>pass=1</option> on the first pass,
|
|
3942 then use <option>pass=3</option> on a subsequent pass, the subsequent
|
|
3943 pass will both read the statistics from the previous pass, and write
|
|
3944 its own statistics. An additional pass following this one will have
|
|
3945 a very good base from which to make highly accurate predictions of
|
|
3946 framesizes at a chosen quantizer. In practice, the overall quality
|
|
3947 gain from this is usually close to zero, and quite possibly a third
|
|
3948 pass will result in slightly worse global PSNR than the pass before
|
|
3949 it. In typical usage, three passes help if you get either bad bitrate
|
|
3950 prediction or bad looking scene transitions when using only two passes.
|
|
3951 This is somewhat likely to happen on extremely short clips. There are
|
|
3952 also a few special cases in which three (or more) passes are handy
|
|
3953 for advanced users, but for brevity, this guide omits discussing those
|
|
3954 special cases.
|
|
3955
|
|
3956 </para></listitem>
|
|
3957 <listitem><para>
|
|
3958 <emphasis role="bold">qcomp</emphasis>:
|
|
3959 <option>qcomp</option> trades off the number of bits allocated
|
|
3960 to "expensive" high-motion versus "cheap" low-motion frames. At
|
|
3961 one extreme, <option>qcomp=0</option> aims for true constant
|
|
3962 bitrate. Typically this would make high-motion scenes look completely
|
|
3963 awful, while low-motion scenes would probably look absolutely
|
|
3964 perfect, but would also use many times more bitrate than they
|
|
3965 would need in order to look merely excellent. At the other extreme,
|
|
3966 <option>qcomp=1</option> achieves nearly constant quantization parameter
|
|
3967 (QP). Constant QP does not look bad, but most people think it is more
|
|
3968 reasonable to shave some bitrate off of the extremely expensive scenes
|
|
3969 (where the loss of quality is not as noticeable) and reallocate it to
|
|
3970 the scenes that are easier to encode at excellent quality.
|
|
3971 <option>qcomp</option> is set to 0.6 by default, which may be slightly
|
|
3972 low for many peoples' taste (0.7-0.8 are also commonly used).
|
|
3973 </para></listitem>
|
|
3974 <listitem><para>
|
|
3975 <emphasis role="bold">keyint</emphasis>:
|
|
3976 <option>keyint</option> is solely for trading off file seekability against
|
|
3977 coding efficiency. By default, <option>keyint</option> is set to 250. In
|
|
3978 25fps material, this guarantees the ability to seek to within 10 seconds
|
|
3979 precision. If you think it would be important and useful to be able to
|
|
3980 seek within 5 seconds of precision, set <option>keyint=125</option>;
|
|
3981 this will hurt quality/bitrate slightly. If you care only about quality
|
|
3982 and not about seekability, you can set it to much higher values
|
|
3983 (understanding that there are diminishing returns which may become
|
|
3984 vanishingly low, or even zero). The video stream will still have seekable
|
|
3985 points as long as there are some scene changes.
|
|
3986 </para></listitem>
|
|
3987 <listitem><para>
|
|
3988 <emphasis role="bold">deblock</emphasis>:
|
|
3989 This topic is going to be a bit controversial.
|
|
3990 </para>
|
|
3991 <para>
|
|
3992 H.264 defines a simple deblocking procedure on I-blocks that uses
|
|
3993 pre-set strengths and thresholds depending on the QP of the block
|
|
3994 in question.
|
|
3995 By default, high QP blocks are filtered heavily, and low QP blocks
|
|
3996 are not deblocked at all.
|
|
3997 The pre-set strengths defined by the standard are well-chosen and
|
|
3998 the odds are very good that they are PSNR-optimal for whatever
|
|
3999 video you are trying to encode.
|
|
4000 The <option>deblock</option> allow you to specify offsets to the preset deblocking
|
|
4001 thresholds.
|
|
4002 </para>
|
|
4003 <para>
|
|
4004 Many people seem to think it is a good idea to lower the deblocking
|
|
4005 filter strength by large amounts (say, -3).
|
|
4006 This is however almost never a good idea, and in most cases,
|
|
4007 people who are doing this do not understand very well how
|
|
4008 deblocking works by default.
|
|
4009 </para>
|
|
4010 <para>
|
|
4011 The first and most important thing to know about the in-loop
|
|
4012 deblocking filter is that the default thresholds are almost always
|
|
4013 PSNR-optimal.
|
|
4014 In the rare cases that they are not optimal, the ideal offset is
|
|
4015 plus or minus 1.
|
|
4016 Adjusting deblocking parameters by a larger amount is almost
|
|
4017 guaranteed to hurt PSNR.
|
|
4018 Strengthening the filter will smear more details; weakening the
|
|
4019 filter will increase the appearance of blockiness.
|
|
4020 </para>
|
|
4021 <para>
|
|
4022 It is definitely a bad idea to lower the deblocking thresholds if
|
|
4023 your source is mainly low in spacial complexity (i.e., not a lot
|
|
4024 of detail or noise).
|
|
4025 The in-loop filter does a rather excellent job of concealing
|
|
4026 the artifacts that occur.
|
|
4027 If the source is high in spacial complexity, however, artifacts
|
|
4028 are less noticeable.
|
|
4029 This is because the ringing tends to look like detail or noise.
|
|
4030 Human visual perception easily notices when detail is removed,
|
|
4031 but it does not so easily notice when the noise is wrongly
|
|
4032 represented.
|
|
4033 When it comes to subjective quality, noise and detail are somewhat
|
|
4034 interchangeable.
|
|
4035 By lowering the deblocking filter strength, you are most likely
|
|
4036 increasing error by adding ringing artifacts, but the eye does
|
|
4037 not notice because it confuses the artifacts with detail.
|
|
4038 </para>
|
|
4039
|
|
4040 <para>
|
|
4041 This <emphasis role="bold">still</emphasis> does not justify
|
|
4042 lowering the deblocking filter strength, however.
|
|
4043 You can generally get better quality noise from postprocessing.
|
|
4044 If your H.264 encodes look too blurry or smeared, try playing with
|
|
4045 <option>-vf noise</option> when you play your encoded movie.
|
|
4046 <option>-vf noise=8a:4a</option> should conceal most mild
|
|
4047 artifacting.
|
|
4048 It will almost certainly look better than the results you
|
|
4049 would have gotten just by fiddling with the deblocking filter.
|
|
4050 </para></listitem>
|
|
4051 </itemizedlist>
|
|
4052 </sect3>
|
|
4053 </sect2>
|
|
4054
|
|
4055 <sect2 id="menc-feat-x264-example-settings">
|
|
4056 <title>Encoding setting examples</title>
|
|
4057
|
|
4058 <para>
|
|
4059 The following settings are examples of different encoding
|
|
4060 option combinations that affect the speed vs quality tradeoff
|
|
4061 at the same target bitrate.
|
|
4062 </para>
|
|
4063
|
|
4064 <para>
|
|
4065 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
4066 video sample, the target bitrate was 900kbps, and the machine was an
|
|
4067 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
4068 Each encoding setting features the measured encoding speed (in
|
|
4069 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
4070 high quality" setting.
|
|
4071 Please understand that depending on your source, your machine type
|
|
4072 and development advancements, you may get very different results.
|
|
4073 </para>
|
|
4074
|
|
4075 <para>
|
|
4076 <informaltable frame="all">
|
|
4077 <tgroup cols="4">
|
|
4078 <thead>
|
|
4079 <row><entry>Description</entry><entry>Encoding options</entry><entry>speed (in fps)</entry><entry>Relative PSNR loss (in dB)</entry></row>
|
|
4080 </thead>
|
|
4081 <tbody>
|
|
4082 <row>
|
|
4083 <entry>Very high quality</entry>
|
|
4084 <entry><option>subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4085 <entry>6fps</entry>
|
|
4086 <entry>0dB</entry>
|
|
4087 </row>
|
|
4088 <row>
|
|
4089 <entry>High quality</entry>
|
|
4090 <entry><option>subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4091 <entry>13fps</entry>
|
|
4092 <entry>-0.89dB</entry>
|
|
4093 </row>
|
|
4094 <row>
|
|
4095 <entry>Fast</entry>
|
|
4096 <entry><option>subq=4:bframes=2:b_pyramid:weight_b</option></entry>
|
|
4097 <entry>17fps</entry>
|
|
4098 <entry>-1.48dB</entry>
|
|
4099 </row>
|
|
4100 </tbody>
|
|
4101 </tgroup>
|
|
4102 </informaltable>
|
|
4103 </para>
|
|
4104 </sect2>
|
|
4105
|
|
4106 </sect1>
|
|
4107
|
|
4108 <sect1 id="menc-feat-video-for-windows">
|
|
4109 <title>Encoding with the <systemitem class="library">Video For Windows</systemitem> codec family</title>
|
|
4110
|
|
4111 <para>
|
|
4112 Video for Windows provides simple encoding by means of binary video codecs.
|
|
4113 You can encode with the following codecs (if you have more, please tell us!)
|
|
4114 </para>
|
|
4115 <para>
|
|
4116 Note that support for this is very experimental and some codecs may not work
|
|
4117 correctly. Some codecs will only work in certain colorspaces, try
|
|
4118 <option>-vf format=bgr24</option> and <option>-vf format=yuy2</option>
|
|
4119 if a codec fails or gives wrong output.
|
|
4120 </para>
|
|
4121
|
|
4122 <sect2 id="menc-feat-enc-vfw-video-codecs">
|
|
4123 <title>Video for Windows supported codecs</title>
|
|
4124
|
|
4125 <para>
|
|
4126 <informaltable frame="all">
|
|
4127 <tgroup cols="4">
|
|
4128 <thead>
|
|
4129 <row>
|
|
4130 <entry>Video codec file name</entry>
|
|
4131 <entry>Description (FourCC)</entry>
|
|
4132 <entry>md5sum</entry>
|
|
4133 <entry>Comment</entry>
|
|
4134 </row>
|
|
4135 </thead>
|
|
4136 <tbody>
|
|
4137 <row>
|
|
4138 <entry>aslcodec_vfw.dll</entry>
|
|
4139 <entry>Alparysoft lossless codec vfw (ASLC)</entry>
|
|
4140 <entry>608af234a6ea4d90cdc7246af5f3f29a</entry>
|
|
4141 <entry></entry>
|
|
4142 </row>
|
|
4143 <row>
|
|
4144 <entry>avimszh.dll</entry>
|
|
4145 <entry>AVImszh (MSZH)</entry>
|
|
4146 <entry>253118fe1eedea04a95ed6e5f4c28878</entry>
|
|
4147 <entry>needs <option>-vf format</option></entry>
|
|
4148 </row>
|
|
4149 <row>
|
|
4150 <entry>avizlib.dll</entry>
|
|
4151 <entry>AVIzlib (ZLIB)</entry>
|
|
4152 <entry>2f1cc76bbcf6d77d40d0e23392fa8eda</entry>
|
|
4153 <entry></entry>
|
|
4154 </row>
|
|
4155 <row>
|
|
4156 <entry>divx.dll</entry>
|
|
4157 <entry>DivX4Windows-VFW</entry>
|
|
4158 <entry>acf35b2fc004a89c829531555d73f1e6</entry>
|
|
4159 <entry></entry>
|
|
4160 </row>
|
|
4161 <row>
|
|
4162 <entry>huffyuv.dll</entry>
|
|
4163 <entry>HuffYUV (lossless) (HFYU)</entry>
|
|
4164 <entry>b74695b50230be4a6ef2c4293a58ac3b</entry>
|
|
4165 <entry></entry>
|
|
4166 </row>
|
|
4167 <row>
|
|
4168 <entry>iccvid.dll</entry>
|
|
4169 <entry>Cinepak Video (cvid)</entry>
|
|
4170 <entry>cb3b7ee47ba7dbb3d23d34e274895133</entry>
|
|
4171 <entry></entry>
|
|
4172 </row>
|
|
4173 <row>
|
|
4174 <entry>icmw_32.dll</entry>
|
|
4175 <entry>Motion Wavelets (MWV1)</entry>
|
|
4176 <entry>c9618a8fc73ce219ba918e3e09e227f2</entry>
|
|
4177 <entry></entry>
|
|
4178 </row>
|
|
4179 <row>
|
|
4180 <entry>jp2avi.dll</entry>
|
|
4181 <entry>ImagePower MJPEG2000 (IPJ2)</entry>
|
|
4182 <entry>d860a11766da0d0ea064672c6833768b</entry>
|
|
4183 <entry><option>-vf flip</option></entry>
|
|
4184 </row>
|
|
4185 <row>
|
|
4186 <entry>m3jp2k32.dll</entry>
|
|
4187 <entry>Morgan MJPEG2000 (MJ2C)</entry>
|
|
4188 <entry>f3c174edcbaef7cb947d6357cdfde7ff</entry>
|
|
4189 <entry></entry>
|
|
4190 </row>
|
|
4191 <row>
|
|
4192 <entry>m3jpeg32.dll</entry>
|
|
4193 <entry>Morgan Motion JPEG Codec (MJPG)</entry>
|
|
4194 <entry>1cd13fff5960aa2aae43790242c323b1</entry>
|
|
4195 <entry></entry>
|
|
4196 </row>
|
|
4197 <row>
|
|
4198 <entry>mpg4c32.dll</entry>
|
|
4199 <entry>Microsoft MPEG-4 v1/v2</entry>
|
|
4200 <entry>b5791ea23f33010d37ab8314681f1256</entry>
|
|
4201 <entry></entry>
|
|
4202 </row>
|
|
4203 <row>
|
|
4204 <entry>tsccvid.dll</entry>
|
|
4205 <entry>TechSmith Camtasia Screen Codec (TSCC)</entry>
|
|
4206 <entry>8230d8560c41d444f249802a2700d1d5</entry>
|
|
4207 <entry>shareware error on windows</entry>
|
|
4208 </row>
|
|
4209 <row>
|
|
4210 <entry>vp31vfw.dll</entry>
|
|
4211 <entry>On2 Open Source VP3 Codec (VP31)</entry>
|
|
4212 <entry>845f3590ea489e2e45e876ab107ee7d2</entry>
|
|
4213 <entry></entry>
|
|
4214 </row>
|
|
4215 <row>
|
|
4216 <entry>vp4vfw.dll</entry>
|
|
4217 <entry>On2 VP4 Personal Codec (VP40)</entry>
|
|
4218 <entry>fc5480a482ccc594c2898dcc4188b58f</entry>
|
|
4219 <entry></entry>
|
|
4220 </row>
|
|
4221 <row>
|
|
4222 <entry>vp6vfw.dll</entry>
|
|
4223 <entry>On2 VP6 Personal Codec (VP60)</entry>
|
|
4224 <entry>04d635a364243013898fd09484f913fb</entry>
|
|
4225 <entry>crashing on Linux</entry>
|
|
4226 </row>
|
|
4227 <row>
|
|
4228 <entry>vp7vfw.dll</entry>
|
|
4229 <entry>On2 VP7 Personal Codec (VP70)</entry>
|
|
4230 <entry>cb4cc3d4ea7c94a35f1d81c3d750bc8d</entry>
|
|
4231 <entry>wrong FourCC?</entry>
|
|
4232 </row>
|
|
4233 <row>
|
|
4234 <entry>ViVD2.dll</entry>
|
|
4235 <entry>SoftMedia ViVD V2 codec VfW (GXVE)</entry>
|
|
4236 <entry>a7b4bf5cac630bb9262c3f80d8a773a1</entry>
|
|
4237 <entry></entry>
|
|
4238 </row>
|
|
4239 <row>
|
|
4240 <entry>msulvc06.DLL</entry>
|
|
4241 <entry>MSU Lossless codec (MSUD)</entry>
|
|
4242 <entry>294bf9288f2f127bb86f00bfcc9ccdda</entry>
|
|
4243 <entry>
|
|
4244 Decodable by <application>Window Media Player</application>,
|
|
4245 not <application>MPlayer</application> (yet).
|
|
4246 </entry>
|
|
4247 </row>
|
|
4248 <row>
|
|
4249 <entry>camcodec.dll</entry>
|
|
4250 <entry>CamStudio lossless video codec (CSCD)</entry>
|
|
4251 <entry>0efe97ce08bb0e40162ab15ef3b45615</entry>
|
|
4252 <entry>sf.net/projects/camstudio</entry>
|
|
4253 </row>
|
|
4254 </tbody>
|
|
4255 </tgroup>
|
|
4256 </informaltable>
|
|
4257
|
|
4258 The first column contains the codec names that should be passed after the
|
|
4259 <literal>codec</literal> parameter, like: <option>-xvfwopts codec=divx.dll</option>
|
|
4260 The FourCC code used by each codec is given in the parentheses.
|
|
4261 </para>
|
|
4262 <informalexample>
|
|
4263 <para>
|
|
4264 An example with VP3 compression:
|
|
4265 <screen>mencoder dvd://2 -o title2.avi -ovc vfw -xvfwopts codec=vp31vfw.dll -oac copy</screen>
|
|
4266 </para>
|
|
4267 </informalexample>
|
|
4268 </sect2>
|
|
4269 </sect1>
|
|
4270
|
|
4271
|
|
4272 <sect1 id="menc-feat-vcd-dvd">
|
|
4273 <title>Using <application>MEncoder</application> to create VCD/SVCD/DVD-compliant files.</title>
|
|
4274
|
|
4275 <sect2 id="menc-feat-vcd-dvd-constraints">
|
|
4276 <title>Format Constraints</title>
|
|
4277 <para>
|
|
4278 <application>MEncoder</application> is capable of creating VCD, SCVD
|
|
4279 and DVD format MPEG files using the
|
|
4280 <systemitem class="library">libavcodec</systemitem> library.
|
|
4281 These files can then be used in conjunction with
|
|
4282 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>
|
|
4283 or
|
|
4284 <ulink url="http://dvdauthor.sourceforge.net/">dvdauthor</ulink>
|
|
4285 to create discs that will play on a standard set-top player.
|
|
4286 </para>
|
|
4287
|
|
4288 <para>
|
|
4289 The DVD, SVCD, and VCD formats are subject to heavy constraints.
|
|
4290 Only a small selection of encoded picture sizes and aspect ratios are
|
|
4291 available.
|
|
4292 If your movie does not already meet these requirements, you may have
|
|
4293 to scale,crop or add black borders to the picture to make it
|
|
4294 compliant.
|
|
4295 </para>
|
|
4296
|
|
4297 <sect3 id="menc-feat-vcd-dvd-constraints-resolution">
|
|
4298 <title>Format Constraints</title>
|
|
4299
|
|
4300 <informaltable frame="all">
|
|
4301 <tgroup cols="9">
|
|
4302 <thead>
|
|
4303 <row>
|
|
4304 <entry>Format</entry>
|
|
4305 <entry>Resolution</entry>
|
|
4306 <entry>V. Codec</entry>
|
|
4307 <entry>V. Bitrate</entry>
|
|
4308 <entry>Sample Rate</entry>
|
|
4309 <entry>A. Codec</entry>
|
|
4310 <entry>A. Bitrate</entry>
|
|
4311 <entry>FPS</entry>
|
|
4312 <entry>Aspect</entry>
|
|
4313 </row>
|
|
4314 </thead>
|
|
4315 <tbody>
|
|
4316 <row>
|
|
4317 <entry>NTSC DVD</entry>
|
|
4318 <entry>720x480, 704x480, 352x480, 352x240</entry>
|
|
4319 <entry>MPEG-2</entry>
|
|
4320 <entry>9800 kbps</entry>
|
|
4321 <entry>48000 Hz</entry>
|
|
4322 <entry>AC3,PCM</entry>
|
|
4323 <entry>1536 kbps (max)</entry>
|
|
4324 <entry>30000/1001, 24000/1001</entry>
|
|
4325 <entry>4:3, 16:9 (only for 720x480)</entry>
|
|
4326 </row>
|
|
4327 <row>
|
|
4328 <entry>NTSC DVD</entry>
|
|
4329 <entry>352x240<footnote id='fn-rare-resolutions'><para>
|
|
4330 These resolutions are rarely used for DVDs because
|
|
4331 they are fairly low quality.</para></footnote></entry>
|
|
4332 <entry>MPEG-1</entry>
|
|
4333 <entry>1856 kbps</entry>
|
|
4334 <entry>48000 Hz</entry>
|
|
4335 <entry>AC3,PCM</entry>
|
|
4336 <entry>1536 kbps (max)</entry>
|
|
4337 <entry>30000/1001, 24000/1001</entry>
|
|
4338 <entry>4:3, 16:9</entry>
|
|
4339 </row>
|
|
4340 <row>
|
|
4341 <entry>NTSC SVCD</entry>
|
|
4342 <entry>480x480</entry>
|
|
4343 <entry>MPEG-2</entry>
|
|
4344 <entry>2600 kbps</entry>
|
|
4345 <entry>44100 Hz</entry>
|
|
4346 <entry>MP2</entry>
|
|
4347 <entry>384 kbps (max)</entry>
|
|
4348 <entry>30000/1001</entry>
|
|
4349 <entry>4:3</entry>
|
|
4350 </row>
|
|
4351 <row>
|
|
4352 <entry>NTSC VCD</entry>
|
|
4353 <entry>352x240</entry>
|
|
4354 <entry>MPEG-1</entry>
|
|
4355 <entry>1150 kbps</entry>
|
|
4356 <entry>44100 Hz</entry>
|
|
4357 <entry>MP2</entry>
|
|
4358 <entry>224 kbps</entry>
|
|
4359 <entry>24000/1001, 30000/1001</entry>
|
|
4360 <entry>4:3</entry>
|
|
4361 </row>
|
|
4362 <row>
|
|
4363 <entry>PAL DVD</entry>
|
|
4364 <entry>720x576, 704x576, 352x576, 352x288</entry>
|
|
4365 <entry>MPEG-2</entry>
|
|
4366 <entry>9800 kbps</entry>
|
|
4367 <entry>48000 Hz</entry>
|
|
4368 <entry>MP2,AC3,PCM</entry>
|
|
4369 <entry>1536 kbps (max)</entry>
|
|
4370 <entry>25</entry>
|
|
4371 <entry>4:3, 16:9 (only for 720x576)</entry>
|
|
4372 </row>
|
|
4373 <row>
|
|
4374 <entry>PAL DVD</entry>
|
|
4375 <entry>352x288<footnoteref linkend='fn-rare-resolutions'/></entry>
|
|
4376 <entry>MPEG-1</entry>
|
|
4377 <entry>1856 kbps</entry>
|
|
4378 <entry>48000 Hz</entry>
|
|
4379 <entry>MP2,AC3,PCM</entry>
|
|
4380 <entry>1536 kbps (max)</entry>
|
|
4381 <entry>25</entry>
|
|
4382 <entry>4:3, 16:9</entry>
|
|
4383 </row>
|
|
4384 <row>
|
|
4385 <entry>PAL SVCD</entry>
|
|
4386 <entry>480x576</entry>
|
|
4387 <entry>MPEG-2</entry>
|
|
4388 <entry>2600 kbps</entry>
|
|
4389 <entry>44100 Hz</entry>
|
|
4390 <entry>MP2</entry>
|
|
4391 <entry>384 kbps (max)</entry>
|
|
4392 <entry>25</entry>
|
|
4393 <entry>4:3</entry>
|
|
4394 </row>
|
|
4395 <row>
|
|
4396 <entry>PAL VCD</entry>
|
|
4397 <entry>352x288</entry>
|
|
4398 <entry>MPEG-1</entry>
|
|
4399 <entry>1152 kbps</entry>
|
|
4400 <entry>44100 Hz</entry>
|
|
4401 <entry>MP2</entry>
|
|
4402 <entry>224 kbps</entry>
|
|
4403 <entry>25</entry>
|
|
4404 <entry>4:3</entry>
|
|
4405 </row>
|
|
4406 </tbody>
|
|
4407 </tgroup>
|
|
4408 </informaltable>
|
|
4409
|
|
4410 <para>
|
|
4411 If your movie has 2.35:1 aspect (most recent action movies), you will
|
|
4412 have to add black borders or crop the movie down to 16:9 to make a DVD
|
|
4413 or VCD.
|
|
4414 If you add black borders, try to align them at 16-pixel boundaries in
|
|
4415 order to minimize the impact on encoding performance.
|
|
4416 Thankfully DVD has sufficiently excessive bitrate that you do not have
|
|
4417 to worry too much about encoding efficiency, but SVCD and VCD are
|
|
4418 highly bitrate-starved and require effort to obtain acceptable quality.
|
|
4419 </para>
|
|
4420 </sect3>
|
|
4421
|
|
4422 <sect3 id="menc-feat-vcd-dvd-constraints-gop">
|
|
4423 <title>GOP Size Constraints</title>
|
|
4424 <para>
|
|
4425 DVD, VCD, and SVCD also constrain you to relatively low
|
|
4426 GOP (Group of Pictures) sizes.
|
|
4427 For 30 fps material the largest allowed GOP size is 18.
|
|
4428 For 25 or 24 fps, the maximum is 15.
|
|
4429 The GOP size is set using the <option>keyint</option> option.
|
|
4430 </para>
|
|
4431 </sect3>
|
|
4432
|
|
4433 <sect3 id="menc-feat-vcd-dvd-constraints-bitrate">
|
|
4434 <title>Bitrate Constraints</title>
|
|
4435 <para>
|
|
4436 VCD video is required to be CBR at 1152 kbps.
|
|
4437 This highly limiting constraint also comes along with an extremly low vbv
|
|
4438 buffer size of 327 kilobits.
|
|
4439 SVCD allows varying video bitrates up to 2500 kbps, and a somewhat less
|
|
4440 restrictive vbv buffer size of 917 kilobits is allowed.
|
|
4441 DVD video bitrates may range anywhere up to 9800 kbps (though typical
|
|
4442 bitrates are about half that), and the vbv buffer size is 1835 kilobits.
|
|
4443 </para>
|
|
4444 </sect3>
|
|
4445 </sect2>
|
|
4446
|
|
4447 <sect2 id="menc-feat-vcd-dvd-output">
|
|
4448 <title>Output Options</title>
|
|
4449 <para>
|
|
4450 <application>MEncoder</application> has options to control the output
|
|
4451 format.
|
|
4452 Using these options we can instruct it to create the correct type of
|
|
4453 file.
|
|
4454 </para>
|
|
4455
|
|
4456 <para>
|
|
4457 The options for VCD and SVCD are called xvcd and xsvcd, because they
|
|
4458 are extended formats.
|
|
4459 They are not strictly compliant, mainly because the output does not
|
|
4460 contain scan offsets.
|
|
4461 If you need to generate an SVCD image, you should pass the output file
|
|
4462 to
|
|
4463 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>.
|
|
4464 </para>
|
|
4465
|
|
4466 <para>
|
|
4467 VCD:
|
|
4468 <screen>
|
|
4469 -of mpeg -mpegopts format=xvcd
|
|
4470 </screen>
|
|
4471 </para>
|
|
4472
|
|
4473 <para>
|
|
4474 SVCD:
|
|
4475 <screen>
|
|
4476 -of mpeg -mpegopts format=xsvcd
|
|
4477 </screen>
|
|
4478 </para>
|
|
4479
|
|
4480 <para>
|
|
4481 DVD (with timestamps on every frame, if possible):
|
|
4482 <screen>
|
|
4483 -of mpeg -mpegopts format=dvd:tsaf
|
|
4484 </screen>
|
|
4485 </para>
|
|
4486
|
|
4487 <para>
|
|
4488 DVD with NTSC Pullup:
|
|
4489 <screen>
|
|
4490 -of mpeg -mpegopts format=dvd:tsaf:telecine -ofps 24000/1001
|
|
4491 </screen>
|
|
4492 This allows 24000/1001 fps progressive content to be encoded at 30000/1001
|
|
4493 fps whilst maintaing DVD-compliance.
|
|
4494 </para>
|
|
4495
|
|
4496 <sect3 id="menc-feat-vcd-dvd-output-aspect">
|
|
4497 <title>Aspect Ratio</title>
|
|
4498 <para>
|
|
4499 The aspect argument of <option>-lavcopts</option> is used to encode
|
|
4500 the aspect ratio of the file.
|
|
4501 During playback the aspect ratio is used to restore the video to the
|
|
4502 correct size.
|
|
4503 </para>
|
|
4504
|
|
4505 <para>
|
|
4506 16:9 or "Widescreen"
|
|
4507 <screen>
|
|
4508 -lavcopts aspect=16/9
|
|
4509 </screen>
|
|
4510 </para>
|
|
4511
|
|
4512 <para>
|
|
4513 4:3 or "Fullscreen"
|
|
4514 <screen>
|
|
4515 -lavcopts aspect=4/3
|
|
4516 </screen>
|
|
4517 </para>
|
|
4518
|
|
4519 <para>
|
|
4520 2.35:1 or "Cinemascope" NTSC
|
|
4521 <screen>
|
|
4522 -vf scale=720:368,expand=720:480 -lavcopts aspect=16/9
|
|
4523 </screen>
|
|
4524 To calculate the correct scaling size, use the expanded NTSC width of
|
|
4525 854/2.35 = 368
|
|
4526 </para>
|
|
4527
|
|
4528 <para>
|
|
4529 2.35:1 or "Cinemascope" PAL
|
|
4530 <screen>
|
|
4531 -vf scale="720:432,expand=720:576 -lavcopts aspect=16/9
|
|
4532 </screen>
|
|
4533 To calculate the correct scaling size, use the expanded PAL width of
|
|
4534 1024/2.35 = 432
|
|
4535 </para>
|
|
4536
|
|
4537 </sect3>
|
|
4538
|
|
4539 <sect3 id="menc-feat-vcd-dvd-a-v-sync">
|
|
4540 <title>Maintaining A/V sync</title>
|
|
4541 <para>
|
|
4542 In order to maintain audio/video synchronization throughout the encode,
|
|
4543 <application>MEncoder</application> has to drop or duplicate frames.
|
|
4544 This works rather well when muxing into an AVI file, but is almost
|
|
4545 guaranteed to fail to maintain A/V sync with other muxers such as MPEG.
|
|
4546 This is why it is necessary to append the
|
|
4547 <option>harddup</option> video filter at the end of the filter chain
|
|
4548 to avoid this kind of problem.
|
|
4549 You can find more technical information about <option>harddup</option>
|
|
4550 in the section
|
|
4551 <link linkend="menc-feat-dvd-mpeg4-muxing-filter-issues">Improving muxing and A/V sync reliability</link>
|
|
4552 or in the manual page.
|
|
4553 </para>
|
|
4554 </sect3>
|
|
4555
|
|
4556 <sect3 id="menc-feat-vcd-dvd-output-srate">
|
|
4557 <title>Sample Rate Conversion</title>
|
|
4558 <para>
|
|
4559 If the audio sample rate in the original file is not the same as
|
|
4560 required by the target format, sample rate conversion is required.
|
|
4561 This is achieved using the <option>-srate</option> option and
|
|
4562 the <option>-af lavcresample</option> audio filter together.
|
|
4563 </para>
|
|
4564 <para>
|
|
4565 DVD:
|
|
4566 <screen>
|
|
4567 -srate 48000 -af lavcresample=48000
|
|
4568 </screen>
|
|
4569 </para>
|
|
4570 <para>
|
|
4571 VCD and SVCD:
|
|
4572 <screen>
|
|
4573 -srate 44100 -af lavcresample=44100
|
|
4574 </screen>
|
|
4575 </para>
|
|
4576 </sect3>
|
|
4577 </sect2>
|
|
4578
|
|
4579 <sect2 id="menc-feat-vcd-dvd-lavc">
|
|
4580 <title>Using libavcodec for VCD/SVCD/DVD Encoding</title>
|
|
4581
|
|
4582 <sect3 id="menc-feat-vcd-dvd-lavc-intro">
|
|
4583 <title>Introduction</title>
|
|
4584 <para>
|
|
4585 <systemitem class="library">libavcodec</systemitem> can be used to
|
|
4586 create VCD/SVCD/DVD compliant video by using the appropriate options.
|
|
4587 </para>
|
|
4588 </sect3>
|
|
4589
|
|
4590 <sect3 id="menc-feat-vcd-dvd-lavc-options">
|
|
4591 <title>lavcopts</title>
|
|
4592 <para>
|
|
4593 This is a list of fields in <option>-lavcopts</option> that you may
|
|
4594 be required to change in order to make a complaint movie for VCD, SVCD,
|
|
4595 or DVD:
|
|
4596 </para>
|
|
4597
|
|
4598 <itemizedlist>
|
|
4599 <listitem><para>
|
|
4600 <emphasis role="bold">acodec</emphasis>:
|
|
4601 <option>mp2</option> for VCD, SVCD, or PAL DVD;
|
|
4602 <option>ac3</option> is most commonly used for DVD.
|
|
4603 PCM audio may also be used for DVD, but this is mostly a big waste of
|
|
4604 space.
|
|
4605 Note that MP3 audio is not compliant for any of these formats, but
|
|
4606 players often have no problem playing it anyway.
|
|
4607 </para></listitem>
|
|
4608
|
|
4609 <listitem><para>
|
|
4610 <emphasis role="bold">abitrate</emphasis>:
|
|
4611 224 for VCD; up to 384 for SVCD; up to 1536 for DVD, but commonly
|
|
4612 used values range from 192 kbps for stereo to 384 kbps for 5.1 channel
|
|
4613 sound.
|
|
4614 </para></listitem>
|
|
4615
|
|
4616 <listitem><para>
|
|
4617 <emphasis role="bold">vcodec</emphasis>:
|
|
4618 <option>mpeg1video</option> for VCD;
|
|
4619 <option>mpeg2video</option> for SVCD;
|
|
4620 <option>mpeg2video</option> is usually used for DVD but you may also use
|
|
4621 <option>mpeg1video</option> for CIF resolutions.
|
|
4622 </para></listitem>
|
|
4623
|
|
4624 <listitem><para>
|
|
4625 <emphasis role="bold">keyint</emphasis>:
|
|
4626 Used to set the GOP size.
|
|
4627 18 for 30fps material, or 15 for 25/24 fps material.
|
|
4628 Commercial producers seem to prefer keyframe intervals of 12.
|
|
4629 It is possible to make this much larger and still retain compatibility
|
|
4630 with most players.
|
|
4631 A <option>keyint</option> of 25 should never cause any problems.
|
|
4632 </para></listitem>
|
|
4633
|
|
4634 <listitem><para>
|
|
4635 <emphasis role="bold">vrc_buf_size</emphasis>:
|
|
4636 327 for VCD, 917 for SVCD, and 1835 for DVD.
|
|
4637 </para></listitem>
|
|
4638
|
|
4639 <listitem><para>
|
|
4640 <emphasis role="bold">vrc_minrate</emphasis>:
|
|
4641 1152, for VCD. May be left alone for SVCD and DVD.
|
|
4642 </para></listitem>
|
|
4643
|
|
4644 <listitem><para>
|
|
4645 <emphasis role="bold">vrc_maxrate</emphasis>:
|
|
4646 1152 for VCD; 2500 for SVCD; 9800 for DVD.
|
|
4647 For SVCD and DVD, you might wish to use lower values depending on your
|
|
4648 own personal preferences and requirements.
|
|
4649 </para></listitem>
|
|
4650
|
|
4651 <listitem><para>
|
|
4652 <emphasis role="bold">vbitrate</emphasis>:
|
|
4653 1152 for VCD;
|
|
4654 up to 2500 for SVCD;
|
|
4655 up to 9800 for DVD.
|
|
4656 For the latter two formats, vbitrate should be set based on personal
|
|
4657 preference.
|
|
4658 For instance, if you insist on fitting 20 or so hours on a DVD, you
|
|
4659 could use vbitrate=400.
|
|
4660 The resulting video quality would probably be quite bad.
|
|
4661 If you are trying to squeeze out the maximum possible quality on a DVD,
|
|
4662 use vbitrate=9800, but be warned that this could constrain you to less
|
|
4663 than an hour of video on a single-layer DVD.
|
|
4664 </para></listitem>
|
|
4665 </itemizedlist>
|
|
4666 </sect3>
|
|
4667
|
|
4668 <sect3 id="menc-feat-vcd-dvd-lavc-examples">
|
|
4669 <title>Examples</title>
|
|
4670 <para>
|
|
4671 This is a typical minimum set of <option>-lavcopts</option> for
|
|
4672 encoding video:
|
|
4673 </para>
|
|
4674 <para>
|
|
4675 VCD:
|
|
4676 <screen>
|
|
4677 -lavcopts vcodec=mpeg1video:vrc_buf_size=327:vrc_minrate=1152:\
|
|
4678 vrc_maxrate=1152:vbitrate=1152:keyint=15:acodec=mp2
|
|
4679 </screen>
|
|
4680 </para>
|
|
4681
|
|
4682 <para>
|
|
4683 SVCD:
|
|
4684 <screen>
|
|
4685 -lavcopts vcodec=mpeg2video:vrc_buf_size=917:vrc_maxrate=2500:vbitrate=1800:\
|
|
4686 keyint=15:acodec=mp2
|
|
4687 </screen>
|
|
4688 </para>
|
|
4689
|
|
4690 <para>
|
|
4691 DVD:
|
|
4692 <screen>
|
|
4693 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
4694 keyint=15:acodec=ac3
|
|
4695 </screen>
|
|
4696 </para>
|
|
4697
|
|
4698 </sect3>
|
|
4699
|
|
4700 <sect3 id="menc-feat-vcd-dvd-lavc-advanced">
|
|
4701 <title>Advanced Options</title>
|
|
4702 <para>
|
|
4703 For higher quality encoding, you may also wish to add quality-enhancing
|
|
4704 options to lavcopts, such as <option>trell</option>,
|
|
4705 <option>mbd=2</option>, and others.
|
|
4706 Note that <option>qpel</option> and <option>v4mv</option>, while often
|
|
4707 useful with MPEG-4, are not usable with MPEG-1 or MPEG-2.
|
|
4708 Also, if you are trying to make a very high quality DVD encode, it may
|
|
4709 be useful to add <option>dc=10</option> to lavcopts.
|
|
4710 Doing so may help reduce the appearance of blocks in flat-colored areas.
|
|
4711 Putting it all together, this is an example of a set of lavcopts for a
|
|
4712 higher quality DVD:
|
|
4713 </para>
|
|
4714
|
|
4715 <para>
|
|
4716 <screen>
|
|
4717 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:\
|
|
4718 keyint=15:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:\
|
|
4719 vqmin=1:lmin=1:dc=10
|
|
4720 </screen>
|
|
4721 </para>
|
|
4722
|
|
4723 </sect3>
|
|
4724 </sect2>
|
|
4725
|
|
4726 <sect2 id="menc-feat-vcd-dvd-audio">
|
|
4727 <title>Encoding Audio</title>
|
|
4728 <para>
|
|
4729 VCD and SVCD support MPEG-1 layer II audio, using one of
|
|
4730 <systemitem class="library">toolame</systemitem>,
|
|
4731 <systemitem class="library">twolame</systemitem>,
|
|
4732 or <systemitem class="library">libavcodec</systemitem>'s MP2 encoder.
|
|
4733 The libavcodec MP2 is far from being as good as the other two libraries,
|
|
4734 however it should always be available to use.
|
|
4735 VCD only supports constant bitrate audio (CBR) whereas SVCD supports
|
|
4736 variable bitrate (VBR), too.
|
|
4737 Be careful when using VBR because some bad standalone players might not
|
|
4738 support it too well.
|
|
4739 </para>
|
|
4740
|
|
4741 <para>
|
|
4742 For DVD audio, <systemitem class="library">libavcodec</systemitem>'s
|
|
4743 AC3 codec is used.
|
|
4744 </para>
|
|
4745
|
|
4746 <sect3 id="menc-feat-vcd-dvd-audio-toolame">
|
|
4747 <title>toolame</title>
|
|
4748 <para>
|
|
4749 For VCD and SVCD:
|
|
4750 <screen>
|
|
4751 -oac toolame -toolameopts br=224
|
|
4752 </screen>
|
|
4753 </para>
|
|
4754 </sect3>
|
|
4755
|
|
4756 <sect3 id="menc-feat-vcd-dvd-audio-twolame">
|
|
4757 <title>twolame</title>
|
|
4758 <para>
|
|
4759 For VCD and SVCD:
|
|
4760 <screen>
|
|
4761 -oac twolame -twolameopts br=224
|
|
4762 </screen>
|
|
4763 </para>
|
|
4764 </sect3>
|
|
4765
|
|
4766 <sect3 id="menc-feat-vcd-dvd-audio-lavc">
|
|
4767 <title>libavcodec</title>
|
|
4768 <para>
|
|
4769 For DVD with 2 channel sound:
|
|
4770 <screen>
|
|
4771 -oac lavc -lavcopts acodec=ac3:abitrate=192
|
|
4772 </screen>
|
|
4773 </para>
|
|
4774 <para>
|
|
4775 For DVD with 5.1 channel sound:
|
|
4776 <screen>
|
|
4777 -channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=384
|
|
4778 </screen>
|
|
4779 </para>
|
|
4780 <para>
|
|
4781 For VCD and SVCD:
|
|
4782 <screen>
|
|
4783 -oac lavc -lavcopts acodec=mp2:abitrate=224
|
|
4784 </screen>
|
|
4785 </para>
|
|
4786 </sect3>
|
|
4787
|
|
4788 </sect2>
|
|
4789
|
|
4790 <sect2 id="menc-feat-vcd-dvd-all">
|
|
4791 <title>Putting it all Together</title>
|
|
4792 <para>
|
|
4793 This section shows some complete commands for creating VCD/SVCD/DVD
|
|
4794 compliant videos.
|
|
4795 </para>
|
|
4796
|
|
4797 <sect3 id="menc-feat-vcd-dvd-all-pal-dvd">
|
|
4798 <title>PAL DVD</title>
|
|
4799 <para>
|
|
4800 <screen>
|
|
4801 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:576,\
|
|
4802 harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:\
|
|
4803 vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:acodec=ac3:\
|
|
4804 abitrate=192:aspect=16/9 -ofps 25 \
|
|
4805 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4806 </screen>
|
|
4807 </para>
|
|
4808 </sect3>
|
|
4809
|
|
4810 <sect3 id="menc-feat-vcd-dvd-all-ntsc-dvd">
|
|
4811 <title>NTSC DVD</title>
|
|
4812 <para>
|
|
4813 <screen>
|
|
4814 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:480,\
|
|
4815 harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:\
|
|
4816 vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=18:acodec=ac3:\
|
|
4817 abitrate=192:aspect=16/9 -ofps 30000/1001 \
|
|
4818 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4819 </screen>
|
|
4820 </para>
|
|
4821 </sect3>
|
|
4822
|
|
4823 <sect3 id="menc-feat-vcd-dvd-all-pal-ac3-copy">
|
|
4824 <title>PAL AVI Containing AC3 Audio to DVD</title>
|
|
4825 <para>
|
|
4826 If the source already has AC3 audio, use -oac copy instead of re-encoding it.
|
|
4827 <screen>
|
|
4828 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:576,\
|
|
4829 harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:\
|
|
4830 vbitrate=5000:keyint=15:aspect=16/9 -ofps 25 \
|
|
4831 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4832 </screen>
|
|
4833 </para>
|
|
4834 </sect3>
|
|
4835
|
|
4836 <sect3 id="menc-feat-vcd-dvd-all-ntsc-ac3-copy">
|
|
4837 <title>NTSC AVI Containing AC3 Audio to DVD</title>
|
|
4838 <para>
|
|
4839 If the source already has AC3 audio, and is NTSC @ 24000/1001 fps:
|
|
4840 <screen>
|
|
4841 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf:telecine \
|
|
4842 -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:\
|
|
4843 vrc_maxrate=9800:vbitrate=5000:keyint=15:aspect=16/9 -ofps 24000/1001 \
|
|
4844 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4845 </screen>
|
|
4846 </para>
|
|
4847 </sect3>
|
|
4848
|
|
4849 <sect3 id="menc-feat-vcd-dvd-all-pal-svcd">
|
|
4850 <title>PAL SVCD</title>
|
|
4851 <para>
|
|
4852 <screen>
|
|
4853 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
4854 scale=480:576,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
4855 vcodec=mpeg2video:mbd=2:keyint=15:vrc_buf_size=917:vrc_minrate=600:\
|
|
4856 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 25 \
|
|
4857 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4858 </screen>
|
|
4859 </para>
|
|
4860 </sect3>
|
|
4861
|
|
4862 <sect3 id="menc-feat-vcd-dvd-all-ntsc-svcd">
|
|
4863 <title>NTSC SVCD</title>
|
|
4864 <para>
|
|
4865 <screen>
|
|
4866 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
4867 scale=480:480,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
4868 vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:\
|
|
4869 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
4870 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4871 </screen>
|
|
4872 </para>
|
|
4873 </sect3>
|
|
4874
|
|
4875 <sect3 id="menc-feat-vcd-dvd-all-pal-vcd">
|
|
4876 <title>PAL VCD</title>
|
|
4877 <para>
|
|
4878 <screen>
|
|
4879 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
4880 scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
4881 vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:vbitrate=1152:\
|
|
4882 vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
|
|
4883 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4884 </screen>
|
|
4885 </para>
|
|
4886 </sect3>
|
|
4887
|
|
4888 <sect3 id="menc-feat-vcd-dvd-all-ntsc-vcd">
|
|
4889 <title>NTSC VCD</title>
|
|
4890 <para>
|
|
4891 <screen>
|
|
4892 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
4893 scale=352:240,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
4894 vcodec=mpeg1video:keyint=18:vrc_buf_size=327:vrc_minrate=1152:vbitrate=1152:\
|
|
4895 vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
4896 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
4897 </screen>
|
|
4898 </para>
|
|
4899 </sect3>
|
|
4900
|
|
4901 </sect2>
|
|
4902
|
|
4903 </sect1>
|
|
4904
|
|
4905 </chapter>
|