25279
|
1 <?xml version="1.0" encoding="utf-8"?>
|
25449
|
2 <!-- 30% synced with r22753 -->
|
25279
|
3 <chapter id="encoding-guide">
|
|
4 <title>La codifica con <application>MEncoder</application></title>
|
|
5
|
|
6 <sect1 id="menc-feat-dvd-mpeg4">
|
|
7 <title>Produrre un rip di un film da DVD in un
|
|
8 MPEG-4 ("DivX") di alta qualità</title>
|
|
9
|
|
10 <para>
|
25449
|
11 Una domanda frequente è "Come posso generare il rip con la migliore qualità
|
25279
|
12 per una dimensione data?". Un'altra domanda è "Come posso fare il rip da DVD
|
|
13 migliore in assoluto? Non mi interessa la dimensione del file, voglio solo la
|
|
14 più alta qualità."
|
|
15 </para>
|
|
16
|
|
17 <para>
|
|
18 L'ultima domanda è perlomeno forse posta malamente. Dopo tutto, se non ti
|
|
19 interessa la dimensione del file, perché non ti copi semplicemente l'intero
|
|
20 flusso video MPEG-2 dal DVD? Certo, avrai un AVI di 5GB, prendere o lasciare,
|
|
21 ma se vuoi la miglior qualità e non ti importa della dimensione, è
|
|
22 sicuramente la scelta migliore.
|
|
23 </para>
|
|
24
|
|
25 <para>
|
|
26 Invero, la ragione per cui vuoi codificare un DVD in MPEG-4 è proprio perché
|
|
27 ti interessa <emphasis role="bold">davvero</emphasis> la dimensione del file.
|
|
28 </para>
|
|
29
|
|
30 <para>
|
|
31 E' difficile offrire una ricetta da libro su come generare un rip da DVD in
|
|
32 qualità molto alta. Bisogna considerare vari fattori, e dovresti comprendere
|
|
33 questi dettagli, altrimenti alla fine probabilmente sarai insoddisfatto del
|
|
34 risultato. Più sotto evidenziamo alcuni di questi argomenti e poi passiamo ad
|
|
35 esaminare un esempio. Partiamo dal principio che per codificare il video tu
|
|
36 stia usando <systemitem class="library">libavcodec</systemitem> anche se la
|
|
37 teoria si applica allo stesso modo agli altri codec.
|
|
38 </para>
|
|
39
|
|
40 <para>
|
|
41 Se questo ti sembra troppo, dovresti probabilmente usare una delle belle
|
|
42 interfacce elencate nella
|
|
43 <ulink url="http://www.mplayerhq.hu/design7/projects.html#mencoder_frontends">sezione su MEncoder</ulink>
|
|
44 nella pagina dei progetti collegati (related projects).
|
|
45 In tal modo riuscirai ad ottenere rip di alta qualità senza pensarci troppo,
|
|
46 dato che la maggior parte di questi strumenti sono progettati per prendere
|
|
47 decisioni sagge al tuo posto.
|
|
48 </para>
|
|
49
|
|
50 <!-- ********** -->
|
|
51
|
|
52 <sect2 id="menc-feat-dvd-mpeg4-preparing-encode">
|
|
53 <title>Prepararsi alla codifica: identificare il materiale sorgente e la frequenza fotogrammi (framerate)</title>
|
|
54
|
|
55 <para>
|
|
56 Prima ancora di pensare a codificare un film, devi fare alcuni passi
|
|
57 preliminari.
|
|
58 </para>
|
|
59
|
|
60 <para>
|
|
61 Il primo e più importante passo prima della codifica dovrebbe essere
|
|
62 determinare il tipo di contenuto che stai trattando.
|
|
63 Se il tuo materiale di partenza arriva da un DVD o da TV in
|
|
64 broadcast/via cavo/satellite, sarà salvato in uno dei due formati: NTSC per
|
|
65 il Nord America e il Giappone, PAL per l'Europa, etc...
|
|
66 E' importante tuttavia comprendere che questo è solo il formato per la
|
|
67 trasmissione in televisione, e spesso <emphasis role="bold">non</emphasis>
|
|
68 corrisponde al formato originario del film.
|
|
69 L'esperienza insegna che il materiale NTSC è molto più difficile da
|
|
70 codificare, perché ci sono più elementi da identificare nel sorgente.
|
|
71 Per generare una codifica adeguata, devi sapere il formato originario.
|
|
72 Il non tenerne conto porterà a molti __flaws__ nella tua codifica, inclusi
|
|
73 artefatti orrendi __combing__ (interlacing) e fotogrammi duplicati o addirittura
|
|
74 perduti.
|
25449
|
75 Oltre ad essere brutti, gli artefatti influenzano negativamente l'efficienza
|
25279
|
76 della codifica: otterrai una peggior qualità a parità di bitrate.
|
|
77 </para>
|
|
78
|
|
79
|
|
80 <sect3 id="menc-feat-dvd-mpeg4-preparing-encode-fps">
|
|
81 <title>Identificare la frequenza fotogrammi (framerate) del sorgente</title>
|
|
82
|
|
83 <para>
|
|
84 C'è qui un elenco di tipi comuni di materiale sorgente, dove facilmente si
|
|
85 trovano e le loro proprietà:
|
|
86 </para>
|
|
87
|
|
88 <itemizedlist>
|
|
89 <listitem><para>
|
|
90 <emphasis role="bold">Film standard</emphasis>: prodotti per la visione
|
|
91 su schermi da cinema a 24fps.
|
|
92 </para></listitem>
|
|
93 <listitem><para>
|
|
94 <emphasis role="bold">Video PAL</emphasis>: registrati con una videocamera
|
|
95 PAL a 50 campi al secondo.
|
|
96 Un campo è composto dalle sole linee pari o dispari di un fotogramma.
|
|
97 La televisione è stata progettata per aggiornarle alternativamente come un
|
|
98 metodo economico di compressione analogica.
|
|
99 L'occhio umano teoricamente compensa la cosa, ma una volta che capisci come
|
|
100 funziona l'interlacciatura imparerai a vederla anche in TV e non ti piacerà
|
|
101 più la TV.
|
|
102 Due campi <emphasis role="bold">non</emphasis> fanno un fotogramma intero,
|
|
103 poiché sono registrati a 1/50 di secondo di distanza nel tempo e quindi non
|
|
104 si allineano a meno che non ci sia movimento alcuno.
|
|
105 </para></listitem>
|
|
106 <listitem><para>
|
|
107 <emphasis role="bold">Video NTSC</emphasis>: registrati con una videocamera
|
|
108 NTSC a 60000/1001 campi al secondi, o 60 campi al secondo nell'era precedente
|
|
109 al colore.
|
|
110 Per il resto sono simili ai PAL.
|
|
111 </para></listitem>
|
|
112 <listitem><para>
|
|
113 <emphasis role="bold">Animazione</emphasis>: solitamente disegnati a 24fps,
|
|
114 ma se ne trovano anche in tipologie con frequenza di fotogrammi mista.
|
|
115 </para></listitem>
|
|
116 <listitem><para>
|
|
117 <emphasis role="bold">Computer Graphics (CG)</emphasis>: possono essere con
|
|
118 qualsiasi frequenza di fotogrammi, ma alcuni sono più comuni di altri;
|
|
119 sono tipici 24 e 30 fotogrammi al secondo per NTSC e 25fps per PAL.
|
|
120 </para></listitem>
|
|
121 <listitem><para>
|
|
122 <emphasis role="bold">Vecchi Film</emphasis>: varie e più basse frequenze di
|
|
123 fotogrammi.
|
|
124 </para></listitem>
|
|
125 </itemizedlist>
|
|
126 </sect3>
|
|
127
|
|
128
|
|
129 <sect3 id="menc-feat-dvd-mpeg4-preparing-encode-material">
|
|
130 <title>Identificare il materiale sorgente</title>
|
|
131
|
|
132 <para>
|
|
133 I film composti da fotogrammi sono indicati come "progressivi", mentre quelli
|
|
134 composti da campi indipendenti sono chiamati "interlacciati" o video - anche se
|
|
135 quest'ultimo termine è ambiguo.
|
|
136 </para>
|
|
137
|
|
138 <para>
|
|
139 Per complicare ulteriormente le cose, alcuni film possono essere un misto di
|
|
140 molti dei suddetti.
|
|
141 </para>
|
|
142
|
|
143 <para>
|
|
144 La più importante distinzione da farsi tra tutti questi formati è che alcuni
|
|
145 sono basati su fotogrammi mentre gli altri sono basati su campi.
|
|
146 <emphasis role="bold">Ogniqualvolta</emphasis> un film viene preparato per la
|
|
147 visualizzazione in televisione (DVD inclusi), viene convertito in un formato
|
|
148 basato su campi.
|
|
149 I vari metodi con cui si può fare sono conosciuti nel loro insieme come
|
|
150 "telecine", di cui il tristemente famoso "3:2 pulldown" NTSC è una tipologia.
|
|
151 A meno che il materiale originale sia anch'esso basato su campi (e con la stessa
|
|
152 frequenza di campi) otterrai un filmato in un formato diverso da quello che è
|
|
153 in origine.
|
|
154 </para>
|
|
155
|
|
156 <itemizedlist>
|
|
157 <title>Ci sono vari tipi usuali di "pulldown":</title>
|
|
158 <listitem><para>
|
|
159 <emphasis role="bold">Pulldown PAL 2:2</emphasis>: il più bello di tutti.
|
|
160 Ciascun fotogramma viene mostrato per la durata di due campi, estraendo le
|
|
161 linee pari e dispari e mostrandole alternativamente.
|
|
162 Se il materiale di origine è a 24fps questo processo velocizza il filmato
|
|
163 del 4%.
|
|
164 </para></listitem>
|
|
165 <listitem><para>
|
|
166 <emphasis role="bold">Pulldown PAL 2:2:2:2:2:2:2:2:2:2:2:3</emphasis>:
|
|
167 Ogni dodicesimo fotogramma viene mostrato per la durata di tre campi, invece
|
|
168 che solamente per due.
|
|
169 Questo evita il problema dell'aumento del 4% di velocità, ma rende il
|
|
170 processo molto più difficile da __reversare__.
|
|
171 Solitamente viene usato nelle produzioni musicali, dove modificare del 4% la
|
|
172 velocità rovinerebbe pesantemente la colonna sonora.
|
|
173 </para></listitem>
|
|
174 <listitem><para>
|
|
175 <emphasis role="bold">Telecine NTSC 3:2</emphasis>: i fotogrammi vengono
|
|
176 mostrati alternativamente per la durata di 3 o 2 campi.
|
|
177 Questo porta ad una frequenza di campi di 2.5 volte la frequenza orginaria.
|
|
178 Il risultato viene anche leggermente rallentato da 60 campi al secondo fino a
|
|
179 60000/1001 campi al secondo, per mantenere la frequenza dei campi di NTSC.
|
|
180 </para></listitem>
|
|
181 <listitem><para>
|
|
182 <emphasis role="bold">Pulldown NTSC 2:2</emphasis>: utilizzato per mostrare
|
|
183 materiale a 30fps su NTSC.
|
|
184 Carino, proprio come il pulldown PAL 2:2.
|
|
185 </para></listitem>
|
|
186 </itemizedlist>
|
|
187
|
|
188 <para>
|
|
189 Ci sono anche alcuni metodi per convertire tra video NTSC e PAL, ma gli
|
|
190 arogmenti relativi non sono obiettivo di questa guida.
|
|
191 Se ti trovi di fronte a un film di questo genere e lo vuoi codificare, la tua
|
|
192 scelta migliore è cercarne una copia nel formato originale.
|
|
193 La conversione tra questi due formati è altamente distruttiva e non può
|
|
194 essere __reversed__ in maniera pulita, perciò la tua codifica __soffrirà__
|
|
195 molto se eseguita da una sorgente convertita.
|
|
196 </para>
|
|
197
|
|
198 <para>
|
|
199 Quando il video viene salvato du un DVD, coppie consecutive di campi sono
|
|
200 raggruppati in un fotogramma, anche se non sono pensati per esser mostrati
|
|
201 nello stesso momento.
|
|
202 Lo standard MPEG-2 usato sui DVD e per la TV digitale fornisce un modo sia per
|
|
203 codificare i fotogrammi progressivi originali, che uno per memorizzare
|
|
204 nell'intestazione del fotogramma il numero dei campi per cui il fotogramma
|
|
205 stesso debba essere mostrato.
|
|
206 Se viene usato questo metodo il filmato verrà spesso indicato come
|
|
207 "soft telecine", visto che il procedimento indica semplicemente al lettore DVD
|
|
208 di applicare il pulldown al film, invece che modificare il film stesso.
|
|
209 Questa situazione è decisamente preferibile, dato che può essere facilmente
|
|
210 __reversed__ (__actually ignored__) dal condificatore, e dato che mantiene la
|
|
211 massima qualità.
|
|
212 Tuttavia, molti studi di produzione DVD e di trasmissione non usano tecniche di
|
|
213 codifica appropriate, ma al contrario producono filmati con "hard telecine", in
|
|
214 cui i campi sono sotanzialmente duplicati nell'MPEG-2 codificato.
|
|
215 </para>
|
|
216
|
|
217 <para>
|
|
218 Le modalità per gestire questi casi verranno descritte
|
|
219 <link linkend="menc-feat-telecine">più avanti in questa guida</link>.
|
|
220 Per adesso ti lasciamo alcune indicazioni su come identificare il tipo di
|
|
221 materiale che stai trattando:
|
|
222 </para>
|
|
223
|
|
224 <itemizedlist>
|
|
225 <title>Regioni NTSC:</title>
|
|
226 <listitem><para>
|
|
227 Se <application>MPlayer</application> dice che la frequenza fotogrammi passa
|
|
228 a 24000/1001 durante la visione del film e non ritorna come prima, è quasi
|
|
229 sicuramente un qualche contenuto progressivo che è stato modificato in
|
|
230 "soft telecine".
|
|
231 </para></listitem>
|
|
232 <listitem><para>
|
|
233 Se <application>MPlayer</application> dice che la frequenza fotogrammi va
|
|
234 avanti e indietro tra 24000/1001 e 30000/1001 e ogni tanto vedi delle "righe",
|
|
235 allora ci sono varie possibilità.
|
|
236 Le parti a 24000/1001 fps sono quasi certamente contenuto progressivo, in
|
|
237 "soft telecine", ma le parti a 30000/1001 fps possono essere sia contenuto in
|
|
238 "hard telecine" a 24000/1001 fps che video NTSC a 60000/1001 campi al secondo.
|
|
239 Usa le stesse linee guida dei due casi seguenti per determinare quale.
|
|
240 </para></listitem>
|
|
241 <listitem><para>
|
|
242 Se <application>MPlayer</application> non mostra mai una modifica alla
|
|
243 frequenza dei fotogrammi e ogni singolo fotogramma con del movimento appare
|
|
244 "rigato", il tuo filmato è video NTSC a 60000/1001 campi al secondo.
|
|
245 </para></listitem>
|
|
246 <listitem><para>
|
|
247 Se <application>MPlayer</application> non mostra mai una modifica alla
|
|
248 frequenza dei fotogrammi e due fotogrammi ogni cinque sono "rigati", il tuo
|
|
249 film è contenuto a 24000/1001fps in "hard telecine".
|
|
250 </para></listitem>
|
|
251 </itemizedlist>
|
|
252
|
|
253 <itemizedlist>
|
|
254 <title>Regioni PAL:</title>
|
|
255 <listitem><para>
|
|
256 Se non vedi mai alcuna "riga", il tuo film è pulldown 2:2.
|
|
257 </para></listitem>
|
|
258 <listitem><para>
|
|
259 Se vedi delle "righe" che vanno e vengono ogni mezzo secondo,
|
|
260 allora il tuo film è pulldown 2:2:2:2:2:2:2:2:2:2:2:3.
|
|
261 </para></listitem>
|
|
262 <listitem><para>
|
|
263 Se vedi sempre "righe" durante il movimento, allora il tuo film è video
|
|
264 PAL a 50 campi al secondo.
|
|
265 </para></listitem>
|
|
266 </itemizedlist>
|
|
267
|
|
268 <note><title>Consiglio:</title>
|
|
269 <para>
|
|
270 <application>MPlayer</application> può rallentare la riproduzione del film
|
|
271 con l'opzione -speed o riprodurlo fotogramma per fotogramma.
|
|
272 Prova ad usare <option>-speed</option> 0.2 per guardare molto lentamente il
|
|
273 film o premi ripetutamente il tasto "<keycap>.</keycap>" per riprodurre un
|
|
274 fotogramma per volta ed identificare la sequenza, se non riesci a vederla a
|
|
275 velocità normale.
|
|
276 </para>
|
|
277 </note>
|
|
278 </sect3>
|
|
279 </sect2>
|
|
280
|
|
281 <!-- ********** -->
|
|
282
|
|
283 <sect2 id="menc-feat-dvd-mpeg4-2pass">
|
|
284 <title>Quantizzatore costante vs. multipassaggio</title>
|
|
285
|
|
286 <para>
|
|
287 E' possibile codificare il filmato in un'ampia gamma di qualità.
|
|
288 Con i codificatori video moderni e un pelo di compressione pre-codec
|
|
289 (ridimensionando e ripulendo), è possibile raggiungere una qualità molto
|
|
290 buona in 700 MB, per un film di 90-110 minuti in widescreen.
|
|
291 Inoltre tutti i film tranne i più lunghi possono essere codificati con una
|
|
292 qualità pressoché perfetta in 1400 MB.
|
|
293 </para>
|
|
294
|
|
295 <para>
|
|
296 Ci sono tre approcci per codificare il video: bitrate costante (CBR),
|
|
297 quantizzatore costante, e multipassaggio (ABR, o bitrate medio).
|
|
298 </para>
|
|
299
|
|
300 <para>
|
|
301 La complessità dei fotogrammi di un filmato, e di conseguenza il numero di
|
|
302 bit necessari per comprimerli, può variare molto da una scena ad un'altra.
|
|
303 I codificatori video moderni possono adattarsi via via a queste necessità
|
|
304 e cambiare il bitrate.
|
|
305 In modalità semplici come CBR, tuttavia, i codificatori non sanno il bitrate
|
|
306 necessario alle scene venture e perciò non possono stare sopra al bitrate
|
|
307 richiesto per lunghi periodi di tempo.
|
|
308 Modalità più avanzate, come la codifica in multipassaggio, possono tener
|
|
309 conto delle statistiche del passo precedente; questo corregge il problema
|
|
310 suddetto.
|
|
311 </para>
|
|
312
|
|
313 <note><title>Nota:</title>
|
|
314 <para>
|
|
315 La maggior parte dei codec che gestisce la codifica in ABR può usare solo la
|
|
316 codifica a due passaggi mentre altri come
|
|
317 <systemitem class="library">x264</systemitem>,
|
|
318 <systemitem class="library">Xvid</systemitem> e
|
|
319 <systemitem class="library">libavcodec</systemitem> gestiscono il
|
|
320 multipassaggio, che migliora leggermente la qualità ad ogni passo, anche se
|
|
321 tale moglioramento non è più misurabile né visibile veramente oltre il
|
|
322 quarto passo o giù di lì.
|
|
323 Perciò in questa sezione due passaggi e multipassaggio avranno lo stesso
|
|
324 significato.
|
|
325 </para>
|
|
326 </note>
|
|
327
|
|
328 <para>
|
|
329 In ambedue i modi, il codec video (come
|
|
330 <systemitem class="library">libavcodec</systemitem>) spezza il fotogramma video
|
|
331 in macroblocchi da 16x16 pixel e poi applica un quantizzatore a ciascun
|
|
332 macroblocco. Più basso è il quantizzatore, migliore sarà la qualità e
|
|
333 più alto il bitrate.
|
|
334 Il metodo usato dal codificatore del filmato per determinare quale quantizzatore
|
|
335 utilizzare per un dato macroblocco varia ed è altamente configurabile.
|
|
336 (Questa è una semplificazione estrema del vero processo, ma il concetto di base
|
|
337 è comodo per capire.)
|
|
338 </para>
|
|
339
|
|
340 <para>
|
|
341 Quando specifichi un bitrate constante, il codec video codificherà il video,
|
|
342 scartando dettagli tanto quanto è necessario e il meno possibile, in modo da
|
|
343 rimanere al di sotto del bitrate voluto. Se non ti interessa davvero la
|
|
344 dimensione del file, potresti anche usare CBR e specificare un bitrate
|
|
345 infinito. (In pratica, questo significa un valore abbastanza alto da non porre
|
|
346 limiti, come 10000Kbit.) Con nessun limite sul bitrate, il risultato è che il
|
|
347 codec userà il quantizzatore più basso possibile per ciascun macroblocco
|
|
348 (come specificato da <option>vqmin</option> per
|
|
349 <systemitem class="library">libavcodec</systemitem>, che è 2 di default).
|
|
350 Appena specifichi un bitrate abbastanza basso tale che il codec venga forzato
|
|
351 ad utilizzare un quantizzatore più alto, allora stai sicuramente diminuendo la
|
|
352 qualità del tuo video.
|
|
353 Per evitarlo, dovresti probabilmente ridurre la dimensione del tuo video,
|
|
354 seguendo il metodo descritto più avanti in questa guida.
|
|
355 In generale dovresti evitare del tutto CBR se ti interessa la qualità.
|
|
356 </para>
|
|
357
|
|
358 <para>
|
|
359 Con il quantizzatore costante, il codec utilizza lo stesso quantizzatore per
|
|
360 ogni macroblocco, come specificato dall'opzione <option>vqscale</option> (per
|
|
361 <systemitem class="library">libavcodec</systemitem>).
|
|
362 Se vuoi la più alta qualità possibile di rip, sempre ignorantdo il bitrate,
|
|
363 puoi usare <option>vqscale=2</option>.
|
|
364 Ciò porterà gli stessi bitrate e PSNR (peak signal-to-noise ratio) come CBR
|
|
365 con <option>vbitrate</option>=infinito e <option>vqmin</option> di default a 2.
|
|
366 </para>
|
|
367
|
|
368 <para>
|
|
369 Il problema con la quantizzazione costante è che usa il quantizzatore indicato
|
|
370 sia che il macroblocco ne abbia bisogno o no. Perciò è possibile che venga
|
|
371 usato un quantizzatore più alto su un macroblocco senza sacrificare la
|
|
372 qualità visiva. Perché sprecare i bit di un quantizzatore basso che non
|
|
373 serve? La tua CPU ha tanti cicli fin quando c'è tempo, ma c'è solo un certo
|
|
374 numero di bit sul tuo disco rigido.
|
|
375 </para>
|
|
376
|
|
377 <para>
|
|
378 Con una codifica a due passi, il primo codificherà il filmato come se fosse
|
|
379 CBR, ma manterrà una registrazione delle caratteristiche di ogni fotogramma.
|
|
380 Questi dati sono poi utilizzati durante il secondo passo in modo da effettuare
|
|
381 scelte intelligenti su quale quantizzatore usare. Durante le scene con azione
|
|
382 veloce o molti dettagliate, verrano usati più probabilmente quantizzatori più
|
|
383 alti, e durante scene lente o con pochi dettagli, verranno usati quantizzatori
|
|
384 più bassi. Solitamente è molto più importante la quantità di movimento
|
|
385 che la quantità di dettagli.
|
|
386 </para>
|
|
387
|
|
388 <para>
|
|
389 Se usi <option>vqscale=2</option>, allora stai sprecando dei bit. Se usi
|
|
390 <option>vqscale=3</option>, allora non stai ottenendo la miglior qualità.
|
|
391 Supponi di rippare un DVD a <option>vqscale=3</option> e che il risultato sia
|
|
392 1800Kbit. Se fai una codifica a due passi con <option>vbitrate=1800</option> il
|
|
393 video risultante avrà una <emphasis role="bold">qualità superiore</emphasis>
|
|
394 a <emphasis role="bold">parità di bitrate</emphasis>.
|
|
395 </para>
|
|
396
|
|
397 <para>
|
|
398 Dato che ora sei convinto che i due passaggi siano la strada da percorrere, la
|
|
399 vera domanda adesso è quale bitrate usare? La risposta à che non c'è una
|
|
400 risposta definitiva. Idealmente vuoi scegliere un bitrate che porti al miglior
|
|
401 equilibrio tra qualità e dimensione del file. Tutto ciò varia in dipendenza
|
|
402 del video di origine.
|
|
403 </para>
|
|
404
|
|
405 <para>
|
|
406 Se la dimensione non è importante, un buon punto di partenza per un rip di
|
|
407 qualità molto elevata è intorno a 2000Kbit più o meno 200Kbit.
|
|
408 Per video con scene di azione veloce o con molti dettagli, oppure se
|
|
409 semplicemente hai l'occhio critico, potresti scegliere 2400 o 2600.
|
|
410 Per alcuni DVD potresti non notare alcuna differenza a 1400Kbit. Sperimentare
|
|
411 con alcune scene a vari bitrate è una buona idea per farsi un'opinione.
|
|
412 </para>
|
|
413
|
|
414 <para>
|
|
415 Se punti a una data dimensione, dovrai calcolare il bitrate in un qualche modo.
|
|
416 Prima di farlo, però, devi sapere quanto spazio devi riservare per la traccia
|
|
417 (le tracce) audio, per cui devi dapprima fare il
|
|
418 <link linkend="menc-feat-dvd-mpeg4-audio">rip di queste</link>.
|
|
419 Puoi calcolare il bitrate con l'equazione che segue:
|
|
420 <systemitem>bitrate = (dimensione_voluta_in_Mbytes - dimensione_audio_in_Mbytes)
|
|
421 * 1024 * 1024 / lunghezza_in_secondi * 8 / 1000</systemitem>
|
|
422 Per esempio, per far stare un film di due ore su un CD da 702MB, con 60MB di
|
|
423 traccia audio, il bitrate video diventerà:
|
|
424 <systemitem>(702 - 60) * 1024 * 1024 / (120*60) * 8 / 1000
|
|
425 = 740kbps</systemitem>
|
|
426 </para>
|
|
427 </sect2>
|
|
428
|
|
429 <!-- ********** -->
|
|
430
|
|
431 <sect2 id="menc-feat-dvd-mpeg4-constraints">
|
|
432 <title>Vincoli per una codifica efficiente</title>
|
|
433
|
|
434 <para>
|
|
435 A causa della natura del tipo di compressione MPEG, ci sono alcuni vincoli da
|
|
436 seguire per avere la massima qualità.
|
|
437 L'MPEG divide il video in quadrati da 16x16 chiamati macroblocchi, ciascuno di
|
|
438 essi composto da blocchi 4x4 con informazioni sulla luminanza (intensità) e
|
|
439 due blocchi da 8x8 a metà risoluzione per la crominanza (colore) (uno per
|
|
440 l'asse rosso-ciano e l'altro per l'asse blu-giallo).
|
|
441 Anche se la larghezza e l'altezza del tuo filmato non sono multipli di 16 il
|
|
442 codificatore userà tanti macroblocchi 16x16 in modo da coprire tutta la
|
|
443 superficie dell'immagine, e lo spazio in esubero sarà sprecato.
|
|
444 Indi, per migliorare la qualità a una dimensione prefissata è una brutta
|
|
445 idea utilizzare dimensioni che non siano multiple di 16.
|
|
446 </para>
|
|
447
|
|
448 <para>
|
|
449 La maggior parte dei DVD ha anche alcune con bordi neri sui lati. Lasciarli lì
|
|
450 avrà un'influenza <emphasis role="bold">molto</emphasis> negativa sulla
|
|
451 qualità in svariati modi.
|
|
452 </para>
|
|
453
|
|
454 <orderedlist>
|
|
455 <listitem>
|
|
456 <para>
|
|
457 Il tipo di compressione MPEG è pesantemente dipendente dalle trasformazioni
|
|
458 di dominio frequenti, in particolare la "trasformazione discreta del coseno"
|
|
459 (Discrete Cosine Transform (DCT)), che xxièe' simile alla trasformazione di
|
|
460 Fourier. Quest'approccio di codifica è efficiente nella rappresentazione di
|
|
461 motivi e transizioni delicate, ma trova difficoltà con spigoli più
|
|
462 definiti. Per codificarli deve usare molti più bit oppure apparirà un
|
|
463 artefatto conosciuto come 'ringing'.
|
|
464 </para>
|
|
465
|
|
466 <para>
|
|
467 La trasformazione di frequenza (DCT) prende luogo separatemente in ogni
|
|
468 macroblocco (praticamente in ogni blocco) perciò questo problema si applica
|
|
469 solo quando lo spigolo definito è dentro a un blocco. Se il bordo nero inizia
|
|
470 esattamente sul lato di un multiplo di 16, questo non e' un problema.
|
|
471 Tuttavia i bordi neri sui DVD difficilmente sono ben allineati, perciò
|
|
472 nella realtà dovrai sempre tagliarli via per evitare questi problemi.
|
|
473 </para>
|
|
474 </listitem>
|
|
475 </orderedlist>
|
|
476
|
|
477 <para>
|
|
478 Oltre alle trasformazioni del dominio di frequenza, il tipo di compressione
|
|
479 MPEG usa dei vettori di movimento per rappresetare le variazioni da un
|
|
480 fotogramma al successivo. Naturalmente i vettori di movimento funzionano molto
|
|
481 meno bene per i nuovi contenuti che arrivano dai bordi dell'immagine, dato che
|
|
482 non erano presenti nel fotogramma precedente. Fintanto che l'immagine arriva
|
|
483 fino al bordo dell'area codificata, i vettori di movimento non incontrano
|
|
484 alcun problema con li contenuto che esce dall'immagine. Tuttavia ci possono
|
|
485 esser problemi quando ci sono dei bordi neri:
|
|
486 </para>
|
|
487
|
|
488 <orderedlist continuation="continues">
|
|
489 <listitem>
|
|
490 <para>
|
|
491 Per ogni macroblocco il tipo di compressione MPEG memorizza un vettore, che
|
|
492 identifica quale parte del fotogramma precedente debba essere copiata nel
|
|
493 macroblocco stesso, come base per predire il fotogramma successivo. Serve
|
|
494 codificare solo le differenze restanti. Se un macroblocco oltrepassa il
|
|
495 bordo dell'immagine e contiene parte del bordo nero, allora i vettori di
|
|
496 movimento provenienti da altre zone dell'immagine ricopriranno il bordo
|
|
497 nero. Questo significa che si devono utilizzare molti bit o per riannerire il
|
|
498 bordo che è stato ricoperto, oppure (più verosimilmente) un vettore di
|
|
499 movimento non sarà proprio usato e tutti i cambiamenti in questo
|
|
500 macroblocco dovranno venir esplicitamente codificate. In un modo o nell'altro
|
|
501 si ricuce di gran lunga l'efficienza della codifica.
|
|
502 </para>
|
|
503
|
|
504 <para>
|
|
505 Inoltre questo problema si applica solo se i bordi neri non sono allinati
|
|
506 su limiti di multipli di 16.
|
|
507 </para>
|
|
508 </listitem>
|
|
509
|
|
510 <listitem>
|
|
511 <para>
|
|
512 Immagina infine di avere un macroblocco all'interno dell'immagine, ed un
|
|
513 oggetto che passa da questo blocco verso il bordo dell'immagine. La
|
|
514 codifica MPEG non può dire "copia la parte che è dentro all'immagine, ma
|
|
515 non il bordo nero". Perciò anche il bordo nero vi verrà copiato
|
|
516 all'interno, e molti bit saranno sprecati codificando l'immagine che si
|
|
517 suppone stia lì.
|
|
518 </para>
|
|
519
|
|
520 <para>
|
|
521 Se l'immagine arriva al limite della superficie codificata, l'MPEG ha una
|
|
522 particolare ottimizzazione che consta nel copiare ripetutamente i pixel sul
|
|
523 bordo dell'immagine quando un vettore di movimento arriva dall'esterno della
|
|
524 superficie codificata. Questa funzionalità diventa inutile quando il film
|
|
525 ha dei bordi neri. Diversamente dai problemi 1 e 2, allineare i bordi a
|
|
526 multipli di 16 in questo caso non aiuta.
|
|
527 </para>
|
|
528 </listitem>
|
|
529
|
|
530 <listitem><para>
|
|
531 A dispetto del fatto che i bordi siano completamente neri e non cambino mai,
|
|
532 c'è perlomeno un piccolo spreco nell'avere più macroblocchi.
|
|
533 </para></listitem>
|
|
534 </orderedlist>
|
|
535
|
|
536 <para>
|
|
537 Per tutte queste ragioni si consiglia di tagliar via completamente i bordi neri.
|
|
538 Inoltre, se c'è una zona di rumore/distorsione sui bordi dell'immagine,
|
|
539 tagliarla migliorerà ancora l'efficienza di codifica. I puristi videofili che
|
|
540 vogliono mantenere il più possibile l'originale potrebbero obiettare su questo
|
|
541 taglio, ma a meno di non codificare a una quantizzazione costante, la qualità
|
|
542 guadagnata tagliando sorpasserà di gran lunga la quantità di informazioni
|
|
543 perse sui bordi.
|
|
544 </para>
|
|
545 </sect2>
|
|
546
|
|
547 <!-- ********** -->
|
|
548
|
|
549 <sect2 id="menc-feat-dvd-mpeg4-crop">
|
|
550 <title>Tagliare e Ridimensionare</title>
|
|
551
|
|
552 <para>
|
|
553 Ricorda dalla sezione precedente che la dimensione finale dell'immagine che
|
|
554 codifichi dovrebbe essere un multiplo di 16 (sia in larghezza che altezza).
|
|
555 Si può ottenere ciò tagliando, ridimensionando o combinando le due cose.
|
|
556 </para>
|
|
557
|
|
558 <para>
|
|
559 Quando tagli, ci sono alcune linee guida che si devono seguire per evitare di
|
|
560 rovinare il tuo filmato.
|
|
561 Il formato YUV abituale, 4:2:0, memorizza le informazioni sulla crominanza
|
|
562 (colore) sottocampionate, per es. la crominanza viene campionata in ogni
|
|
563 direzione solo la metà di quanto venga la luminanza (intensità).
|
|
564 Osserva questo diagramma, dove L indica i punti di campionamente della
|
|
565 luminanza e C quelli della crominanza.
|
|
566 </para>
|
|
567
|
|
568 <informaltable>
|
|
569 <?dbhtml table-width="40%" ?>
|
|
570 <?dbfo table-width="40%" ?>
|
|
571 <tgroup cols="8" align="center">
|
|
572 <colspec colnum="1" colname="col1"/>
|
|
573 <colspec colnum="2" colname="col2"/>
|
|
574 <colspec colnum="3" colname="col3"/>
|
|
575 <colspec colnum="4" colname="col4"/>
|
|
576 <colspec colnum="5" colname="col5"/>
|
|
577 <colspec colnum="6" colname="col6"/>
|
|
578 <colspec colnum="7" colname="col7"/>
|
|
579 <colspec colnum="8" colname="col8"/>
|
|
580 <spanspec spanname="spa1-2" namest="col1" nameend="col2"/>
|
|
581 <spanspec spanname="spa3-4" namest="col3" nameend="col4"/>
|
|
582 <spanspec spanname="spa5-6" namest="col5" nameend="col6"/>
|
|
583 <spanspec spanname="spa7-8" namest="col7" nameend="col8"/>
|
|
584 <tbody>
|
|
585 <row>
|
|
586 <entry>L</entry>
|
|
587 <entry>L</entry>
|
|
588 <entry>L</entry>
|
|
589 <entry>L</entry>
|
|
590 <entry>L</entry>
|
|
591 <entry>L</entry>
|
|
592 <entry>L</entry>
|
|
593 <entry>L</entry>
|
|
594 </row>
|
|
595 <row>
|
|
596 <entry spanname="spa1-2">C</entry>
|
|
597 <entry spanname="spa3-4">C</entry>
|
|
598 <entry spanname="spa5-6">C</entry>
|
|
599 <entry spanname="spa7-8">C</entry>
|
|
600 </row>
|
|
601 <row>
|
|
602 <entry>L</entry>
|
|
603 <entry>L</entry>
|
|
604 <entry>L</entry>
|
|
605 <entry>L</entry>
|
|
606 <entry>L</entry>
|
|
607 <entry>L</entry>
|
|
608 <entry>L</entry>
|
|
609 <entry>L</entry>
|
|
610 </row>
|
|
611 <row>
|
|
612 <entry>L</entry>
|
|
613 <entry>L</entry>
|
|
614 <entry>L</entry>
|
|
615 <entry>L</entry>
|
|
616 <entry>L</entry>
|
|
617 <entry>L</entry>
|
|
618 <entry>L</entry>
|
|
619 <entry>L</entry>
|
|
620 </row>
|
|
621 <row>
|
|
622 <entry spanname="spa1-2">C</entry>
|
|
623 <entry spanname="spa3-4">C</entry>
|
|
624 <entry spanname="spa5-6">C</entry>
|
|
625 <entry spanname="spa7-8">C</entry>
|
|
626 </row>
|
|
627 <row>
|
|
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 <entry>L</entry>
|
|
635 <entry>L</entry>
|
|
636 </row>
|
|
637 </tbody>
|
|
638 </tgroup>
|
|
639 </informaltable>
|
|
640
|
|
641 <para>
|
|
642 Come puoi vedere, le righe e le colonne dell'immagine vengono sempre a coppie.
|
|
643 Quindi i tuoi valori di spostamento e dimensione <emphasis>devono</emphasis>
|
|
644 essere numeri pari.
|
|
645 Se non lo sono la crominanza non sarà più allineata correttamente con la
|
|
646 luminanza.
|
|
647 In teoria è possibile tagliare con uno spostamento dispari, ma richiede che la
|
|
648 crominanza venga ricampionata, il che potenzialmente è un'operazione in perdita
|
|
649 e non è gestita dal filtro crop.
|
|
650 </para>
|
|
651
|
|
652 <para>
|
|
653 Inoltre, il video interlacciato viene campionato come segue:
|
|
654 </para>
|
|
655
|
|
656 <informaltable>
|
|
657 <?dbhtml table-width="80%" ?>
|
|
658 <?dbfo table-width="80%" ?>
|
|
659 <tgroup cols="16" align="center">
|
|
660 <colspec colnum="1" colname="col1"/>
|
|
661 <colspec colnum="2" colname="col2"/>
|
|
662 <colspec colnum="3" colname="col3"/>
|
|
663 <colspec colnum="4" colname="col4"/>
|
|
664 <colspec colnum="5" colname="col5"/>
|
|
665 <colspec colnum="6" colname="col6"/>
|
|
666 <colspec colnum="7" colname="col7"/>
|
|
667 <colspec colnum="8" colname="col8"/>
|
|
668 <colspec colnum="9" colname="col9"/>
|
|
669 <colspec colnum="10" colname="col10"/>
|
|
670 <colspec colnum="11" colname="col11"/>
|
|
671 <colspec colnum="12" colname="col12"/>
|
|
672 <colspec colnum="13" colname="col13"/>
|
|
673 <colspec colnum="14" colname="col14"/>
|
|
674 <colspec colnum="15" colname="col15"/>
|
|
675 <colspec colnum="16" colname="col16"/>
|
|
676 <spanspec spanname="spa1-2" namest="col1" nameend="col2"/>
|
|
677 <spanspec spanname="spa3-4" namest="col3" nameend="col4"/>
|
|
678 <spanspec spanname="spa5-6" namest="col5" nameend="col6"/>
|
|
679 <spanspec spanname="spa7-8" namest="col7" nameend="col8"/>
|
|
680 <spanspec spanname="spa9-10" namest="col9" nameend="col10"/>
|
|
681 <spanspec spanname="spa11-12" namest="col11" nameend="col12"/>
|
|
682 <spanspec spanname="spa13-14" namest="col13" nameend="col14"/>
|
|
683 <spanspec spanname="spa15-16" namest="col15" nameend="col16"/>
|
|
684 <tbody>
|
|
685 <row>
|
|
686 <entry namest="col1" nameend="col8">Campo superiore</entry>
|
|
687 <entry namest="col9" nameend="col16">Campo inferiore</entry>
|
|
688 </row>
|
|
689 <row>
|
|
690 <entry>L</entry>
|
|
691 <entry>L</entry>
|
|
692 <entry>L</entry>
|
|
693 <entry>L</entry>
|
|
694 <entry>L</entry>
|
|
695 <entry>L</entry>
|
|
696 <entry>L</entry>
|
|
697 <entry>L</entry>
|
|
698 <entry></entry>
|
|
699 <entry></entry>
|
|
700 <entry></entry>
|
|
701 <entry></entry>
|
|
702 <entry></entry>
|
|
703 <entry></entry>
|
|
704 <entry></entry>
|
|
705 <entry></entry>
|
|
706 </row>
|
|
707 <row>
|
|
708 <entry spanname="spa1-2">C</entry>
|
|
709 <entry spanname="spa3-4">C</entry>
|
|
710 <entry spanname="spa5-6">C</entry>
|
|
711 <entry spanname="spa7-8">C</entry>
|
|
712 <entry></entry>
|
|
713 <entry></entry>
|
|
714 <entry></entry>
|
|
715 <entry></entry>
|
|
716 <entry></entry>
|
|
717 <entry></entry>
|
|
718 <entry></entry>
|
|
719 <entry></entry>
|
|
720 </row>
|
|
721 <row>
|
|
722 <entry></entry>
|
|
723 <entry></entry>
|
|
724 <entry></entry>
|
|
725 <entry></entry>
|
|
726 <entry></entry>
|
|
727 <entry></entry>
|
|
728 <entry></entry>
|
|
729 <entry></entry>
|
|
730 <entry>L</entry>
|
|
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 </row>
|
|
739 <row>
|
|
740 <entry>L</entry>
|
|
741 <entry>L</entry>
|
|
742 <entry>L</entry>
|
|
743 <entry>L</entry>
|
|
744 <entry>L</entry>
|
|
745 <entry>L</entry>
|
|
746 <entry>L</entry>
|
|
747 <entry>L</entry>
|
|
748 <entry></entry>
|
|
749 <entry></entry>
|
|
750 <entry></entry>
|
|
751 <entry></entry>
|
|
752 <entry></entry>
|
|
753 <entry></entry>
|
|
754 <entry></entry>
|
|
755 <entry></entry>
|
|
756 </row>
|
|
757 <row>
|
|
758 <entry></entry>
|
|
759 <entry></entry>
|
|
760 <entry></entry>
|
|
761 <entry></entry>
|
|
762 <entry></entry>
|
|
763 <entry></entry>
|
|
764 <entry></entry>
|
|
765 <entry></entry>
|
|
766 <entry spanname="spa9-10">C</entry>
|
|
767 <entry spanname="spa11-12">C</entry>
|
|
768 <entry spanname="spa13-14">C</entry>
|
|
769 <entry spanname="spa15-16">C</entry>
|
|
770 </row>
|
|
771 <row>
|
|
772 <entry></entry>
|
|
773 <entry></entry>
|
|
774 <entry></entry>
|
|
775 <entry></entry>
|
|
776 <entry></entry>
|
|
777 <entry></entry>
|
|
778 <entry></entry>
|
|
779 <entry></entry>
|
|
780 <entry>L</entry>
|
|
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 </row>
|
|
789 <row>
|
|
790 <entry>L</entry>
|
|
791 <entry>L</entry>
|
|
792 <entry>L</entry>
|
|
793 <entry>L</entry>
|
|
794 <entry>L</entry>
|
|
795 <entry>L</entry>
|
|
796 <entry>L</entry>
|
|
797 <entry>L</entry>
|
|
798 <entry></entry>
|
|
799 <entry></entry>
|
|
800 <entry></entry>
|
|
801 <entry></entry>
|
|
802 <entry></entry>
|
|
803 <entry></entry>
|
|
804 <entry></entry>
|
|
805 <entry></entry>
|
|
806 </row>
|
|
807 <row>
|
|
808 <entry spanname="spa1-2">C</entry>
|
|
809 <entry spanname="spa3-4">C</entry>
|
|
810 <entry spanname="spa5-6">C</entry>
|
|
811 <entry spanname="spa7-8">C</entry>
|
|
812 <entry></entry>
|
|
813 <entry></entry>
|
|
814 <entry></entry>
|
|
815 <entry></entry>
|
|
816 <entry></entry>
|
|
817 <entry></entry>
|
|
818 <entry></entry>
|
|
819 <entry></entry>
|
|
820 </row>
|
|
821 <row>
|
|
822 <entry></entry>
|
|
823 <entry></entry>
|
|
824 <entry></entry>
|
|
825 <entry></entry>
|
|
826 <entry></entry>
|
|
827 <entry></entry>
|
|
828 <entry></entry>
|
|
829 <entry></entry>
|
|
830 <entry>L</entry>
|
|
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 </row>
|
|
839 <row>
|
|
840 <entry>L</entry>
|
|
841 <entry>L</entry>
|
|
842 <entry>L</entry>
|
|
843 <entry>L</entry>
|
|
844 <entry>L</entry>
|
|
845 <entry>L</entry>
|
|
846 <entry>L</entry>
|
|
847 <entry>L</entry>
|
|
848 <entry></entry>
|
|
849 <entry></entry>
|
|
850 <entry></entry>
|
|
851 <entry></entry>
|
|
852 <entry></entry>
|
|
853 <entry></entry>
|
|
854 <entry></entry>
|
|
855 <entry></entry>
|
|
856 </row>
|
|
857 <row>
|
|
858 <entry></entry>
|
|
859 <entry></entry>
|
|
860 <entry></entry>
|
|
861 <entry></entry>
|
|
862 <entry></entry>
|
|
863 <entry></entry>
|
|
864 <entry></entry>
|
|
865 <entry></entry>
|
|
866 <entry spanname="spa9-10">C</entry>
|
|
867 <entry spanname="spa11-12">C</entry>
|
|
868 <entry spanname="spa13-14">C</entry>
|
|
869 <entry spanname="spa15-16">C</entry>
|
|
870 </row>
|
|
871 <row>
|
|
872 <entry></entry>
|
|
873 <entry></entry>
|
|
874 <entry></entry>
|
|
875 <entry></entry>
|
|
876 <entry></entry>
|
|
877 <entry></entry>
|
|
878 <entry></entry>
|
|
879 <entry></entry>
|
|
880 <entry>L</entry>
|
|
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 </row>
|
|
889 </tbody>
|
|
890 </tgroup>
|
|
891 </informaltable>
|
|
892
|
|
893 <para>
|
|
894 Come puoi notare, il motivo non si ripete fino a dopo 4 linee.
|
|
895 Quindi per il video interlacciato, il tuo spostamento sull'asse y e l'altezza
|
|
896 devono essere multipli di 4.
|
|
897 </para>
|
|
898
|
|
899 <para>
|
|
900 La risoluzione nativa DVD è 720x480 per NTSC e 720x576 per PAL, ma c'è un
|
|
901 flag per l'aspetto che indica se è full-screen (4:3) o wide-screen (16:9).
|
|
902 Molti (se non quasi tutti) i DVD in widescreen non sono esattamente 16:9 e
|
|
903 possono essere sia 1.85:1 o 2.35:1 (cinescope). Questo significa che nel video
|
|
904 ci saranno bordi neri che bisogna tagliare via.
|
|
905 </para>
|
|
906
|
|
907 <para>
|
|
908 <application>MPlayer</application> fornisce un filtro che rileva i valori di
|
|
909 taglio e fornisce il rettangolo per crop (<option>-vf cropdetect</option>).
|
|
910 Esegui <application>MPlayer</application> con <option>-vf cropdetect</option> ed
|
|
911 emetterà le impostazioni di taglio per crop al fine di rimuovere i bordi.
|
|
912 Dovresti lasciare andare avanti il film abbastanza da ottenere valori di taglio
|
|
913 precisi.
|
|
914 </para>
|
|
915
|
|
916 <para>
|
|
917 Dopodiché prova con <application>MPlayer</application> i valori ottenuti usando
|
|
918 la linea comando emessa da <option>cropdetect</option>, e correggi il
|
|
919 rettangolo se e come serve.
|
|
920 Il filtro <option>rectangle</option> può esserti di aiuto, dato che ti
|
|
921 permette di impostare interattivamente la posizione del rettangolo di taglio
|
|
922 sopra al filmato.
|
|
923 Ricordati di seguire le linee guida sui multipli in modo da non disallineare
|
|
924 i piani di crominanza.
|
|
925 </para>
|
|
926
|
|
927 <para>
|
|
928 In talune occasioni, il ridimensionamento può essere indesiderabile.
|
|
929 Il ridimensionamento sulla direzione verticale è difficoltoso con video
|
|
930 interlacciato e se vuoi mantenere l'interlacciamento, dovresti evitare il
|
|
931 ridimensionamento.
|
|
932 Se non ridimensionerai, ma vuoi comunque usare dimensioni multiple di 16,
|
|
933 dovrai tagliare di più.
|
|
934 Evita di tagliare di meno, dato che i bordi neri sono un male per la codifica!
|
|
935 </para>
|
|
936
|
|
937 <para>
|
|
938 Dato che MPEG-4 usa macroblocchi 16x16 vorrai esser sicuro che ambedue le
|
|
939 dimensioni del video che stai per codificare siano multiple di 16, altrimenti
|
|
940 perderai in qualità, soprattutto a bitrate più bassi. Puoi farlo abbassando
|
|
941 la larghezza e l'altezza del rettangolo di taglio al multiplo di 16 più vicino.
|
|
942 Come detto precedentemente, quando tagli, vorrai aumentare lo scostamento Y
|
|
943 della metà della differenza tra la nuova e la vecchia altezza, in modo che il
|
|
944 video risultante sia preso dal centro del fotogramma. Inoltre, a causa del modo
|
|
945 in cui il video DVD viene campionato, assicurati che lo scostamento sia un
|
|
946 numero pari. (Infatti, come regola, non utilizzare mai valori dispari per alcun
|
|
947 parametro quando tagli e ridimensioni un video.) Se non ti va di scartare dei
|
|
948 pixel in più, potresti piuttosto preferire il ridimensionamento del video.
|
|
949 Prenderemo in esame questa situazione più avanti.
|
|
950 Puoi in verità lasciare che tutte le considerazioni suddette vengano fatte
|
|
951 dal filtro <option>cropdetect</option>, visto che ha un parametro
|
|
952 <option>round</option> facoltativo, che è impostato a 16 di default.
|
|
953 </para>
|
|
954
|
|
955 <para>
|
|
956 Fai anche attenzione ai pixel "mezzi neri" sui bordi. Assicurati di tagliare
|
|
957 anch'essi, altrimenti sprecherai bit più utili altrove.
|
|
958 </para>
|
|
959
|
|
960 <para>
|
|
961 Dopo aver detto e fatto tutto ciò, probabilmente avrei un vide i cui pixel
|
|
962 non saranno proprio 1.85:1 o 2.35:1, ma piuttosto un valore vicino. Potresti
|
|
963 calcolare a mano il nuovo rapporto di aspetto, ma
|
|
964 <application>MEncoder</application> ha un'opzione per <systemitem
|
|
965 class="library">libavcodec</systemitem> chiamata <option>autoaspect</option>
|
|
966 che lo farà per te. Non aumentare assolutamente le dimensioni del video per
|
|
967 avere i pixel quadrati, a meno che tu non voglia sprecare il tuo spazio disco.
|
|
968 Il ridimensionamento dovrebbe essere eseguito in riproduzione, e per definire
|
|
969 la risoluzione giusta il riproduttore userà l'aspetto memorizzato nell'AVI.
|
|
970 Sfortunatamente non tutti i riproduttori verificano l'informazione sul rapporto
|
|
971 perciò potresti voler comunque effettuare il ridimensionamento.
|
|
972 </para>
|
|
973 </sect2>
|
|
974
|
|
975 <!-- ********** -->
|
|
976
|
|
977 <sect2 id="menc-feat-dvd-mpeg4-resolution-bitrate">
|
|
978 <title>Scegliere la risoluzione e il bitrate</title>
|
|
979
|
|
980 <para>
|
|
981 Other parameters such as scaling, cropping, etc. will
|
|
982 <emphasis role="bold">not</emphasis> alter the file size unless you
|
|
983 change the bitrate as well!.
|
|
984 A meno che tu non stia per codificare con quantizzazione costante devi
|
|
985 impostare un bitrate.
|
|
986 La logica del bitrate è abbastanza semplice.
|
|
987 Normalmente il bitrate viene misurato in kilobit (1000 bit) al secondo.
|
|
988 La dimensione del filmato sul disco è il bitrate moltiplicato per la durata
|
|
989 del filmato, più un piccolo quantitativo in "surplus" (vedi per esempio la
|
|
990 sezione sul
|
|
991 <link linkend="menc-feat-dvd-mpeg4-muxing-avi-limitations">contenitore AVI</link>).
|
|
992 Altri parametri come ridimensionamento, taglio, etc...
|
|
993 <emphasis role="bold">non</emphasis> influiscono sulla dimensione del file a
|
|
994 meno che tu non cambi anche il bitrate!
|
|
995 </para>
|
|
996
|
|
997 <para>
|
|
998 Il bitrate <emphasis role="bold">non</emphasis> è direttamente proporzionale
|
|
999 alla risoluzione.
|
|
1000 Tanto per capirci, un file 320x240 a 200 kbit/sec non avrà la stessa qualità
|
|
1001 dello stesso filmato a 640x480 e 800 kbit/sec!
|
|
1002 Ci sono due ragioni per ciò:
|
|
1003 <orderedlist>
|
|
1004 <listitem><para>
|
|
1005 <emphasis role="bold">Percettiva</emphasis>: noti di più gli artefatti MPEG
|
|
1006 quando sono più grandi!
|
|
1007 Gli artefatti appaiono a livello dei blocchi (8x8).
|
|
1008 Il tuo occhio non noterà errori in 4800 piccoli blocchi tanti quanti ne
|
|
1009 vedrà in 1200 grossi blocchi (assumendo che tu li stia ridimensionando tutti
|
|
1010 e due a schermo intero).
|
|
1011 </para></listitem>
|
|
1012 <listitem><para>
|
|
1013 <emphasis role="bold">Teorica</emphasis> : quando rimpicciolisci un immagine
|
|
1014 ma usi la stessa dimensione dei blocchi (8x8) per la trasformazione spaziale
|
|
1015 della frequenza, hai più dati nelle bande ad alta frequenza. In parole
|
|
1016 povere, ogni pixel contiene più dettagli di quanti ne contenesse prima.
|
|
1017 Quindi anche se la tua immagine rimpicciolita contiene 1/4 delle informazioni
|
|
1018 sulle direzioni spaziali, potrebbe ancora contenere una gran parte delle
|
|
1019 informazioni nel dominio delal frequenza (assumendo che le alte frequenze
|
|
1020 siano sotto-utilizzate nell'immagine di origine a 640x480).
|
|
1021 </para></listitem>
|
|
1022 </orderedlist>
|
|
1023 </para>
|
|
1024
|
|
1025 <para>
|
|
1026 Guide precendenti hanno consigliato di scegliere un bitrate e una risoluzione
|
|
1027 in base ad un approccio "bit al secondo", ma di solito ciò non è valido a
|
|
1028 causa delle ragioni suddette.
|
|
1029 Una stima migliore pare essere che il bitrate è proporzionale alla radice
|
|
1030 quadrata della risoluzione, per cui 320x240 e 400 kbit/sec sarà
|
|
1031 paragonabile a 640x480 a 800 kbit/sec.
|
|
1032 Tuttavia ciò non è stato verificato con certezza empirica o teorica.
|
|
1033 Inoltre, dato che i filmati hanno diversi livelli di disturbo, dettaglio, angoli
|
|
1034 di movimento, etc..., è vano dare consigli generici su bit per lunghezza della
|
|
1035 diagonale (analogamente a bit per pixel, usando la radice quadrata).
|
|
1036 </para>
|
|
1037 <para>
|
|
1038 Finora abbiamo parlato della difficoltà nel scegliere un bitrate e una
|
|
1039 risoluzione.
|
|
1040 </para>
|
|
1041
|
|
1042
|
|
1043 <sect3 id="menc-feat-dvd-mpeg4-resolution-bitrate-compute">
|
|
1044 <title>Calcolare la risoluzione</title>
|
|
1045
|
|
1046 <para>
|
|
1047 I passaggi seguenti ti guideranno nel calcolo della risoluzione per la tua
|
|
1048 codifica senza distorcere troppo il video, tenendo in considerazione vari tipo
|
|
1049 di informazioni riguardo la sorgente video.
|
|
1050 Per prima cosa dovresti calcolare il rapporto di aspetto codificato:
|
|
1051 <systemitem>ARc = (Wc x (ARa / PRdvd )) / Hc</systemitem>
|
|
1052
|
|
1053 <itemizedlist>
|
|
1054 <title>dove:</title>
|
|
1055 <listitem><para>
|
|
1056 Wc e Hc sono la larghezza e l'altezza del video tagliato,
|
|
1057 </para></listitem>
|
|
1058 <listitem><para>
|
|
1059 ARa è il rapporto di aspetto mostrato, che di solito è 4/3 o 16/9,
|
|
1060 </para></listitem>
|
|
1061 <listitem><para>
|
|
1062 PRdvd à il rapporto del pixel del DVD che è uguale a 1.25=(720/576) per DVD
|
|
1063 PAL e 1.5=(720/480) per DVD NTSC.
|
|
1064 </para></listitem>
|
|
1065 </itemizedlist>
|
|
1066 </para>
|
|
1067
|
|
1068 <para>
|
|
1069 Dopo puoi calcolare la risoluzione X e Y, basandoti su un dato fattore
|
|
1070 di qualità di compressione (Compression Quality, CQ):
|
|
1071 <systemitem>ResY = INT(SQRT( 1000*Bitrate/25/ARc/CQ )/16) * 16</systemitem>
|
|
1072 and
|
|
1073 <systemitem>ResX = INT( ResY * ARc / 16) * 16</systemitem>
|
|
1074 </para>
|
|
1075
|
|
1076 <para>
|
|
1077 Okay, ma cos'è la CQ?
|
|
1078 Il CQ rappresenta il numero di bit per pixel e per fotogramma in codifica.
|
|
1079 Parlando più semplicemente, più alto è la CQ, più difficilmente si vedranno
|
|
1080 codificati degli artefatti.
|
25449
|
1081 Tuttavia, se desideri una particolare dimensione per il tuo film (per esempio
|
|
1082 1 o 2 CD), hai un numero limitato di bit da utilizzare; devi quindi trovare un
|
|
1083 buon compromesso tra compressione e qualità.
|
25279
|
1084 </para>
|
|
1085
|
|
1086 <para>
|
|
1087 La CQ dipende dal bitrate, dall'efficienza del codec video e dalla risoluzione
|
|
1088 del filmato.
|
|
1089 Per alzare la CQ, di solito dovrai rimpicciolire il filmato visto che il bitrate
|
|
1090 viene calcolato in funzione della dimensione voluta e della lunghezza del
|
|
1091 filmato, che sono delle costanti.
|
|
1092 Con codec MPEG-4 ASP come <systemitem class="library">Xvid</systemitem> e
|
|
1093 <systemitem class="library">libavcodec</systemitem>, una CQ inferiore a 0.18
|
|
1094 solitamente genera un'immagine abbastanza squadrettata, perché non ci sono
|
|
1095 abbastanza bit per codificare l'informazione di ogni macroblocco. (MPEG4, come
|
|
1096 molti altri codec, ragruppa i pixel in blocchi di pixel per comprimere
|
|
1097 l'immagine; se non ci sono abbastanza bit, si vedono i bordi dei blocchi.)
|
|
1098 E' saggio anche prendere una CQ compresa tra 0.20 e 0.22 per un rip a 1 CD,
|
|
1099 e 0.26-0.28 per un rip a 2 CD con impostazioni standard di codifica.
|
|
1100 Opzioni più evolute di codifica come quelle qui indicate per
|
|
1101 <link linkend="menc-feat-mpeg4-lavc-example-settings"><systemitem class="library">libavcodec</systemitem></link>
|
|
1102 e
|
|
1103 <link linkend="menc-feat-xvid-example-settings"><systemitem class="library">Xvid</systemitem></link>
|
|
1104 dovrebbero permetterti di ottenere la stessa qualità con CQ compresa tra
|
|
1105 0.18 e 0.20 per un rip da 1 CD, e da 0.24 a 0.26 per 2 CD.
|
|
1106 Con codec MPEG-4 AVC come <systemitem class="library">x264</systemitem>,
|
|
1107 puoi usare una CQ che varia da 0.14 a 0.16 con opzioni standard di codifica, e
|
|
1108 dovresti riuscire a scendere tra 0.10 e 0.12 con <link linkend="menc-feat-x264-example-settings">impostazioni avanzate di codifica
|
|
1109 <systemitem class="library">x264</systemitem></link>.
|
|
1110 </para>
|
|
1111
|
|
1112 <para>
|
|
1113 Prendi per favore nota che CQ è solo un valore indicativo, dato che dipende dal
|
|
1114 contenuto che viene codificato, una CQ di 0.18 può andar bene per un Bergman,
|
|
1115 mentre per un film come Matrix, che contiene molte scene ad alta velocità, no.
|
|
1116 D'altro canto è inutile portare la CQ oltre 0.30 dato che sprecherai dei bit
|
|
1117 senza avere alcun guadagno visibile in qualità.
|
|
1118 Nota anche che come detto precedentemente in questa guida, per video a bassa
|
|
1119 risoluzione serve una CQ più alta (in rapporto, per esempio, alla risoluzione
|
|
1120 DVD) perché si vedano bene.
|
|
1121 </para>
|
|
1122 </sect3>
|
|
1123 </sect2>
|
|
1124
|
|
1125 <!-- ********** -->
|
|
1126
|
|
1127 <sect2 id="menc-feat-dvd-mpeg4-filtering">
|
|
1128 <title>Filtraggio</title>
|
|
1129
|
|
1130 <para>
|
|
1131 Imparare come usare i filtri video di <application>MEncoder</application> è
|
|
1132 essenziale per produrre delle buone codfiche.
|
|
1133 Tutta l'elaborazione video è eseguita attraverso i filtri -- taglio,
|
|
1134 ridimensionamento, aggiustamento del colore, rimozione del disturbo, rilevamento
|
|
1135 margini, deinterlacciatura, telecine, telecine inverso, e deblocco, solo per
|
|
1136 nominarne qualcuno.
|
|
1137 Insieme con la vasta gamma di formati di entrata gestiti, la varietà dei
|
|
1138 filtri disponibili in <application>MEncoder</application> è uno dei suoi
|
|
1139 più grandi vantaggi sugli altri programmi similari.
|
|
1140 </para>
|
|
1141
|
|
1142 <para>
|
|
1143 I filtri vengono caricati in catena usando l'opzione -vf:
|
|
1144
|
|
1145 <screen>-vf filtro1=opzioni,filtro2=opzioni,...</screen>
|
|
1146
|
|
1147 La maggior parte dei filtri riceve alcune opzioni numeriche separate da due
|
|
1148 punti, ma la sintassi per le opzioni cambia da filtro a filtro, indi leggiti la
|
|
1149 pagina man per i dettagli sul filtro che desideri usare.
|
|
1150 </para>
|
|
1151
|
|
1152 <para>
|
|
1153 I filtri lavorano sul video nell'ordine in cui vengono caricati.
|
|
1154 Per esempio la catena seguente:
|
|
1155
|
|
1156 <screen>-vf crop=688:464:12:4,scale=640:464</screen>
|
|
1157
|
|
1158 dapprima taglia la zona 688x464 dell'immagine con uno scostamento dall'alto a
|
|
1159 sinistra di (12,4), e poi ridimensiona il risultato a 640x464.
|
|
1160 </para>
|
|
1161
|
|
1162 <para>
|
|
1163 Taluni filtri devono essere caricati all'inizio o vicino all'inizio della
|
|
1164 catena di filtri, in modo da trarre vantaggio dalle informazioni che arrivano
|
|
1165 dal decoder video, che potrebbero essere perse o invalidate da altri filtri.
|
|
1166 Gli esempi principali sono <option>pp</option> (post elaborazione
|
|
1167 (postprocessing), solo quando esegue operazioni di deblock o dering),
|
|
1168 <option>spp</option> (un altra post elaborazione per eliminare artefatti MPEG),
|
|
1169 <option>pullup</option> (telecine inverso), e <option>softpulldown</option>
|
|
1170 (per passare da telecine soft a hard).
|
|
1171 </para>
|
|
1172
|
|
1173 <para>
|
|
1174 In generale vorrai filtrare il meno possibile in modo da rimaner fedele alla
|
|
1175 sorgente DVD originale. Il taglio è spesso necessario (com detto sopra), ma
|
|
1176 evita di ridimensionare il video. Anche se alcune volte si preferisce
|
|
1177 rimpicciolire per poter usare quantizzatori più alti, vogliamo evitare ciò:
|
|
1178 ricorda che abbiamo sin dall'inizio deciso di investire bit in qualità.
|
|
1179 </para>
|
|
1180
|
|
1181 <para>
|
|
1182 In più, non reimpostare la gamma, il contrasto, la luminosità, etc...
|
|
1183 Quello che si vede bene sul tuo schermo potrebbe non vedersi bene su altro.
|
|
1184 Queste modifiche dovrebbero esser fatte solo durante la riproduzione.
|
|
1185 </para>
|
|
1186
|
|
1187 <para>
|
|
1188 Una cosa che voresti però fare è tuttavia far passare il video attraverso un
|
|
1189 leggero filtro di rimozione disturbo, come <option>-vf hqdn3d=2:1:2</option>.
|
|
1190 Ancora, è una questione di poter meglio utilizzare quei bit: perché sprecarli
|
|
1191 codificando disturbo mentre puoi semplicemente aggiungerlo di nuovo durante la
|
|
1192 riproduzione? Alzando i parametri per <option>hqdn3d</option> aumenterà
|
|
1193 ancora la compressione, ma se aumenti troppo i valori, rischi un degrado pesante
|
|
1194 dell'immagine. I valori sopra consigliati (<option>2:1:2</option>) sono
|
|
1195 abbastanza conservativi; sentiti libero di sperimentare con valori più alti e
|
|
1196 verificare da solo il risultato.
|
|
1197 </para>
|
|
1198 </sect2>
|
|
1199
|
|
1200 <!-- ********** -->
|
|
1201
|
|
1202 <sect2 id="menc-feat-dvd-mpeg4-interlacing">
|
|
1203 <title>Interlacciamento e Telecine</title>
|
|
1204
|
|
1205 <para>
|
|
1206 Quasi tutti i film vengono ripresi a 24 fps. Dato che NTSC è 30000/1001 fps,
|
|
1207 si devono eseguire alcune elaborazioni affinché questo video a 24 fps sia
|
|
1208 letto al giusto framerate NTSC. Il processo è chiamato "3:2 pulldown", meglio
|
|
1209 conosciuto come "telecine" (poiché pulldown viene spesso applicato durante il
|
|
1210 processo di telecine), e descritto rozzamente, agisce rallentando il film a
|
|
1211 24000/1001 fps, e ripetendo ogni quarto fotogramma.
|
|
1212 </para>
|
|
1213
|
|
1214 <para>
|
|
1215 Non viene invece eseguita alcuna elaborazione sul video per i DVD PAL, che
|
|
1216 girano a 25 fps. (Tecnicamente, PAL può subire il telecine, chiamato
|
|
1217 "2:2 pulldown", ma non è usanza abituale.) Il film a 24 fps viene
|
|
1218 semplicemente riprodotto a 25 fps. Il risultato è che il filmato è leggermente
|
|
1219 più veloce, ma a meno che tu non sia un alieno, probabilmente non noterai la
|
|
1220 differenza.
|
|
1221 La maggior parte dei DVD PAL hanno audio corretto ai picchi, in modo che quando
|
|
1222 siano riprodotti a 25 fps le cose suonino giuste, anche se la traccia audio
|
|
1223 (e quindi tutto il filmato) ha un tempo di riproduzione che è il 4% inferiore
|
|
1224 ai DVD NTSC.
|
|
1225 </para>
|
|
1226
|
|
1227 <para>
|
|
1228 A causa del fatto che il video nei DVD PAL non è stato alterato, non dovrai
|
|
1229 preoccuperti molto della frequenza fotogrammi. La sorgente è 25 fps, e il tuo
|
|
1230 rip sarà a 25 fps. Tuttavia, se stai codificando un film da DVD NTSC,
|
|
1231 potresti dover applicare il telecine inverso.
|
|
1232 </para>
|
|
1233
|
|
1234 <para>
|
|
1235 Per film ripresi a 24 fps, il video sul DVD NTSC è o con telecine a 30000/1001,
|
|
1236 oppure è progressivo a 24000/1001 fps e destinato a subire il telecine al volo
|
|
1237 da un lettore DVD. D'altro canto le serie TV sono solitamente solo
|
|
1238 interlacciate, senza telecine. Questa non è una regola ferrea: alcune serie TV
|
|
1239 sono interlacciate (come Buffy the Vampire Slayer) mentre alcune sono un misto
|
|
1240 di progressivo e interlacciato (come Angel, o 24).
|
|
1241 </para>
|
|
1242
|
|
1243 <para>
|
|
1244 Si consiglia vivamente di leggere la sezione su
|
|
1245 <link linkend="menc-feat-telecine">Come trattare il telecine e l'interlacciamento nei DVD NTSC</link>
|
|
1246 per imparare come gestire le varie possibilità.
|
|
1247 </para>
|
|
1248
|
|
1249 <para>
|
|
1250 Ciononostante, se stai principalmente rippando solo film, solitamente ti
|
|
1251 troverai di fronte a video a 24 fps progressivo o con telecine, nel qual caso
|
|
1252 puoi usare il filtro <option>pullup</option> <option>-vf
|
|
1253 pullup,softskip</option>.
|
|
1254 </para>
|
|
1255 </sect2>
|
|
1256
|
|
1257 <!-- ********** -->
|
|
1258
|
|
1259 <sect2 id="menc-feat-dvd-mpeg4-encoding-interlaced">
|
|
1260 <title>Codificare video interlacciato</title>
|
|
1261
|
|
1262 <para>
|
|
1263 Se il film che vuoi codificare è interlacciato (video NTSC o PAL) dovrai
|
|
1264 scegliere se vuoi de-interlacciare o no.
|
|
1265 Se da un lato de-interlacciare renderà il tuo filmato utilizzabile su
|
|
1266 schermi a scansione progressiva come monitor di computer o proiettori, porta
|
|
1267 con sé un costo: la frequenza dei campi di 50 o 60000/1001 campi al secondo
|
|
1268 viene dimezzata a 25 o 30000/1001 fotogrammi al secondo, e circa la metà delle
|
|
1269 informazioni nel tuo film saranno perdute, in scene con movimento significativo.
|
|
1270 </para>
|
|
1271
|
|
1272 <para>
|
|
1273 Per di più, se stai codificando puntando ad alta qualità di archiviazione.
|
|
1274 si consiglia di non de-interlacciare.
|
|
1275 Puoi sempre de-interlacciare il film durante la riproduzione attraverso
|
|
1276 dispositivi a scansione progressiva.
|
|
1277 La potenza dei computer attuali forza per i riproduttori l'utilizzo di un filtro
|
|
1278 di de-interlacciamento, che porta un leggero degrado dell'immagine.
|
|
1279 Ma i lettori del futuro saranno in grado di simulare lo schermo di una TV,
|
|
1280 de-interlacciando a piena frequenza di campi e interpolando 50 o 60000/1001
|
|
1281 fotogrammi interi al secondo dal video interlacciato
|
|
1282 </para>
|
|
1283
|
|
1284 <para>
|
|
1285 Bisogna porre speciale attenzione quando si lavora con video interlacciato:
|
|
1286 </para>
|
|
1287
|
|
1288 <orderedlist>
|
|
1289 <listitem><para>
|
|
1290 Altezza e scostamento del taglio devono essere multipli di 4.
|
|
1291 </para></listitem>
|
|
1292 <listitem><para>
|
|
1293 Qualsiasi ridimensionamento verticale va fatto in modalità interlacciata.
|
|
1294 </para></listitem>
|
|
1295 <listitem><para>
|
|
1296 I filtri di post elaborazione e di rimozione disturbo potrebbero non
|
|
1297 funzionare come ci si aspetta a meno che tu non ponga particolare attenzione
|
|
1298 per farli lavorare su un campo per volta, e possono rovinare il video quando
|
|
1299 usati in modo non corretto.
|
|
1300 </para></listitem>
|
|
1301 </orderedlist>
|
|
1302
|
|
1303 <para>
|
|
1304 Tenendo a mente queste cose, ecco il nostro primo esempio:
|
|
1305 <screen>
|
|
1306 mencoder <replaceable>capture.avi</replaceable> -mc 0 -oac lavc -ovc lavc -lavcopts \
|
|
1307 vcodec=mpeg2video:vbitrate=6000:ilme:ildct:acodec=mp2:abitrate=224
|
|
1308 </screen>
|
|
1309 Nota le opzioni <option>ilme</option> e <option>ildct</option>.
|
|
1310 </para>
|
|
1311 </sect2>
|
|
1312
|
|
1313 <!-- ********** -->
|
|
1314
|
|
1315 <sect2 id="menc-feat-dvd-mpeg4-av-sync">
|
25449
|
1316 <title>Note sulla sincronizzazione Audio/Video</title>
|
|
1317
|
|
1318 <para>
|
|
1319 Gli algoritmi di sincronizzazione audio/video di
|
|
1320 <application>MEncoder</application> sono stati progettati con l'intento di
|
|
1321 recuperare file con sincronia danneggiata.
|
|
1322 In alcuni casi tuttavia, possono generare inutili duplicazioni o scarti di
|
|
1323 fotogrammi, e possibilmente leggera desincronia A/V quando vengono usati con
|
|
1324 sorgenti buone (i problemi di sincronizzazione A/V accadono solo se elabori o
|
|
1325 copi la traccia audio mentre transcodifichi il video, il che è decisamente
|
|
1326 consigliato).
|
|
1327 Perciò potresti dover passare ad una sincronizzazione di base con l'opzione
|
|
1328 <option>-mc 0</option>, o metterla nel tuo file di configurazione
|
|
1329 <systemitem>~/.mplayer/mencoder</systemitem>, sempre che tu stia lavorando con
|
|
1330 buone sorgenti (DVD, acquisizione TV, rip MPEG-4 ad alta qualità, etc) e non
|
|
1331 con file ASF/RM/MOV rovinati.
|
|
1332 </para>
|
|
1333
|
|
1334 <para>
|
|
1335 Se vuoi proteggerti ulteriormente da strani salti e duplicazioni di fotogrammi,
|
|
1336 puoi usare sia <option>-mc 0</option> che <option>-noskip</option>.
|
|
1337 Questo disabiliterà <emphasis>tutte</emphasis> le sincronizzazioni A/V, e
|
|
1338 copierà i fotogrammi uno ad uno, perciò è inutilizzabile se stai usando dei
|
|
1339 filtri che aggiungono o rimuovono arbitrariamente fotogrammi, ovvero se il
|
|
1340 tuo file sorgente ha una frequenza fotogrammi non costante!
|
|
1341 Quindi l'utilizzo di <option>-noskip</option> in linea di massima si sconsiglia.
|
|
1342 </para>
|
|
1343
|
|
1344 <para>
|
|
1345 Si sa che la cosiddetta codifica audio in "tre passi", che
|
|
1346 <application>MEncoder</application> gestisce, può causare desincronizzazione
|
|
1347 A/V.
|
|
1348 Il che capiterà prontamente se viene usata insieme con alcuni filtri, per cui
|
|
1349 si consiglia di <emphasis>non</emphasis> usare la modalità audio a tre passi.
|
|
1350 Questa caratteristica viene lasciata solo per finalità di compatibilità e
|
|
1351 per utenti esperti che sanno quando sia adeguato usarla e quando no.
|
|
1352 Se non hai mai sentito parlar prima della modalità a tre passi, dimenticati
|
|
1353 di averla anche solo sentita nominare!
|
|
1354 </para>
|
|
1355
|
|
1356 <para>
|
|
1357 Ci sono anche stati rapporti di desincronia A/V codificando con
|
|
1358 <application>MEncoder</application> da stdin.
|
|
1359 Non farlo! Usa sempre come ingresso un file o un dispositivo CD/DVD/etc.
|
25279
|
1360 </para>
|
|
1361 </sect2>
|
|
1362
|
|
1363 <!-- ********** -->
|
|
1364
|
|
1365 <sect2 id="menc-feat-dvd-mpeg4-codec">
|
25449
|
1366 <title>Scegliere il codec video</title>
|
|
1367
|
|
1368 <para>
|
|
1369 Quale possa esere il miglior codec video dipende da molti fattori, come
|
|
1370 dimensione, qualità, possibilita di farne lo streaming, usabilit, diffusione,
|
|
1371 alcuni dei quali dipendono fortemente dai gusti personali e dalle variabili
|
|
1372 tecniche in gioco.
|
25279
|
1373 </para>
|
|
1374 <itemizedlist>
|
|
1375 <listitem>
|
|
1376 <para>
|
25449
|
1377 E' abbastanza facile da capire che i codec più recenti sono fatti per
|
|
1378 aumentare qualità e compressione.
|
|
1379 Quindi gli autori di questa guida e moltra altra gente suggeriscono che non
|
|
1380 potete sbagliare
|
25279
|
1381 <footnote id='fn-menc-feat-dvd-mpeg4-codec-cpu'><para>
|
25449
|
1382 Fai comunque attenzione: la decodifica di video MPEG-4 AVC a risoluzione DVD
|
|
1383 richiede una macchina veloce (per es. un Pentium 4 oltre 1.5GHz o un Pentium
|
|
1384 M superiore a 1GHz).
|
25279
|
1385 </para></footnote>
|
25449
|
1386 quando scegliete un qualche codec MPEG-4 AVC come
|
|
1387 <systemitem class="library">x264</systemitem> piuttosto che un codec MPEG-4
|
|
1388 ASP come l'MPEG-4 di <systemitem class="library">libavcodec</systemitem> o
|
25279
|
1389 <systemitem class="library">Xvid</systemitem>.
|
25449
|
1390 (Per sviluppatori avenzati di codec potrebbe essere interessante leggere
|
|
1391 l'opinione di Michael Niedermayer sul
|
|
1392 "<ulink url="http://guru.multimedia.cx/?p=10">perché MPEG-4 ASP faccia schifo</ulink>"
|
|
1393 (in inglese).)
|
|
1394 Analogamente dovresti ottenere una miglior qualità usando MPEG-4 ASP rispetto
|
|
1395 a quella ottenuta con codec MPEG-2.
|
25279
|
1396 </para>
|
|
1397
|
|
1398 <para>
|
25449
|
1399 Tuttavia, i codec più recenti che sono sotto pesante sviluppo possono avere
|
|
1400 problemi che non sono ancora stati scoperti, e che possono rovinare una
|
|
1401 codifica.
|
|
1402 Questo è semplicemente il contrappasso per usare la tecnologia di punta.
|
25279
|
1403 </para>
|
|
1404
|
|
1405 <para>
|
25449
|
1406 Inoltre iniziare ad utilizzare un codec nuovo richiede l'utilizzo di un po'
|
|
1407 di tempo per familiarizzare con le sue opzioni, affinché tu sappia cosa
|
|
1408 impostare per ottenere la qualità dell'immagine voluta.
|
25279
|
1409 </para>
|
|
1410 </listitem>
|
|
1411
|
|
1412 <listitem><para>
|
25449
|
1413 <emphasis role="bold">Compatibilità Hardware</emphasis>:
|
|
1414 Solitamente ci va un po' di tempo prima che i lettori da tavolo incomincino ad
|
|
1415 includere il supporto per il video codec più recente.
|
|
1416 Il risultato è che la maggior parte legge MPEG-1 (come i VCD, XVCD e KVCD),
|
|
1417 MPEG-2 (come DVD, SVCD e KVCD) e MPEG-4 ASP (come DivX,
|
|
1418 LMP4 di <systemitem class="library">libavcodec</systemitem> e
|
25279
|
1419 <systemitem class="library">Xvid</systemitem>)
|
25449
|
1420 (attenzione: solitamente non sono gestite tutte le caratteristiche
|
|
1421 MPEG-4 ASP).
|
|
1422 Fai per favore riferimento alle specifiche tecniche del tuo lettore (ove
|
|
1423 disponibili) o cerca su internet per ulteriori informazioni.
|
25279
|
1424 </para></listitem>
|
|
1425
|
|
1426 <listitem>
|
|
1427 <para>
|
25449
|
1428 <emphasis role="bold">Miglior qualità per tempo di codifica</emphasis>:
|
|
1429 Codec che sono in giro da parecchio tempo (come MPEG-4 di
|
|
1430 <systemitem class="library">libavcodec</systemitem> e
|
|
1431 <systemitem class="library">Xvid</systemitem>) sono spesso molto ottimizzati
|
|
1432 con ogni tipo di algoritmo furbo e codice SIMD in assembly.
|
|
1433 Per questo tendono a fornire il miglior rapporto tra qualità e tempo di
|
|
1434 codifica. Tuttavia, possono avere delle opzioni avanzate che, quando
|
|
1435 abilitate, rendono la codifica molto lenta fornendo poco guadagno.
|
25279
|
1436 </para>
|
|
1437
|
|
1438 <para>
|
25449
|
1439 Se stai cercando di incrementare la velocità dovresti cercare di non
|
|
1440 modificare troppo le impostazioni di default del codec video (anche se
|
|
1441 dovresti comunque provare le altre opzioni che sono citate in altre sezioni
|
|
1442 di questa guida).
|
25279
|
1443 </para>
|
|
1444
|
|
1445 <para>
|
25449
|
1446 Puoi tenere in considerazione anche la scelta di un codec che possa eseguire
|
|
1447 elaborazioni multi-thread, anche se ciò è utile solo per utenti di macchine
|
|
1448 con più di una CPU.
|
|
1449 MPEG-4 di <systemitem class="library">libavcodec</systemitem> lo permette,
|
|
1450 ma il guadagno in velocità è limitato, e c'è un leggere effetto negativo
|
|
1451 sulla qualità dell'immagine.
|
|
1452 La codifica multi-thread di <systemitem class="library">Xvid</systemitem>,
|
|
1453 attivata dall'opzione <option>threads</option>, può essere usata per
|
|
1454 accelerare la velocità di codifica — tipicamente di circa il 40-60%
|
|
1455 — con poco se non nessun degrado dell'immagine.
|
|
1456 Anche <systemitem class="library">x264</systemitem> permette la codifica in
|
|
1457 multi-thread, la quale attualmente velocizza la codifica del 94% per core di
|
|
1458 CPU mentre abbassa il PSNR tra 0.005dB e 0.01dB, con impostazioni tipiche.
|
25279
|
1459 </para>
|
|
1460 </listitem>
|
|
1461
|
|
1462 <listitem>
|
|
1463 <para>
|
25449
|
1464 <emphasis role="bold">Gusto personale</emphasis>:
|
|
1465 Qui è dove capita l'irrazionale: per la stessa ragione per cui alcuni
|
|
1466 restano attaccati a DivX 3 per anni, mentre nuovi codec stanno
|
|
1467 facendo meraviglie, alcuni personaggi preferiranno
|
|
1468 <systemitem class="library">Xvid</systemitem> o MPEG-4 di
|
|
1469 <systemitem class="library">libavcodec</systemitem> a
|
25279
|
1470 <systemitem class="library">x264</systemitem>.
|
|
1471 </para>
|
|
1472 <para>
|
25449
|
1473 Dovresti prendere le tue decisioni; non prendere consigli da gente che
|
|
1474 fanno giuramenti su un codec.
|
|
1475 Prendi alcuni pezzi di esempio da sorgenti grezze e compara le diverse
|
|
1476 opzioni di codifica e di codec per trovare quello che ti garba di più.
|
|
1477 Il miglior codec è quello che riesci a gestire al meglio, e quello che ai
|
|
1478 tuoi occhi e sul tuo schermo si vede meglio.
|
25279
|
1479 <footnote id='fn-menc-feat-dvd-mpeg4-codec-playback'><para>
|
25449
|
1480 La stessa codifica potrebbe non apparire uguale sullo schermo di qualcun
|
|
1481 altro o se riprodotta con un decodificatore differente, perciò controlla
|
|
1482 i tuoi risultati riproducendoli in diverse condizioni.
|
25279
|
1483 </para></footnote>!
|
|
1484 </para>
|
|
1485 </listitem>
|
|
1486 </itemizedlist>
|
|
1487
|
|
1488 <para>
|
25449
|
1489 Fai per favore riferimento alla sezione
|
|
1490 <link linkend="menc-feat-selecting-codec">selezionare codec e formati contenitore</link>
|
|
1491 per avere un elenco dei codec usabili.
|
25279
|
1492 </para>
|
|
1493 </sect2>
|
|
1494
|
|
1495 <!-- ********** -->
|
|
1496
|
|
1497 <sect2 id="menc-feat-dvd-mpeg4-audio">
|
|
1498 <title>Audio</title>
|
|
1499
|
|
1500 <para>
|
25449
|
1501 L'audio è un problema di decisamente più facile soluzione: se ti interessa la
|
|
1502 qualità, lascialo semplicemente com'è.
|
|
1503 Anche i flussi AC-3 5.1 sono al massimo a 448Kbit/s, e ne valgono ogni bit.
|
|
1504 Potresti esser tentato di trascodificare l'audio in Vorbis ad alta qualità, ma
|
|
1505 solo perché a tutt'oggi non hai un decodificatore AC-3 pass-through ciò non
|
|
1506 significa che non ne avrai uno in futuro. Assicura un futuro ai tuoi rip da DVD
|
|
1507 preservando il flusso in AC-3.
|
|
1508 Puoi mantenere il flusso AC-3 anche copiandolo direttamente nel flusso video
|
|
1509 <link linkend="menc-feat-mpeg4">durante la codifica</link>.
|
|
1510 Puoi anche estrarre il flusso AC-3 al fine di farne il mux in contenitori come
|
|
1511 NUT o Matroska.
|
25279
|
1512 <screen>
|
25449
|
1513 mplayer <replaceable>file_sorgente.vob</replaceable> -aid 129 -dumpaudio -dumpfile <replaceable>suono.ac3</replaceable>
|
25279
|
1514 </screen>
|
25449
|
1515 effettuerà il dump della traccia audio numero 129 dal file
|
|
1516 <replaceable>file_sorgente.vob</replaceable> nel file
|
|
1517 <replaceable>suono.ac3</replaceable> (NB: i file VOB da DVD spesso usano una
|
|
1518 numerazione dell'audio diversa, il che significa che la traccia audio 129 è la
|
|
1519 seconda traccia del file).
|
|
1520 </para>
|
|
1521
|
|
1522 <para>
|
|
1523 Alcune volte invece, non hai davvero altra scelta se non comprimere
|
|
1524 ulteriormente il suono per poter usare più bit per il video.
|
|
1525 La maggior parte delle persone sceglie di comprimere l'audio con i codec MP3
|
|
1526 ovvero Vorbis.
|
|
1527 Mentre quest'ultimo è un codec decisamente efficiente per lo spazio, MP3 è
|
|
1528 meglio supportato dai lettori da tavolo, anche se la situazione sta cambiando.
|
|
1529 </para>
|
|
1530
|
|
1531 <para>
|
|
1532 <emphasis>Non</emphasis> usare <option>-nosound</option> mentre codifichi un
|
|
1533 file con dell'audio, anche se farai la codifica e il mux dell'audio
|
|
1534 separatamente in seguito.
|
|
1535 Anche se potesse andar bene in casi ideali, facilmente usare
|
|
1536 <option>-nosound</option> nasconderà alcuni problemi nelle tue impostazioni di
|
|
1537 codifica sulla riga comando.
|
|
1538 In altre parole mantenere la colonna sonora durante la codifica ti assicura,
|
|
1539 a patto che tu non veda messaggi del tipo
|
|
1540 <quote>Troppi pacchetti audio nel buffer</quote>, di ottenere un'adeguata
|
|
1541 sincronizzazione.
|
|
1542 </para>
|
|
1543
|
|
1544 <para>
|
|
1545 Devi fare in modo che <application>MEncoder</application> processi il suono.
|
|
1546 Puoi per esempio copiare la colonna sonora originaria durante la codifica con
|
|
1547 <option>-oac copy</option>, o convertirla in un "leggero" PCM WAV mono a 4 kHz
|
|
1548 con <option>-oac pcm -channels 1 -srate 4000</option>.
|
|
1549 In caso contrario in alcuni casi verrà generato un file video che sarà
|
|
1550 desincronizzato con l'audio.
|
|
1551 Casi del genere sono quelli in cui il numero dei fotogrammi video nel file di
|
|
1552 origine non corrisponde alla lunghezza totale dei fotogrammi audio oppure
|
|
1553 ogniqualvolta vi siano delle discontinuità/splice in cui mancano o ci sono
|
|
1554 fotogrammi audio in più.
|
|
1555 Il modo giusto di gestire questo tipo di problemi è inserire del silenzio o
|
|
1556 tagliare l'audio in quei punti.
|
|
1557 Tuttavia <application>MPlayer</application> non è in grado di farlo, per cui se
|
|
1558 fai il demux dell'audio AC-3 e lo codifichi con un'altro programma (o ne fai il
|
|
1559 dump in PCM con <application>MPlayer</application>), gli splice rimarranno
|
|
1560 sbagliati e l'unico modo per correggerli è scartare/duplicare fotogrammi video
|
|
1561 nel punto di splice.
|
|
1562 Fintantochè <application>MEncoder</application> vede l'audio mentre codifica il
|
|
1563 video, può eseguire questo scarto/duplicazione (che solitamente è OK, dato che
|
|
1564 capita con scene nere o cambi scena), ma se <application>MEncoder</application>
|
|
1565 non vede l'audio, processerà i fotogrammi così come sono e alla fine non
|
|
1566 corrisponderanno al flusso audio finale quando per esempio inserirai i flussi
|
|
1567 audio e video dentro a un file Matroska.
|
|
1568 </para>
|
|
1569
|
|
1570 <para>
|
|
1571 Prima di tutto dovrai convertire l'audio DVD in un file WAV che il codec audio
|
|
1572 possa usare come ingresso.
|
|
1573 Per esempio:
|
25279
|
1574 <screen>
|
25449
|
1575 mplayer <replaceable>file_sorgente.vob</replaceable> -ao pcm:file=<replaceable>suono_destinazione.wav</replaceable> \
|
25279
|
1576 -vc dummy -aid 1 -vo null
|
|
1577 </screen>
|
25449
|
1578 eseguirà il dump della seconda traccia audio dal file
|
|
1579 <replaceable>file_sorgente.vob</replaceable> sul file
|
|
1580 <replaceable>suono_destinazione.wav</replaceable>.
|
|
1581 Potresti voler normalizzare il suono prima della codifica, visto che le tracce
|
|
1582 audio dei DVD spesso sono registrate a volumi bassi.
|
|
1583 Puoi usare per esempio lo strumento <application>normalize</application>, che
|
|
1584 è disponibile nella maggior parte delle distribuzioni.
|
|
1585 Se stai usando Windows, lo stesso mestiere lo può fare uno strumento tipo
|
|
1586 <application>BeSweet</application>.
|
|
1587 Effettuerai la compressione in Vorbis ovvero in MP3.
|
|
1588
|
|
1589 Per esempio:
|
|
1590 <screen>oggenc -q1 <replaceable>suono_destinazione.wav</replaceable></screen>
|
|
1591 codificherà <replaceable>suono_destinazione.wav</replaceable> con qualità
|
|
1592 di codifica 1, che equivale circa a 80Kb/s, ed è la qualità minima in cui
|
|
1593 dovresti codificare se ti interessa la qualità.
|
|
1594 Fai per favore attenzione che attualmente <application>MEncoder</application>
|
|
1595 non è in grado di fare il mux di tracce audio Vorbis nel file di uscita,
|
|
1596 perché gestisce solo contenitori AVI e MPEG in uscita, ognuno dei quali può
|
|
1597 portare a problemi di sincronizzazione audio/video durante la riproduzione con
|
|
1598 alcuni lettori quando il file AVI contiene flussi audio VBR come Vorbis.
|
|
1599 Non preoccuparti, questa documentazione ti mostrerà come tu possa farlo
|
|
1600 comunque con programmi di terze parti.
|
25279
|
1601 </para>
|
|
1602 </sect2>
|
|
1603
|
|
1604 <!-- ********** -->
|
|
1605
|
|
1606 <sect2 id="menc-feat-dvd-mpeg4-muxing">
|
|
1607 <title>Muxing</title>
|
|
1608
|
|
1609 <para>
|
|
1610 Now that you have encoded your video, you will most likely want
|
|
1611 to mux it with one or more audio tracks into a movie container, such
|
|
1612 as AVI, MPEG, Matroska or NUT.
|
|
1613 <application>MEncoder</application> is currently only able to natively output
|
|
1614 audio and video into MPEG and AVI container formats.
|
|
1615 for example:
|
|
1616 <screen>
|
|
1617 mencoder -oac copy -ovc copy -o <replaceable>output_movie.avi</replaceable> \
|
|
1618 -audiofile <replaceable>input_audio.mp2</replaceable> <replaceable>input_video.avi</replaceable>
|
|
1619 </screen>
|
|
1620 This would merge the video file <replaceable>input_video.avi</replaceable>
|
|
1621 and the audio file <replaceable>input_audio.mp2</replaceable>
|
|
1622 into the AVI file <replaceable>output_movie.avi</replaceable>.
|
|
1623 This command works with MPEG-1 layer I, II and III (more commonly known
|
|
1624 as MP3) audio, WAV and a few other audio formats too.
|
|
1625 </para>
|
|
1626
|
|
1627 <para>
|
|
1628 <application>MEncoder</application> features experimental support for
|
|
1629 <systemitem class="library">libavformat</systemitem>, which is a
|
|
1630 library from the FFmpeg project that supports muxing and demuxing
|
|
1631 a variety of containers.
|
|
1632 For example:
|
|
1633 <screen>
|
|
1634 mencoder -oac copy -ovc copy -o <replaceable>output_movie.asf</replaceable> -audiofile <replaceable>input_audio.mp2</replaceable> \
|
|
1635 <replaceable>input_video.avi</replaceable> -of lavf -lavfopts format=asf
|
|
1636 </screen>
|
|
1637 This will do the same thing as the previous example, except that
|
|
1638 the output container will be ASF.
|
|
1639 Please note that this support is highly experimental (but getting
|
|
1640 better every day), and will only work if you compiled
|
|
1641 <application>MPlayer</application> with the support for
|
|
1642 <systemitem class="library">libavformat</systemitem> enabled (which
|
|
1643 means that a pre-packaged binary version will not work in most cases).
|
|
1644 </para>
|
|
1645
|
|
1646
|
|
1647 <sect3 id="menc-feat-dvd-mpeg4-muxing-filter-issues">
|
|
1648 <title>Improving muxing and A/V sync reliability</title>
|
|
1649
|
|
1650 <para>
|
|
1651 You may experience some serious A/V sync problems while trying to mux
|
|
1652 your video and some audio tracks, where no matter how you adjust the
|
|
1653 audio delay, you will never get proper sync.
|
|
1654 That may happen when you use some video filters that will drop or
|
|
1655 duplicate some frames, like the inverse telecine filters.
|
|
1656 It is strongly encouraged to append the <option>harddup</option> video
|
|
1657 filter at the end of the filter chain to avoid this kind of problem.
|
|
1658 </para>
|
|
1659
|
|
1660 <para>
|
|
1661 Without <option>harddup</option>, if <application>MEncoder</application>
|
|
1662 wants to duplicate a frame, it relies on the muxer to put a mark on the
|
|
1663 container so that the last frame will be displayed again to maintain
|
|
1664 sync while writing no actual frame.
|
|
1665 With <option>harddup</option>, <application>MEncoder</application>
|
|
1666 will instead just push the last frame displayed again into the filter
|
|
1667 chain.
|
|
1668 This means that the encoder receives the <emphasis>exact</emphasis>
|
|
1669 same frame twice, and compresses it.
|
|
1670 This will result in a slightly bigger file, but will not cause problems
|
|
1671 when demuxing or remuxing into other container formats.
|
|
1672 </para>
|
|
1673
|
|
1674 <para>
|
|
1675 You may also have no choice but to use <option>harddup</option> with
|
|
1676 container formats that are not too tightly linked with
|
|
1677 <application>MEncoder</application> such as the ones supported through
|
|
1678 <systemitem class="library">libavformat</systemitem>, which may not
|
|
1679 support frame duplication at the container level.
|
|
1680 </para>
|
|
1681 </sect3>
|
|
1682
|
|
1683
|
|
1684 <sect3 id="menc-feat-dvd-mpeg4-muxing-avi-limitations">
|
|
1685 <title>Limitations of the AVI container</title>
|
|
1686
|
|
1687 <para>
|
|
1688 Although it is the most widely-supported container format after MPEG-1,
|
|
1689 AVI also has some major drawbacks.
|
|
1690 Perhaps the most obvious is the overhead.
|
|
1691 For each chunk of the AVI file, 24 bytes are wasted on headers and index.
|
|
1692 This translates into a little over 5 MB per hour, or 1-2.5%
|
|
1693 overhead for a 700 MB movie. This may not seem like much, but it could
|
|
1694 mean the difference between being able to use 700 kbit/sec video or
|
|
1695 714 kbit/sec, and every bit of quality counts.
|
|
1696 </para>
|
|
1697
|
|
1698 <para>
|
|
1699 In addition this gross inefficiency, AVI also has the following major
|
|
1700 limitations:
|
|
1701 </para>
|
|
1702
|
|
1703 <orderedlist>
|
|
1704 <listitem><para>
|
|
1705 Only fixed-fps content can be stored. This is particularly limiting
|
|
1706 if the original material you want to encode is mixed content, for
|
|
1707 example a mix of NTSC video and film material.
|
|
1708 Actually there are hacks that can be used to store mixed-framerate
|
|
1709 content in AVI, but they increase the (already huge) overhead
|
|
1710 fivefold or more and so are not practical.
|
|
1711 </para></listitem>
|
|
1712 <listitem><para>
|
|
1713 Audio in AVI files must be either constant-bitrate (CBR) or
|
|
1714 constant-framesize (i.e. all frames decode to the same number of
|
|
1715 samples).
|
|
1716 Unfortunately, the most efficient codec, Vorbis, does not meet
|
|
1717 either of these requirements.
|
|
1718 Therefore, if you plan to store your movie in AVI, you will have to
|
|
1719 use a less efficient codec such as MP3 or AC-3.
|
|
1720 </para></listitem>
|
|
1721 </orderedlist>
|
|
1722
|
|
1723 <para>
|
|
1724 Having said all that, <application>MEncoder</application> does not
|
|
1725 currently support variable-fps output or Vorbis encoding.
|
|
1726 Therefore, you may not see these as limitations if
|
|
1727 <application>MEncoder</application> is the
|
|
1728 only tool you will be using to produce your encodes.
|
|
1729 However, it is possible to use <application>MEncoder</application>
|
|
1730 only for video encoding, and then use external tools to encode
|
|
1731 audio and mux it into another container format.
|
|
1732 </para>
|
|
1733 </sect3>
|
|
1734
|
|
1735
|
|
1736 <sect3 id="menc-feat-dvd-mpeg4-muxing-matroska">
|
|
1737 <title>Muxing into the Matroska container</title>
|
|
1738
|
|
1739 <para>
|
|
1740 Matroska is a free, open standard container format, aiming
|
|
1741 to offer a lot of advanced features, which older containers
|
|
1742 like AVI cannot handle.
|
|
1743 For example, Matroska supports variable bitrate audio content
|
|
1744 (VBR), variable framerates (VFR), chapters, file attachments,
|
|
1745 error detection code (EDC) and modern A/V Codecs like "Advanced Audio
|
|
1746 Coding" (AAC), "Vorbis" or "MPEG-4 AVC" (H.264), next to nothing
|
|
1747 handled by AVI.
|
|
1748 </para>
|
|
1749
|
|
1750 <para>
|
|
1751 The tools required to create Matroska files are collectively called
|
|
1752 <application>mkvtoolnix</application>, and are available for most
|
|
1753 Unix platforms as well as <application>Windows</application>.
|
|
1754 Because Matroska is an open standard you may find other
|
|
1755 tools that suit you better, but since mkvtoolnix is the most
|
|
1756 common, and is supported by the Matroska team itself, we will
|
|
1757 only cover its usage.
|
|
1758 </para>
|
|
1759
|
|
1760 <para>
|
|
1761 Probably the easiest way to get started with Matroska is to use
|
|
1762 <application>MMG</application>, the graphical frontend shipped with
|
|
1763 <application>mkvtoolnix</application>, and follow the
|
|
1764 <ulink url="http://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge-gui.html">guide to mkvmerge GUI (mmg)</ulink>
|
|
1765 </para>
|
|
1766
|
|
1767 <para>
|
|
1768 You may also mux audio and video files using the command line:
|
|
1769 <screen>
|
|
1770 mkvmerge -o <replaceable>output.mkv</replaceable> <replaceable>input_video.avi</replaceable> <replaceable>input_audio1.mp3</replaceable> <replaceable>input_audio2.ac3</replaceable>
|
|
1771 </screen>
|
|
1772 This would merge the video file <replaceable>input_video.avi</replaceable>
|
|
1773 and the two audio files <replaceable>input_audio1.mp3</replaceable>
|
|
1774 and <replaceable>input_audio2.ac3</replaceable> into the Matroska
|
|
1775 file <replaceable>output.mkv</replaceable>.
|
|
1776 Matroska, as mentioned earlier, is able to do much more than that, like
|
|
1777 multiple audio tracks (including fine-tuning of audio/video
|
|
1778 synchronization), chapters, subtitles, splitting, etc...
|
|
1779 Please refer to the documentation of those applications for
|
|
1780 more details.
|
|
1781 </para>
|
|
1782 </sect3>
|
|
1783 </sect2>
|
|
1784 </sect1>
|
|
1785
|
|
1786
|
|
1787 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
1788
|
|
1789
|
|
1790 <sect1 id="menc-feat-telecine">
|
|
1791 <title>How to deal with telecine and interlacing within NTSC DVDs</title>
|
|
1792
|
|
1793 <sect2 id="menc-feat-telecine-intro">
|
|
1794 <title>Introduction</title>
|
|
1795
|
|
1796 <formalpara>
|
|
1797 <title>What is telecine?</title>
|
|
1798 <para>
|
|
1799 If you do not understand much of what is written in this document, read the
|
|
1800 <ulink url="http://en.wikipedia.org/wiki/Telecine">Wikipedia entry on telecine</ulink>.
|
|
1801 It is an understandable and reasonably comprehensive
|
|
1802 description of what telecine is.
|
|
1803 </para></formalpara>
|
|
1804
|
|
1805 <formalpara>
|
|
1806 <title>A note about the numbers.</title>
|
|
1807 <para>
|
|
1808 Many documents, including the guide linked above, refer to the fields
|
|
1809 per second value of NTSC video as 59.94 and the corresponding frames
|
|
1810 per second values as 29.97 (for telecined and interlaced) and 23.976
|
|
1811 (for progressive). For simplicity, some documents even round these
|
|
1812 numbers to 60, 30, and 24.
|
|
1813 </para></formalpara>
|
|
1814
|
|
1815 <para>
|
|
1816 Strictly speaking, all those numbers are approximations. Black and
|
|
1817 white NTSC video was exactly 60 fields per second, but 60000/1001
|
|
1818 was later chosen to accomodate color data while remaining compatible
|
|
1819 with contemporary black and white televisions. Digital NTSC video
|
|
1820 (such as on a DVD) is also 60000/1001 fields per second. From this,
|
|
1821 interlaced and telecined video are derived to be 30000/1001 frames
|
|
1822 per second; progressive video is 24000/1001 frames per second.
|
|
1823 </para>
|
|
1824
|
|
1825 <para>
|
|
1826 Older versions of the <application>MEncoder</application> documentation
|
|
1827 and many archived mailing list posts refer to 59.94, 29.97, and 23.976.
|
|
1828 All <application>MEncoder</application> documentation has been updated
|
|
1829 to use the fractional values, and you should use them too.
|
|
1830 </para>
|
|
1831
|
|
1832 <para>
|
|
1833 <option>-ofps 23.976</option> is incorrect.
|
|
1834 <option>-ofps 24000/1001</option> should be used instead.
|
|
1835 </para>
|
|
1836
|
|
1837 <formalpara>
|
|
1838 <title>How telecine is used.</title>
|
|
1839 <para>
|
|
1840 All video intended to be displayed on an NTSC
|
|
1841 television set must be 60000/1001 fields per second. Made-for-TV movies
|
|
1842 and shows are often filmed directly at 60000/1001 fields per second, but
|
|
1843 the majority of cinema is filmed at 24 or 24000/1001 frames per
|
|
1844 second. When cinematic movie DVDs are mastered, the video is then
|
|
1845 converted for television using a process called telecine.
|
|
1846 </para></formalpara>
|
|
1847
|
|
1848 <para>
|
|
1849 On a DVD, the video is never actually stored as 60000/1001 fields per
|
|
1850 second. For video that was originally 60000/1001, each pair of fields is
|
|
1851 combined to form a frame, resulting in 30000/1001 frames per
|
|
1852 second. Hardware DVD players then read a flag embedded in the video
|
|
1853 stream to determine whether the odd- or even-numbered lines should
|
|
1854 form the first field.
|
|
1855 </para>
|
|
1856
|
|
1857 <para>
|
|
1858 Usually, 24000/1001 frames per second content stays as it is when
|
|
1859 encoded for a DVD, and the DVD player must perform telecining
|
|
1860 on-the-fly. Sometimes, however, the video is telecined
|
|
1861 <emphasis>before</emphasis> being stored on the DVD; even though it
|
|
1862 was originally 24000/1001 frames per second, it becomes 60000/1001 fields per
|
|
1863 second. When it is stored on the DVD, pairs of fields are combined to form
|
|
1864 30000/1001 frames per second.
|
|
1865 </para>
|
|
1866
|
|
1867 <para>
|
|
1868 When looking at individual frames formed from 60000/1001 fields per
|
|
1869 second video, telecined or otherwise, interlacing is clearly visible
|
|
1870 wherever there is any motion, because one field (say, the
|
|
1871 even-numbered lines) represents a moment in time 1/(60000/1001)
|
|
1872 seconds later than the other. Playing interlaced video on a computer
|
|
1873 looks ugly both because the monitor is higher resolution and because
|
|
1874 the video is shown frame-after-frame instead of field-after-field.
|
|
1875 </para>
|
|
1876
|
|
1877 <itemizedlist>
|
|
1878 <title>Notes:</title>
|
|
1879 <listitem><para>
|
|
1880 This section only applies to NTSC DVDs, and not PAL.
|
|
1881 </para></listitem>
|
|
1882 <listitem><para>
|
|
1883 The example <application>MEncoder</application> lines throughout the
|
|
1884 document are <emphasis role="bold">not</emphasis> intended for
|
|
1885 actual use. They are simply the bare minimum required to encode the
|
|
1886 pertaining video category. How to make good DVD rips or fine-tune
|
|
1887 <systemitem class="library">libavcodec</systemitem> for maximal
|
|
1888 quality is not within the scope of this document.
|
|
1889 </para></listitem>
|
|
1890 <listitem><para>
|
|
1891 There are a couple footnotes specific to this guide, linked like this:
|
|
1892 <link linkend="menc-feat-telecine-footnotes">[1]</link>
|
|
1893 </para></listitem>
|
|
1894 </itemizedlist>
|
|
1895 </sect2>
|
|
1896
|
|
1897 <!-- ********** -->
|
|
1898
|
|
1899 <sect2 id="menc-feat-telecine-ident">
|
|
1900 <title>How to tell what type of video you have</title>
|
|
1901
|
|
1902 <sect3 id="menc-feat-telecine-ident-progressive">
|
|
1903 <title>Progressive</title>
|
|
1904
|
|
1905 <para>
|
|
1906 Progressive video was originally filmed at 24000/1001 fps, and stored
|
|
1907 on the DVD without alteration.
|
|
1908 </para>
|
|
1909
|
|
1910 <para>
|
|
1911 When you play a progressive DVD in <application>MPlayer</application>,
|
|
1912 <application>MPlayer</application> will print the following line as
|
|
1913 soon as the movie begins to play:
|
|
1914 <screen>
|
|
1915 demux_mpg: 24000/1001 fps progressive NTSC content detected, switching framerate.
|
|
1916 </screen>
|
|
1917 From this point forward, demux_mpg should never say it finds
|
|
1918 "30000/1001 fps NTSC content."
|
|
1919 </para>
|
|
1920
|
|
1921 <para>
|
|
1922 When you watch progressive video, you should never see any
|
|
1923 interlacing. Beware, however, because sometimes there is a tiny bit
|
|
1924 of telecine mixed in where you would not expect. I have encountered TV
|
|
1925 show DVDs that have one second of telecine at every scene change, or
|
|
1926 at seemingly random places. I once watched a DVD that had a
|
|
1927 progressive first half, and the second half was telecined. If you
|
|
1928 want to be <emphasis>really</emphasis> thorough, you can scan the
|
|
1929 entire movie:
|
|
1930 <screen>mplayer dvd://1 -nosound -vo null -benchmark</screen>
|
|
1931 Using <option>-benchmark</option> makes
|
|
1932 <application>MPlayer</application> play the movie as quickly as it
|
|
1933 possibly can; still, depending on your hardware, it can take a
|
|
1934 while. Every time demux_mpg reports a framerate change, the line
|
|
1935 immediately above will show you the time at which the change
|
|
1936 occurred.
|
|
1937 </para>
|
|
1938
|
|
1939 <para>
|
|
1940 Sometimes progressive video on DVDs is referred to as
|
|
1941 "soft-telecine" because it is intended to
|
|
1942 be telecined by the DVD player.
|
|
1943 </para>
|
|
1944 </sect3>
|
|
1945
|
|
1946
|
|
1947 <sect3 id="menc-feat-telecine-ident-telecined">
|
|
1948 <title>Telecined</title>
|
|
1949
|
|
1950 <para>
|
|
1951 Telecined video was originally filmed at 24000/1001, but was telecined
|
|
1952 <emphasis>before</emphasis> it was written to the DVD.
|
|
1953 </para>
|
|
1954
|
|
1955 <para>
|
|
1956 <application>MPlayer</application> does not (ever) report any
|
|
1957 framerate changes when it plays telecined video.
|
|
1958 </para>
|
|
1959
|
|
1960 <para>
|
|
1961 Watching a telecined video, you will see interlacing artifacts that
|
|
1962 seem to "blink": they repeatedly appear and disappear.
|
|
1963 You can look closely at this by
|
|
1964 <orderedlist>
|
|
1965 <listitem><screen>mplayer dvd://1</screen></listitem>
|
|
1966 <listitem><para>
|
|
1967 Seek to a part with motion.
|
|
1968 </para></listitem>
|
|
1969 <listitem><para>
|
|
1970 Use the <keycap>.</keycap> key to step forward one frame at a time.
|
|
1971 </para></listitem>
|
|
1972 <listitem><para>
|
|
1973 Look at the pattern of interlaced-looking and progressive-looking
|
|
1974 frames. If the pattern you see is PPPII,PPPII,PPPII,... then the
|
|
1975 video is telecined. If you see some other pattern, then the video
|
|
1976 may have been telecined using some non-standard method;
|
|
1977 <application>MEncoder</application> cannot losslessly convert
|
|
1978 non-standard telecine to progressive. If you do not see any
|
|
1979 pattern at all, then it is most likely interlaced.
|
|
1980 </para></listitem>
|
|
1981 </orderedlist>
|
|
1982 </para>
|
|
1983
|
|
1984 <para>
|
|
1985 Sometimes telecined video on DVDs is referred to as
|
|
1986 "hard-telecine". Since hard-telecine is already 60000/1001 fields
|
|
1987 per second, the DVD player plays the video without any manipulation.
|
|
1988 </para>
|
|
1989
|
|
1990 <para>
|
|
1991 Another way to tell if your source is telecined or not is to play
|
|
1992 the source with the <option>-vf pullup</option> and <option>-v</option>
|
|
1993 command line options to see how <option>pullup</option> matches frames.
|
|
1994 If the source is telecined, you should see on the console a 3:2 pattern
|
|
1995 with <systemitem>0+.1.+2</systemitem> and <systemitem>0++1</systemitem>
|
|
1996 alternating.
|
|
1997 This technique has the advantage that you do not need to watch the
|
|
1998 source to identify it, which could be useful if you wish to automate
|
|
1999 the encoding procedure, or to carry out said procedure remotely via
|
|
2000 a slow connection.
|
|
2001 </para>
|
|
2002 </sect3>
|
|
2003
|
|
2004
|
|
2005 <sect3 id="menc-feat-telecine-ident-interlaced">
|
|
2006 <title>Interlaced</title>
|
|
2007
|
|
2008 <para>
|
|
2009 Interlaced video was originally filmed at 60000/1001 fields per second,
|
|
2010 and stored on the DVD as 30000/1001 frames per second. The interlacing effect
|
|
2011 (often called "combing") is a result of combining pairs of
|
|
2012 fields into frames. Each field is supposed to be 1/(60000/1001) seconds apart,
|
|
2013 and when they are displayed simultaneously the difference is apparent.
|
|
2014 </para>
|
|
2015
|
|
2016 <para>
|
|
2017 As with telecined video, <application>MPlayer</application> should
|
|
2018 not ever report any framerate changes when playing interlaced content.
|
|
2019 </para>
|
|
2020
|
|
2021 <para>
|
|
2022 When you view an interlaced video closely by frame-stepping with the
|
|
2023 <keycap>.</keycap> key, you will see that every single frame is interlaced.
|
|
2024 </para>
|
|
2025 </sect3>
|
|
2026
|
|
2027
|
|
2028 <sect3 id="menc-feat-telecine-ident-mixedpt">
|
|
2029 <title>Mixed progressive and telecine</title>
|
|
2030
|
|
2031 <para>
|
|
2032 All of a "mixed progressive and telecine" video was originally
|
|
2033 24000/1001 frames per second, but some parts of it ended up being telecined.
|
|
2034 </para>
|
|
2035
|
|
2036 <para>
|
|
2037 When <application>MPlayer</application> plays this category, it will
|
|
2038 (often repeatedly) switch back and forth between "30000/1001 fps NTSC"
|
|
2039 and "24000/1001 fps progressive NTSC". Watch the bottom of
|
|
2040 <application>MPlayer</application>'s output to see these messages.
|
|
2041 </para>
|
|
2042
|
|
2043 <para>
|
|
2044 You should check the "30000/1001 fps NTSC" sections to make sure
|
|
2045 they are actually telecine, and not just interlaced.
|
|
2046 </para>
|
|
2047 </sect3>
|
|
2048
|
|
2049
|
|
2050 <sect3 id="menc-feat-telecine-ident-mixedpi">
|
|
2051 <title>Mixed progressive and interlaced</title>
|
|
2052
|
|
2053 <para>
|
|
2054 In "mixed progressive and interlaced" content, progressive
|
|
2055 and interlaced video have been spliced together.
|
|
2056 </para>
|
|
2057
|
|
2058 <para>
|
|
2059 This category looks just like "mixed progressive and telecine",
|
|
2060 until you examine the 30000/1001 fps sections and see that they do not have the
|
|
2061 telecine pattern.
|
|
2062 </para>
|
|
2063 </sect3>
|
|
2064 </sect2>
|
|
2065
|
|
2066 <!-- ********** -->
|
|
2067
|
|
2068 <sect2 id="menc-feat-telecine-encode">
|
|
2069 <title>How to encode each category</title>
|
|
2070 <para>
|
|
2071 As I mentioned in the beginning, example <application>MEncoder</application>
|
|
2072 lines below are <emphasis role="bold">not</emphasis> meant to actually be used;
|
|
2073 they only demonstrate the minimum parameters to properly encode each category.
|
|
2074 </para>
|
|
2075
|
|
2076
|
|
2077 <sect3 id="menc-feat-telecine-encode-progressive">
|
|
2078 <title>Progressive</title>
|
|
2079 <para>
|
|
2080 Progressive video requires no special filtering to encode. The only
|
|
2081 parameter you need to be sure to use is <option>-ofps 24000/1001</option>.
|
|
2082 Otherwise, <application>MEncoder</application>
|
|
2083 will try to encode at 30000/1001 fps and will duplicate frames.
|
|
2084 </para>
|
|
2085
|
|
2086 <para>
|
|
2087 <screen>mencoder dvd://1 -oac copy -ovc lavc -ofps 24000/1001</screen>
|
|
2088 </para>
|
|
2089
|
|
2090 <para>
|
|
2091 It is often the case, however, that a video that looks progressive
|
|
2092 actually has very short parts of telecine mixed in. Unless you are
|
|
2093 sure, it is safest to treat the video as
|
|
2094 <link linkend="menc-feat-telecine-encode-mixedpt">mixed progressive and telecine</link>.
|
|
2095 The performance loss is small
|
|
2096 <link linkend="menc-feat-telecine-footnotes">[3]</link>.
|
|
2097 </para>
|
|
2098 </sect3>
|
|
2099
|
|
2100
|
|
2101 <sect3 id="menc-feat-telecine-encode-telecined">
|
|
2102 <title>Telecined</title>
|
|
2103
|
|
2104 <para>
|
|
2105 Telecine can be reversed to retrieve the original 24000/1001 content,
|
|
2106 using a process called inverse-telecine.
|
|
2107 <application>MPlayer</application> contains several filters to
|
|
2108 accomplish this; the best filter, <option>pullup</option>, is described
|
|
2109 in the <link linkend="menc-feat-telecine-encode-mixedpt">mixed
|
|
2110 progressive and telecine</link> section.
|
|
2111 </para>
|
|
2112 </sect3>
|
|
2113
|
|
2114
|
|
2115 <sect3 id="menc-feat-telecine-encode-interlaced">
|
|
2116 <title>Interlaced</title>
|
|
2117
|
|
2118 <para>
|
|
2119 For most practical cases it is not possible to retrieve a complete
|
|
2120 progressive video from interlaced content. The only way to do so
|
|
2121 without losing half of the vertical resolution is to double the
|
|
2122 framerate and try to "guess" what ought to make up the
|
|
2123 corresponding lines for each field (this has drawbacks - see method 3).
|
|
2124 </para>
|
|
2125
|
|
2126 <orderedlist>
|
|
2127 <listitem><para>
|
|
2128 Encode the video in interlaced form. Normally, interlacing wreaks
|
|
2129 havoc with the encoder's ability to compress well, but
|
|
2130 <systemitem class="library">libavcodec</systemitem> has two
|
|
2131 parameters specifically for dealing with storing interlaced video a
|
|
2132 bit better: <option> ildct</option> and <option>ilme</option>. Also,
|
|
2133 using <option>mbd=2</option> is strongly recommended
|
|
2134 <link linkend="menc-feat-telecine-footnotes">[2] </link> because it
|
|
2135 will encode macroblocks as non-interlaced in places where there is
|
|
2136 no motion. Note that <option>-ofps</option> is NOT needed here.
|
|
2137 <screen>mencoder dvd://1 -oac copy -ovc lavc -lavcopts ildct:ilme:mbd=2</screen>
|
|
2138 </para></listitem>
|
|
2139 <listitem><para>
|
|
2140 Use a deinterlacing filter before encoding. There are several of
|
|
2141 these filters available to choose from, each with its own advantages
|
|
2142 and disadvantages. Consult <option>mplayer -pphelp</option> and
|
|
2143 <option>mplayer -vf help</option> to see what is available
|
|
2144 (grep for "deint"), read Michael's Niedermayer
|
|
2145 <ulink url="http://guru.multimedia.cx/deinterlacing-filters/">Deinterlacing filters comparison</ulink>,
|
|
2146 and search the
|
|
2147 <ulink url="http://www.mplayerhq.hu/design7/mailing_lists.html">
|
|
2148 MPlayer mailing lists</ulink> to find many discussions about the
|
|
2149 various filters.
|
|
2150 Again, the framerate is not changing, so no
|
|
2151 <option>-ofps</option>. Also, deinterlacing should be done after
|
|
2152 cropping <link linkend="menc-feat-telecine-footnotes">[1]</link> and
|
|
2153 before scaling.
|
|
2154 <screen>mencoder dvd://1 -oac copy -vf yadif -ovc lavc</screen>
|
|
2155 </para></listitem>
|
|
2156 <listitem><para>
|
|
2157 Unfortunately, this option is buggy with
|
|
2158 <application>MEncoder</application>; it ought to work well with
|
|
2159 <application>MEncoder G2</application>, but that is not here yet. You
|
|
2160 might experience crahes. Anyway, the purpose of <option> -vf
|
|
2161 tfields</option> is to create a full frame out of each field, which
|
|
2162 makes the framerate 60000/1001. The advantage of this approach is that no
|
|
2163 data is ever lost; however, since each frame comes from only one
|
|
2164 field, the missing lines have to be interpolated somehow. There are
|
|
2165 no very good methods of generating the missing data, and so the
|
|
2166 result will look a bit similar to when using some deinterlacing
|
|
2167 filters. Generating the missing lines creates other issues, as well,
|
|
2168 simply because the amount of data doubles. So, higher encoding
|
|
2169 bitrates are required to maintain quality, and more CPU power is
|
|
2170 used for both encoding and decoding. tfields has several different
|
|
2171 options for how to create the missing lines of each frame. If you
|
|
2172 use this method, then Reference the manual, and chose whichever
|
|
2173 option looks best for your material. Note that when using
|
|
2174 <option>tfields</option> you
|
|
2175 <emphasis role="bold">have to</emphasis> specify both
|
|
2176 <option>-fps</option> and <option>-ofps</option> to be twice the
|
|
2177 framerate of your original source.
|
|
2178 <screen>
|
|
2179 mencoder dvd://1 -oac copy -vf tfields=2 -ovc lavc \
|
|
2180 -fps 60000/1001 -ofps 60000/1001<!--
|
|
2181 --></screen>
|
|
2182 </para></listitem>
|
|
2183 <listitem><para>
|
|
2184 If you plan on downscaling dramatically, you can extract and encode
|
|
2185 only one of the two fields. Of course, you will lose half the vertical
|
|
2186 resolution, but if you plan on downscaling to at most 1/2 of the
|
|
2187 original, the loss will not matter much. The result will be a
|
|
2188 progressive 30000/1001 frames per second file. The procedure is to use
|
|
2189 <option>-vf field</option>, then crop
|
|
2190 <link linkend="menc-feat-telecine-footnotes">[1]</link> and scale
|
|
2191 appropriately. Remember that you will have to adjust the scale to
|
|
2192 compensate for the vertical resolution being halved.
|
|
2193 <screen>mencoder dvd://1 -oac copy -vf field=0 -ovc lavc</screen>
|
|
2194 </para></listitem>
|
|
2195 </orderedlist>
|
|
2196 </sect3>
|
|
2197
|
|
2198
|
|
2199 <sect3 id="menc-feat-telecine-encode-mixedpt">
|
|
2200 <title>Mixed progressive and telecine</title>
|
|
2201
|
|
2202 <para>
|
|
2203 In order to turn mixed progressive and telecine video into entirely
|
|
2204 progressive video, the telecined parts have to be
|
|
2205 inverse-telecined. There are three ways to accomplish this,
|
|
2206 described below. Note that you should
|
|
2207 <emphasis role="bold">always</emphasis> inverse-telecine before any
|
|
2208 rescaling; unless you really know what you are doing,
|
|
2209 inverse-telecine before cropping, too
|
|
2210 <link linkend="menc-feat-telecine-footnotes">[1]</link>.
|
|
2211 <option>-ofps 24000/1001</option> is needed here because the output video
|
|
2212 will be 24000/1001 frames per second.
|
|
2213 </para>
|
|
2214
|
|
2215 <itemizedlist>
|
|
2216 <listitem><para>
|
|
2217 <option>-vf pullup</option> is designed to inverse-telecine
|
|
2218 telecined material while leaving progressive data alone. In order to
|
|
2219 work properly, <option>pullup</option> <emphasis role="bold">must</emphasis>
|
|
2220 be followed by the <option>softskip</option> filter or
|
|
2221 else <application>MEncoder</application> will crash.
|
|
2222 <option>pullup</option> is, however, the cleanest and most
|
|
2223 accurate method available for encoding both telecine and
|
|
2224 "mixed progressive and telecine".
|
|
2225 <screen>
|
|
2226 mencoder dvd://1 -oac copy -vf pullup,softskip
|
|
2227 -ovc lavc -ofps 24000/1001<!--
|
|
2228 --></screen>
|
|
2229 </para></listitem>
|
|
2230 <listitem><para>
|
|
2231 An older method
|
|
2232 is to, rather than inverse-telecine the telecined parts, telecine
|
|
2233 the non-telecined parts and then inverse-telecine the whole
|
|
2234 video. Sound confusing? softpulldown is a filter that goes through
|
|
2235 a video and makes the entire file telecined. If we follow
|
|
2236 softpulldown with either <option>detc</option> or
|
|
2237 <option>ivtc</option>, the final result will be entirely
|
|
2238 progressive. <option>-ofps 24000/1001</option> is needed.
|
|
2239 <screen>
|
|
2240 mencoder dvd://1 -oac copy -vf softpulldown,ivtc=1 -ovc lavc -ofps 24000/1001
|
|
2241 </screen>
|
|
2242 </para></listitem>
|
|
2243
|
|
2244 <listitem><para>
|
|
2245 I have not used <option>-vf filmdint</option> myself, but here is what
|
|
2246 D Richard Felker III has to say:
|
|
2247
|
|
2248 <blockquote><para>It is OK, but IMO it tries to deinterlace rather
|
|
2249 than doing inverse telecine too often (much like settop DVD
|
|
2250 players & progressive TVs) which gives ugly flickering and
|
|
2251 other artifacts. If you are going to use it, you at least need to
|
|
2252 spend some time tuning the options and watching the output first
|
|
2253 to make sure it is not messing up.
|
|
2254 </para></blockquote>
|
|
2255 </para></listitem>
|
|
2256 </itemizedlist>
|
|
2257 </sect3>
|
|
2258
|
|
2259
|
|
2260 <sect3 id="menc-feat-telecine-encode-mixedpi">
|
|
2261 <title>Mixed progressive and interlaced</title>
|
|
2262
|
|
2263 <para>
|
|
2264 There are two options for dealing with this category, each of
|
|
2265 which is a compromise. You should decide based on the
|
|
2266 duration/location of each type.
|
|
2267 </para>
|
|
2268
|
|
2269 <itemizedlist>
|
|
2270 <listitem>
|
|
2271 <para>
|
|
2272 Treat it as progressive. The interlaced parts will look interlaced,
|
|
2273 and some of the interlaced fields will have to be dropped, resulting
|
|
2274 in a bit of uneven jumpiness. You can use a postprocessing filter if
|
|
2275 you want to, but it may slightly degrade the progressive parts.
|
|
2276 </para>
|
|
2277
|
|
2278 <para>
|
|
2279 This option should definitely not be used if you want to eventually
|
|
2280 display the video on an interlaced device (with a TV card, for
|
|
2281 example). If you have interlaced frames in a 24000/1001 frames per
|
|
2282 second video, they will be telecined along with the progressive
|
|
2283 frames. Half of the interlaced "frames" will be displayed for three
|
|
2284 fields' duration (3/(60000/1001) seconds), resulting in a flicking
|
|
2285 "jump back in time" effect that looks quite bad. If you
|
|
2286 even attempt this, you <emphasis role="bold">must</emphasis> use a
|
|
2287 deinterlacing filter like <option>lb</option> or
|
|
2288 <option>l5</option>.
|
|
2289 </para>
|
|
2290
|
|
2291 <para>
|
|
2292 It may also be a bad idea for progressive display, too. It will drop
|
|
2293 pairs of consecutive interlaced fields, resulting in a discontinuity
|
|
2294 that can be more visible than with the second method, which shows
|
|
2295 some progressive frames twice. 30000/1001 frames per second interlaced
|
|
2296 video is already a bit choppy because it really should be shown at
|
|
2297 60000/1001 fields per second, so the duplicate frames do not stand out as
|
|
2298 much.
|
|
2299 </para>
|
|
2300
|
|
2301 <para>
|
|
2302 Either way, it is best to consider your content and how you intend to
|
|
2303 display it. If your video is 90% progressive and you never intend to
|
|
2304 show it on a TV, you should favor a progressive approach. If it is
|
|
2305 only half progressive, you probably want to encode it as if it is all
|
|
2306 interlaced.
|
|
2307 </para>
|
|
2308 </listitem>
|
|
2309
|
|
2310 <listitem><para>
|
|
2311 Treat it as interlaced. Some frames of the progressive parts will
|
|
2312 need to be duplicated, resulting in uneven jumpiness. Again,
|
|
2313 deinterlacing filters may slightly degrade the progressive parts.
|
|
2314 </para></listitem>
|
|
2315 </itemizedlist>
|
|
2316 </sect3>
|
|
2317 </sect2>
|
|
2318
|
|
2319 <!-- ********** -->
|
|
2320
|
|
2321 <sect2 id="menc-feat-telecine-footnotes">
|
|
2322 <title>Footnotes</title>
|
|
2323
|
|
2324 <orderedlist>
|
|
2325 <listitem>
|
|
2326 <formalpara>
|
|
2327 <title>About cropping:</title>
|
|
2328 <para>
|
|
2329 Video data on DVDs are stored in a format called YUV 4:2:0. In YUV
|
|
2330 video, luma ("brightness") and chroma ("color")
|
|
2331 are stored separately. Because the human eye is somewhat less
|
|
2332 sensitive to color than it is to brightness, in a YUV 4:2:0 picture
|
|
2333 there is only one chroma pixel for every four luma pixels. In a
|
|
2334 progressive picture, each square of four luma pixels (two on each
|
|
2335 side) has one common chroma pixel. You must crop progressive YUV
|
|
2336 4:2:0 to even resolutions, and use even offsets. For example,
|
|
2337 <option>crop=716:380:2:26</option> is OK but
|
|
2338 <option>crop=716:380:3:26 </option> is not.
|
|
2339 </para>
|
|
2340 </formalpara>
|
|
2341
|
|
2342 <para>
|
|
2343 When you are dealing with interlaced YUV 4:2:0, the situation is a
|
|
2344 bit more complicated. Instead of every four luma pixels in the
|
|
2345 <emphasis>frame</emphasis> sharing a chroma pixel, every four luma
|
|
2346 pixels in each <emphasis> field</emphasis> share a chroma
|
|
2347 pixel. When fields are interlaced to form a frame, each scanline is
|
|
2348 one pixel high. Now, instead of all four luma pixels being in a
|
|
2349 square, there are two pixels side-by-side, and the other two pixels
|
|
2350 are side-by-side two scanlines down. The two luma pixels in the
|
|
2351 intermediate scanline are from the other field, and so share a
|
|
2352 different chroma pixel with two luma pixels two scanlines away. All
|
|
2353 this confusion makes it necessary to have vertical crop dimensions
|
|
2354 and offsets be multiples of four. Horizontal can stay even.
|
|
2355 </para>
|
|
2356
|
|
2357 <para>
|
|
2358 For telecined video, I recommend that cropping take place after
|
|
2359 inverse telecining. Once the video is progressive you only need to
|
|
2360 crop by even numbers. If you really want to gain the slight speedup
|
|
2361 that cropping first may offer, you must crop vertically by multiples
|
|
2362 of four or else the inverse-telecine filter will not have proper data.
|
|
2363 </para>
|
|
2364
|
|
2365 <para>
|
|
2366 For interlaced (not telecined) video, you must always crop
|
|
2367 vertically by multiples of four unless you use <option>-vf
|
|
2368 field</option> before cropping.
|
|
2369 </para>
|
|
2370 </listitem>
|
|
2371
|
|
2372 <listitem><formalpara>
|
|
2373 <title>About encoding parameters and quality:</title>
|
|
2374 <para>
|
|
2375 Just because I recommend <option>mbd=2</option> here does not mean it
|
|
2376 should not be used elsewhere. Along with <option>trell</option>,
|
|
2377 <option>mbd=2</option> is one of the two
|
|
2378 <systemitem class="library">libavcodec</systemitem> options that
|
|
2379 increases quality the most, and you should always use at least those
|
|
2380 two unless the drop in encoding speed is prohibitive (e.g. realtime
|
|
2381 encoding). There are many other options to
|
|
2382 <systemitem class="library">libavcodec</systemitem> that increase
|
|
2383 encoding quality (and decrease encoding speed) but that is beyond
|
|
2384 the scope of this document.
|
|
2385 </para>
|
|
2386 </formalpara></listitem>
|
|
2387
|
|
2388 <listitem><formalpara>
|
|
2389 <title>About the performance of pullup:</title>
|
|
2390 <para>
|
|
2391 It is safe to use <option>pullup</option> (along with <option>softskip
|
|
2392 </option>) on progressive video, and is usually a good idea unless
|
|
2393 the source has been definitively verified to be entirely progressive.
|
|
2394 The performace loss is small for most cases. On a bare-minimum encode,
|
|
2395 <option>pullup</option> causes <application>MEncoder</application> to
|
|
2396 be 50% slower. Adding sound processing and advanced <option>lavcopts
|
|
2397 </option> overshadows that difference, bringing the performance
|
|
2398 decrease of using <option>pullup</option> down to 2%.
|
|
2399 </para>
|
|
2400 </formalpara></listitem>
|
|
2401 </orderedlist>
|
|
2402 </sect2>
|
|
2403 </sect1>
|
|
2404
|
|
2405
|
|
2406 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
2407
|
|
2408
|
|
2409 <sect1 id="menc-feat-enc-libavcodec">
|
|
2410 <title>Encoding with the <systemitem class="library">libavcodec</systemitem>
|
|
2411 codec family</title>
|
|
2412
|
|
2413 <para>
|
|
2414 <link linkend="ffmpeg"><systemitem class="library">libavcodec</systemitem></link>
|
|
2415 provides simple encoding to a lot of interesting video and audio formats.
|
|
2416 You can encode to the following codecs (more or less up to date):
|
|
2417 </para>
|
|
2418
|
|
2419 <!-- ********** -->
|
|
2420
|
|
2421 <sect2 id="menc-feat-enc-libavcodec-video-codecs">
|
|
2422 <title><systemitem class="library">libavcodec</systemitem>'s
|
|
2423 video codecs</title>
|
|
2424
|
|
2425 <para>
|
|
2426 <informaltable frame="all">
|
|
2427 <tgroup cols="2">
|
|
2428 <thead>
|
|
2429 <row><entry>Video codec name</entry><entry>Description</entry></row>
|
|
2430 </thead>
|
|
2431 <tbody>
|
|
2432 <row>
|
|
2433 <entry>mjpeg</entry>
|
|
2434 <entry>Motion JPEG</entry>
|
|
2435 </row>
|
|
2436 <row>
|
|
2437 <entry>ljpeg</entry>
|
|
2438 <entry>lossless JPEG</entry>
|
|
2439 </row>
|
|
2440 <row>
|
|
2441 <entry>jpegls</entry>
|
|
2442 <entry>JPEG LS</entry>
|
|
2443 </row>
|
|
2444 <row>
|
|
2445 <entry>targa</entry>
|
|
2446 <entry>Targa image</entry>
|
|
2447 </row>
|
|
2448 <row>
|
|
2449 <entry>gif</entry>
|
|
2450 <entry>GIF image</entry>
|
|
2451 </row>
|
|
2452 <row>
|
|
2453 <entry>bmp</entry>
|
|
2454 <entry>BMP image</entry>
|
|
2455 </row>
|
|
2456 <row>
|
|
2457 <entry>png</entry>
|
|
2458 <entry>PNG image</entry>
|
|
2459 </row>
|
|
2460 <row>
|
|
2461 <entry>h261</entry>
|
|
2462 <entry>H.261</entry>
|
|
2463 </row>
|
|
2464 <row>
|
|
2465 <entry>h263</entry>
|
|
2466 <entry>H.263 </entry>
|
|
2467 </row>
|
|
2468 <row>
|
|
2469 <entry>h263p</entry>
|
|
2470 <entry>H.263+</entry>
|
|
2471 </row>
|
|
2472 <row>
|
|
2473 <entry>mpeg4</entry>
|
|
2474 <entry>ISO standard MPEG-4 (DivX, Xvid compatible)</entry>
|
|
2475 </row>
|
|
2476 <row>
|
|
2477 <entry>msmpeg4</entry>
|
|
2478 <entry>pre-standard MPEG-4 variant by MS, v3 (AKA DivX3)</entry>
|
|
2479 </row>
|
|
2480 <row>
|
|
2481 <entry>msmpeg4v2</entry>
|
|
2482 <entry>pre-standard MPEG-4 by MS, v2 (used in old ASF files)</entry>
|
|
2483 </row>
|
|
2484 <row>
|
|
2485 <entry>wmv1</entry>
|
|
2486 <entry>Windows Media Video, version 1 (AKA WMV7)</entry>
|
|
2487 </row>
|
|
2488 <row>
|
|
2489 <entry>wmv2</entry>
|
|
2490 <entry>Windows Media Video, version 2 (AKA WMV8)</entry>
|
|
2491 </row>
|
|
2492 <row>
|
|
2493 <entry>rv10</entry>
|
|
2494 <entry>RealVideo 1.0</entry>
|
|
2495 </row>
|
|
2496 <row>
|
|
2497 <entry>rv20</entry>
|
|
2498 <entry>RealVideo 2.0</entry>
|
|
2499 </row>
|
|
2500 <row>
|
|
2501 <entry>mpeg1video</entry>
|
|
2502 <entry>MPEG-1 video</entry>
|
|
2503 </row>
|
|
2504 <row>
|
|
2505 <entry>mpeg2video</entry>
|
|
2506 <entry>MPEG-2 video</entry>
|
|
2507 </row>
|
|
2508 <row>
|
|
2509 <entry>huffyuv</entry>
|
|
2510 <entry>lossless compression</entry>
|
|
2511 </row>
|
|
2512 <row>
|
|
2513 <entry>ffvhuff</entry>
|
|
2514 <entry>FFmpeg modified huffyuv lossless</entry>
|
|
2515 </row>
|
|
2516 <row>
|
|
2517 <entry>asv1</entry>
|
|
2518 <entry>ASUS Video v1</entry>
|
|
2519 </row>
|
|
2520 <row>
|
|
2521 <entry>asv2</entry>
|
|
2522 <entry>ASUS Video v2</entry>
|
|
2523 </row>
|
|
2524 <row>
|
|
2525 <entry>ffv1</entry>
|
|
2526 <entry>FFmpeg's lossless video codec</entry>
|
|
2527 </row>
|
|
2528 <row>
|
|
2529 <entry>svq1</entry>
|
|
2530 <entry>Sorenson video 1</entry>
|
|
2531 </row>
|
|
2532 <row>
|
|
2533 <entry>flv</entry>
|
|
2534 <entry>Sorenson H.263 used in Flash Video</entry>
|
|
2535 </row>
|
|
2536 <row>
|
|
2537 <entry>flashsv</entry>
|
|
2538 <entry>Flash Screen Video</entry>
|
|
2539 </row>
|
|
2540 <row>
|
|
2541 <entry>dvvideo</entry>
|
|
2542 <entry>Sony Digital Video</entry>
|
|
2543 </row>
|
|
2544 <row>
|
|
2545 <entry>snow</entry>
|
|
2546 <entry>FFmpeg's experimental wavelet-based codec</entry>
|
|
2547 </row>
|
|
2548 <row>
|
|
2549 <entry>zbmv</entry>
|
|
2550 <entry>Zip Blocks Motion Video</entry>
|
|
2551 </row>
|
|
2552 </tbody>
|
|
2553 </tgroup>
|
|
2554 </informaltable>
|
|
2555
|
|
2556 The first column contains the codec names that should be passed after the
|
|
2557 <literal>vcodec</literal> config,
|
|
2558 like: <option>-lavcopts vcodec=msmpeg4</option>
|
|
2559 </para>
|
|
2560
|
|
2561 <informalexample><para>
|
|
2562 An example with MJPEG compression:
|
|
2563 <screen>
|
|
2564 mencoder dvd://2 -o <replaceable>title2.avi</replaceable> -ovc lavc -lavcopts vcodec=mjpeg -oac copy
|
|
2565 </screen>
|
|
2566 </para></informalexample>
|
|
2567 </sect2>
|
|
2568
|
|
2569 <!-- ********** -->
|
|
2570
|
|
2571 <sect2 id="menc-feat-enc-libavcodec-audio-codecs">
|
|
2572 <title><systemitem class="library">libavcodec</systemitem>'s
|
|
2573 audio codecs</title>
|
|
2574
|
|
2575 <para>
|
|
2576 <informaltable frame="all">
|
|
2577 <tgroup cols="2">
|
|
2578 <thead>
|
|
2579 <row><entry>Audio codec name</entry><entry>Description</entry></row>
|
|
2580 </thead>
|
|
2581 <tbody>
|
|
2582 <row>
|
|
2583 <entry>mp2</entry>
|
|
2584 <entry>MPEG Layer 2</entry>
|
|
2585 </row>
|
|
2586 <row>
|
|
2587 <entry>ac3</entry>
|
|
2588 <entry>AC-3, AKA Dolby Digital</entry>
|
|
2589 </row>
|
|
2590 <row>
|
|
2591 <entry>adpcm_ima_wav</entry>
|
|
2592 <entry>IMA adaptive PCM (4 bits per sample, 4:1 compression)</entry>
|
|
2593 </row>
|
|
2594 <row>
|
|
2595 <entry>sonic</entry>
|
|
2596 <entry>experimental FFmpeg lossy codec</entry>
|
|
2597 </row>
|
|
2598 <row>
|
|
2599 <entry>sonicls</entry>
|
|
2600 <entry>experimental FFmpeg lossless codec</entry>
|
|
2601 </row>
|
|
2602 <row>
|
|
2603 <entry>vorbis</entry>
|
|
2604 <entry>Xiph Ogg Vorbis codec</entry>
|
|
2605 </row>
|
|
2606 <row>
|
|
2607 <entry>wmav1</entry>
|
|
2608 <entry>Windows Media Audio v1 codec</entry>
|
|
2609 </row>
|
|
2610 <row>
|
|
2611 <entry>wmav2</entry>
|
|
2612 <entry>Windows Media Audio v2 codec</entry>
|
|
2613 </row>
|
|
2614 </tbody>
|
|
2615 </tgroup>
|
|
2616 </informaltable>
|
|
2617
|
|
2618 The first column contains the codec names that should be passed after the
|
|
2619 <literal>acodec</literal> option, like: <option>-lavcopts acodec=ac3</option>
|
|
2620 </para>
|
|
2621
|
|
2622 <informalexample><para>
|
|
2623 An example with AC-3 compression:
|
|
2624 <screen>
|
|
2625 mencoder dvd://2 -o <replaceable>title2.avi</replaceable> -oac lavc -lavcopts acodec=ac3 -ovc copy
|
|
2626 </screen>
|
|
2627 </para></informalexample>
|
|
2628
|
|
2629 <para>
|
|
2630 Contrary to <systemitem class="library">libavcodec</systemitem>'s video
|
|
2631 codecs, its audio codecs do not make a wise usage of the bits they are
|
|
2632 given as they lack some minimal psychoacoustic model (if at all)
|
|
2633 which most other codec implementations feature.
|
|
2634 However, note that all these audio codecs are very fast and work
|
|
2635 out-of-the-box everywhere <application>MEncoder</application> has been
|
|
2636 compiled with <systemitem class="library">libavcodec</systemitem> (which
|
|
2637 is the case most of time), and do not depend on external libraries.
|
|
2638 </para>
|
|
2639 </sect2>
|
|
2640
|
|
2641 <!-- ********** -->
|
|
2642
|
|
2643 <sect2 id="menc-feat-dvd-mpeg4-lavc-encoding-options">
|
|
2644 <title>Encoding options of libavcodec</title>
|
|
2645
|
|
2646 <para>
|
|
2647 Ideally, you would probably want to be able to just tell the encoder to switch
|
|
2648 into "high quality" mode and move on.
|
|
2649 That would probably be nice, but unfortunately hard to implement as different
|
|
2650 encoding options yield different quality results depending on the source
|
|
2651 material. That is because compression depends on the visual properties of the
|
|
2652 video in question.
|
|
2653 For example, anime and live action have very different properties and
|
|
2654 thus require different options to obtain optimum encoding.
|
|
2655 The good news is that some options should never be left out, like
|
|
2656 <option>mbd=2</option>, <option>trell</option>, and <option>v4mv</option>.
|
|
2657 See below for a detailed description of common encoding options.
|
|
2658 </para>
|
|
2659
|
|
2660 <itemizedlist>
|
|
2661 <title>Options to adjust:</title>
|
|
2662 <listitem><para>
|
|
2663 <emphasis role="bold">vmax_b_frames</emphasis>: 1 or 2 is good, depending on
|
|
2664 the movie.
|
|
2665 Note that if you need to have your encode be decodable by DivX5, you
|
|
2666 need to activate closed GOP support, using
|
|
2667 <systemitem class="library">libavcodec</systemitem>'s <option>cgop</option>
|
|
2668 option, but you need to deactivate scene detection, which
|
|
2669 is not a good idea as it will hurt encode efficiency a bit.
|
|
2670 </para></listitem>
|
|
2671 <listitem><para>
|
|
2672 <emphasis role="bold">vb_strategy=1</emphasis>: helps in high-motion scenes.
|
|
2673 On some videos, vmax_b_frames may hurt quality, but vmax_b_frames=2 along
|
|
2674 with vb_strategy=1 helps.
|
|
2675 </para></listitem>
|
|
2676 <listitem><para>
|
|
2677 <emphasis role="bold">dia</emphasis>: motion search range. Bigger is better
|
|
2678 and slower.
|
|
2679 Negative values are a completely different scale.
|
|
2680 Good values are -1 for a fast encode, or 2-4 for slower.
|
|
2681 </para></listitem>
|
|
2682 <listitem><para>
|
|
2683 <emphasis role="bold">predia</emphasis>: motion search pre-pass.
|
|
2684 Not as important as dia. Good values are 1 (default) to 4. Requires preme=2
|
|
2685 to really be useful.
|
|
2686 </para></listitem>
|
|
2687 <listitem><para>
|
|
2688 <emphasis role="bold">cmp, subcmp, precmp</emphasis>: Comparison function for
|
|
2689 motion estimation.
|
|
2690 Experiment with values of 0 (default), 2 (hadamard), 3 (dct), and 6 (rate
|
|
2691 distortion).
|
|
2692 0 is fastest, and sufficient for precmp.
|
|
2693 For cmp and subcmp, 2 is good for anime, and 3 is good for live action.
|
|
2694 6 may or may not be slightly better, but is slow.
|
|
2695 </para></listitem>
|
|
2696 <listitem><para>
|
|
2697 <emphasis role="bold">last_pred</emphasis>: Number of motion predictors to
|
|
2698 take from the previous frame.
|
|
2699 1-3 or so help at little speed cost.
|
|
2700 Higher values are slow for no extra gain.
|
|
2701 </para></listitem>
|
|
2702 <listitem><para>
|
|
2703 <emphasis role="bold">cbp, mv0</emphasis>: Controls the selection of
|
|
2704 macroblocks. Small speed cost for small quality gain.
|
|
2705 </para></listitem>
|
|
2706 <listitem><para>
|
|
2707 <emphasis role="bold">qprd</emphasis>: adaptive quantization based on the
|
|
2708 macroblock's complexity.
|
|
2709 May help or hurt depending on the video and other options.
|
|
2710 This can cause artifacts unless you set vqmax to some reasonably small value
|
|
2711 (6 is good, maybe as low as 4); vqmin=1 should also help.
|
|
2712 </para></listitem>
|
|
2713 <listitem><para>
|
|
2714 <emphasis role="bold">qns</emphasis>: very slow, especially when combined
|
|
2715 with qprd.
|
|
2716 This option will make the encoder minimize noise due to compression
|
|
2717 artifacts instead of making the encoded video strictly match the source.
|
|
2718 Do not use this unless you have already tweaked everything else as far as it
|
|
2719 will go and the results still are not good enough.
|
|
2720 </para></listitem>
|
|
2721 <listitem><para>
|
|
2722 <emphasis role="bold">vqcomp</emphasis>: Tweak ratecontrol.
|
|
2723 What values are good depends on the movie.
|
|
2724 You can safely leave this alone if you want.
|
|
2725 Reducing vqcomp puts more bits on low-complexity scenes, increasing it puts
|
|
2726 them on high-complexity scenes (default: 0.5, range: 0-1. recommended range:
|
|
2727 0.5-0.7).
|
|
2728 </para></listitem>
|
|
2729 <listitem><para>
|
|
2730 <emphasis role="bold">vlelim, vcelim</emphasis>: Sets the single coefficient
|
|
2731 elimination threshold for luminance and chroma planes.
|
|
2732 These are encoded separately in all MPEG-like algorithms.
|
|
2733 The idea behind these options is to use some good heuristics to determine
|
|
2734 when the change in a block is less than the threshold you specify, and in
|
|
2735 such a case, to just encode the block as "no change".
|
|
2736 This saves bits and perhaps speeds up encoding. vlelim=-4 and vcelim=9
|
|
2737 seem to be good for live movies, but seem not to help with anime;
|
|
2738 when encoding animation, you should probably leave them unchanged.
|
|
2739 </para></listitem>
|
|
2740 <listitem><para>
|
|
2741 <emphasis role="bold">qpel</emphasis>: Quarter pixel motion estimation.
|
|
2742 MPEG-4 uses half pixel precision for its motion search by default,
|
|
2743 therefore this option comes with an overhead as more information will be
|
|
2744 stored in the encoded file.
|
|
2745 The compression gain/loss depends on the movie, but it is usually not very
|
|
2746 effective on anime.
|
|
2747 qpel always incurs a significant cost in CPU decode time (+25% in
|
|
2748 practice).
|
|
2749 </para></listitem>
|
|
2750 <listitem><para>
|
|
2751 <emphasis role="bold">psnr</emphasis>: does not affect the actual encoding,
|
|
2752 but writes a log file giving the type/size/quality of each frame, and
|
|
2753 prints a summary of PSNR (Peak Signal to Noise Ratio) at the end.
|
|
2754 </para></listitem>
|
|
2755 </itemizedlist>
|
|
2756
|
|
2757 <itemizedlist>
|
|
2758 <title>Options not recommended to play with:</title>
|
|
2759 <listitem><para>
|
|
2760 <emphasis role="bold">vme</emphasis>: The default is best.
|
|
2761 </para></listitem>
|
|
2762 <listitem><para>
|
|
2763 <emphasis role="bold">lumi_mask, dark_mask</emphasis>: Psychovisual adaptive
|
|
2764 quantization.
|
|
2765 You do not want to play with those options if you care about quality.
|
|
2766 Reasonable values may be effective in your case, but be warned this is very
|
|
2767 subjective.
|
|
2768 </para></listitem>
|
|
2769 <listitem><para>
|
|
2770 <emphasis role="bold">scplx_mask</emphasis>: Tries to prevent blocky
|
|
2771 artifacts, but postprocessing is better.
|
|
2772 </para></listitem>
|
|
2773 </itemizedlist>
|
|
2774 </sect2>
|
|
2775
|
|
2776 <!-- ********** -->
|
|
2777
|
|
2778 <sect2 id="menc-feat-mpeg4-lavc-example-settings">
|
|
2779 <title>Encoding setting examples</title>
|
|
2780
|
|
2781 <para>
|
|
2782 The following settings are examples of different encoding
|
|
2783 option combinations that affect the speed vs quality tradeoff
|
|
2784 at the same target bitrate.
|
|
2785 </para>
|
|
2786
|
|
2787 <para>
|
|
2788 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
2789 video sample, the target bitrate was 900kbps, and the machine was an
|
|
2790 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
2791 Each encoding setting features the measured encoding speed (in
|
|
2792 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
2793 high quality" setting.
|
|
2794 Please understand that depending on your source, your machine type
|
|
2795 and development advancements, you may get very different results.
|
|
2796 </para>
|
|
2797
|
|
2798 <para>
|
|
2799 <informaltable frame="all">
|
|
2800 <tgroup cols="4">
|
|
2801 <thead>
|
|
2802 <row>
|
|
2803 <entry>Description</entry>
|
|
2804 <entry>Encoding options</entry>
|
|
2805 <entry>speed (in fps)</entry>
|
|
2806 <entry>Relative PSNR loss (in dB)</entry>
|
|
2807 </row>
|
|
2808 </thead>
|
|
2809 <tbody>
|
|
2810 <row>
|
|
2811 <entry>Very high quality</entry>
|
|
2812 <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>
|
|
2813 <entry>6fps</entry>
|
|
2814 <entry>0dB</entry>
|
|
2815 </row>
|
|
2816 <row>
|
|
2817 <entry>High quality</entry>
|
|
2818 <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>
|
|
2819 <entry>15fps</entry>
|
|
2820 <entry>-0.5dB</entry>
|
|
2821 </row>
|
|
2822 <row>
|
|
2823 <entry>Fast</entry>
|
|
2824 <entry><option>vcodec=mpeg4:mbd=2:trell:v4mv:turbo</option></entry>
|
|
2825 <entry>42fps</entry>
|
|
2826 <entry>-0.74dB</entry>
|
|
2827 </row>
|
|
2828 <row>
|
|
2829 <entry>Realtime</entry>
|
|
2830 <entry><option>vcodec=mpeg4:mbd=2:turbo</option></entry>
|
|
2831 <entry>54fps</entry>
|
|
2832 <entry>-1.21dB</entry>
|
|
2833 </row>
|
|
2834 </tbody>
|
|
2835 </tgroup>
|
|
2836 </informaltable>
|
|
2837 </para>
|
|
2838 </sect2>
|
|
2839
|
|
2840 <!-- ********** -->
|
|
2841
|
|
2842 <sect2 id="custommatrices">
|
|
2843 <title>Custom inter/intra matrices</title>
|
|
2844
|
|
2845 <para>
|
|
2846 With this feature of
|
|
2847 <link linkend="ffmpeg"><systemitem class="library">libavcodec</systemitem></link>
|
|
2848 you are able to set custom inter (I-frames/keyframes) and intra
|
|
2849 (P-frames/predicted frames) matrices. It is supported by many of the codecs:
|
|
2850 <systemitem>mpeg1video</systemitem> and <systemitem>mpeg2video</systemitem>
|
|
2851 are reported as working.
|
|
2852 </para>
|
|
2853
|
|
2854 <para>
|
|
2855 A typical usage of this feature is to set the matrices preferred by the
|
|
2856 <ulink url="http://www.kvcd.net/">KVCD</ulink> specifications.
|
|
2857 </para>
|
|
2858
|
|
2859 <para>
|
|
2860 The <emphasis role="bold">KVCD "Notch" Quantization Matrix:</emphasis>
|
|
2861 </para>
|
|
2862
|
|
2863 <para>
|
|
2864 Intra:
|
|
2865 <screen>
|
|
2866 8 9 12 22 26 27 29 34
|
|
2867 9 10 14 26 27 29 34 37
|
|
2868 12 14 18 27 29 34 37 38
|
|
2869 22 26 27 31 36 37 38 40
|
|
2870 26 27 29 36 39 38 40 48
|
|
2871 27 29 34 37 38 40 48 58
|
|
2872 29 34 37 38 40 48 58 69
|
|
2873 34 37 38 40 48 58 69 79
|
|
2874 </screen>
|
|
2875
|
|
2876 Inter:
|
|
2877 <screen>
|
|
2878 16 18 20 22 24 26 28 30
|
|
2879 18 20 22 24 26 28 30 32
|
|
2880 20 22 24 26 28 30 32 34
|
|
2881 22 24 26 30 32 32 34 36
|
|
2882 24 26 28 32 34 34 36 38
|
|
2883 26 28 30 32 34 36 38 40
|
|
2884 28 30 32 34 36 38 42 42
|
|
2885 30 32 34 36 38 40 42 44
|
|
2886 </screen>
|
|
2887 </para>
|
|
2888
|
|
2889 <para>
|
|
2890 Usage:
|
|
2891 <screen>
|
|
2892 mencoder <replaceable>input.avi</replaceable> -o <replaceable>output.avi</replaceable> -oac copy -ovc lavc \
|
|
2893 -lavcopts inter_matrix=...:intra_matrix=...
|
|
2894 </screen>
|
|
2895 </para>
|
|
2896
|
|
2897 <para>
|
|
2898 <screen>
|
|
2899 mencoder <replaceable>input.avi</replaceable> -ovc lavc -lavcopts \
|
|
2900 vcodec=mpeg2video:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,\
|
|
2901 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,\
|
|
2902 29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79\
|
|
2903 :inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,\
|
|
2904 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,\
|
|
2905 36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 -oac copy -o svcd.mpg
|
|
2906 </screen>
|
|
2907 </para>
|
|
2908 </sect2>
|
|
2909
|
|
2910 <!-- ********** -->
|
|
2911
|
|
2912 <sect2 id="menc-feat-dvd-mpeg4-example">
|
|
2913 <title>Example</title>
|
|
2914
|
|
2915 <para>
|
|
2916 So, you have just bought your shiny new copy of Harry Potter and the Chamber
|
|
2917 of Secrets (widescreen edition, of course), and you want to rip this DVD
|
|
2918 so that you can add it to your Home Theatre PC. This is a region 1 DVD,
|
|
2919 so it is NTSC. The example below will still apply to PAL, except you will
|
|
2920 omit <option>-ofps 24000/1001</option> (because the output framerate is the
|
|
2921 same as the input framerate), and of course the crop dimensions will be
|
|
2922 different.
|
|
2923 </para>
|
|
2924
|
|
2925 <para>
|
|
2926 After running <option>mplayer dvd://1</option>, we follow the process
|
|
2927 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
2928 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
2929 24000/1001 fps progressive video, which means that we need not use an inverse
|
|
2930 telecine filter, such as <option>pullup</option> or
|
|
2931 <option>filmdint</option>.
|
|
2932 </para>
|
|
2933
|
|
2934 <para id="menc-feat-dvd-mpeg4-example-crop">
|
|
2935 Next, we want to determine the appropriate crop rectangle, so we use the
|
|
2936 cropdetect filter:
|
|
2937 <screen>mplayer dvd://1 -vf cropdetect</screen>
|
|
2938 Make sure you seek to a fully filled frame (such as a bright scene,
|
|
2939 past the opening credits and logos), and
|
|
2940 you will see in <application>MPlayer</application>'s console output:
|
|
2941 <screen>crop area: X: 0..719 Y: 57..419 (-vf crop=720:362:0:58)</screen>
|
|
2942 We then play the movie back with this filter to test its correctness:
|
|
2943 <screen>mplayer dvd://1 -vf crop=720:362:0:58</screen>
|
|
2944 And we see that it looks perfectly fine. Next, we ensure the width and
|
|
2945 height are a multiple of 16. The width is fine, however the height is
|
|
2946 not. Since we did not fail 7th grade math, we know that the nearest
|
|
2947 multiple of 16 lower than 362 is 352.
|
|
2948 </para>
|
|
2949
|
|
2950 <para>
|
|
2951 We could just use <option>crop=720:352:0:58</option>, but it would be nice
|
|
2952 to take a little off the top and a little off the bottom so that we
|
|
2953 retain the center. We have shrunk the height by 10 pixels, but we do not
|
|
2954 want to increase the y-offset by 5-pixels since that is an odd number and
|
|
2955 will adversely affect quality. Instead, we will increase the y-offset by
|
|
2956 4 pixels:
|
|
2957 <screen>mplayer dvd://1 -vf crop=720:352:0:62</screen>
|
|
2958 Another reason to shave pixels from both the top and the bottom is that we
|
|
2959 ensure we have eliminated any half-black pixels if they exist. Note that if
|
|
2960 your video is telecined, make sure the <option>pullup</option> filter (or
|
|
2961 whichever inverse telecine filter you decide to use) appears in the filter
|
|
2962 chain before you crop. If it is interlaced, deinterlace before cropping.
|
|
2963 (If you choose to preserve the interlaced video, then make sure your
|
|
2964 vertical crop offset is a multiple of 4.)
|
|
2965 </para>
|
|
2966
|
|
2967 <para>
|
|
2968 If you are really concerned about losing those 10 pixels, you might
|
|
2969 prefer instead to scale the dimensions down to the nearest multiple of 16.
|
|
2970 The filter chain would look like:
|
|
2971 <screen>-vf crop=720:362:0:58,scale=720:352</screen>
|
|
2972 Scaling the video down like this will mean that some small amount of
|
|
2973 detail is lost, though it probably will not be perceptible. Scaling up will
|
|
2974 result in lower quality (unless you increase the bitrate). Cropping
|
|
2975 discards those pixels altogether. It is a tradeoff that you will want to
|
|
2976 consider for each circumstance. For example, if the DVD video was made
|
|
2977 for television, you might want to avoid vertical scaling, since the line
|
|
2978 sampling corresponds to the way the content was originally recorded.
|
|
2979 </para>
|
|
2980
|
|
2981 <para>
|
|
2982 On inspection, we see that our movie has a fair bit of action and high
|
|
2983 amounts of detail, so we pick 2400Kbit for our bitrate.
|
|
2984 </para>
|
|
2985
|
|
2986 <para>
|
|
2987 We are now ready to do the two pass encode. Pass one:
|
|
2988 <screen>
|
|
2989 mencoder dvd://1 -ofps 24000/1001 -oac copy -o <replaceable>Harry_Potter_2.avi</replaceable> -ovc lavc \
|
|
2990 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=1 \
|
|
2991 -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
|
|
2992 </screen>
|
|
2993 And pass two is the same, except that we specify <option>vpass=2</option>:
|
|
2994 <screen>
|
|
2995 mencoder dvd://1 -ofps 24000/1001 -oac copy -o <replaceable>Harry_Potter_2.avi</replaceable> -ovc lavc \
|
|
2996 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=2 \
|
|
2997 -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
|
|
2998 </screen>
|
|
2999 </para>
|
|
3000
|
|
3001 <para>
|
|
3002 The options <option>v4mv:mbd=2:trell</option> will greatly increase the
|
|
3003 quality at the expense of encoding time. There is little reason to leave
|
|
3004 these options out when the primary goal is quality. The options
|
|
3005 <option>cmp=3:subcmp=3</option> select a comparison function that
|
|
3006 yields higher quality than the defaults. You might try experimenting with
|
|
3007 this parameter (refer to the man page for the possible values) as
|
|
3008 different functions can have a large impact on quality depending on the
|
|
3009 source material. For example, if you find
|
|
3010 <systemitem class="library">libavcodec</systemitem> produces too much
|
|
3011 blocky artifacting, you could try selecting the experimental NSSE as
|
|
3012 comparison function via <option>*cmp=10</option>.
|
|
3013 </para>
|
|
3014
|
|
3015 <para>
|
|
3016 For this movie, the resulting AVI will be 138 minutes long and nearly
|
|
3017 3GB. And because you said that file size does not matter, this is a
|
|
3018 perfectly acceptable size. However, if you had wanted it smaller, you
|
|
3019 could try a lower bitrate. Increasing bitrates have diminishing
|
|
3020 returns, so while we might clearly see an improvement from 1800Kbit to
|
|
3021 2000Kbit, it might not be so noticeable above 2000Kbit. Feel
|
|
3022 free to experiment until you are happy.
|
|
3023 </para>
|
|
3024
|
|
3025 <para>
|
|
3026 Because we passed the source video through a denoise filter, you may want
|
|
3027 to add some of it back during playback. This, along with the
|
|
3028 <option>spp</option> post-processing filter, drastically improves the
|
|
3029 perception of quality and helps eliminate blocky artifacts in the video.
|
|
3030 With <application>MPlayer</application>'s <option>autoq</option> option,
|
|
3031 you can vary the amount of post-processing done by the spp filter
|
|
3032 depending on available CPU. Also, at this point, you may want to apply
|
|
3033 gamma and/or color correction to best suit your display. For example:
|
|
3034 <screen>
|
|
3035 mplayer <replaceable>Harry_Potter_2.avi</replaceable> -vf spp,noise=9ah:5ah,eq2=1.2 -autoq 3
|
|
3036 </screen>
|
|
3037 </para>
|
|
3038 </sect2>
|
|
3039 </sect1>
|
|
3040
|
|
3041
|
|
3042 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
3043
|
|
3044
|
|
3045 <sect1 id="menc-feat-xvid">
|
|
3046 <title>Encoding with the <systemitem class="library">Xvid</systemitem>
|
|
3047 codec</title>
|
|
3048
|
|
3049 <para>
|
|
3050 <systemitem class="library">Xvid</systemitem> is a free library for
|
|
3051 encoding MPEG-4 ASP video streams.
|
|
3052 Before starting to encode, you need to <link linkend="xvid">
|
|
3053 set up <application>MEncoder</application> to support it</link>.
|
|
3054 </para>
|
|
3055
|
|
3056 <para>
|
|
3057 This guide mainly aims at featuring the same kind of information
|
|
3058 as x264's encoding guide.
|
|
3059 Therefore, please begin by reading
|
|
3060 <link linkend="menc-feat-x264-encoding-options-intro">the first part</link>
|
|
3061 of that guide.
|
|
3062 </para>
|
|
3063
|
|
3064 <!-- ********** -->
|
|
3065
|
|
3066 <sect2 id="menc-feat-xvid-intro">
|
|
3067 <title>What options should I use to get the best results?</title>
|
|
3068
|
|
3069 <para>
|
|
3070 Please begin by reviewing the
|
|
3071 <systemitem class="library">Xvid</systemitem> section of
|
|
3072 <application>MPlayer</application>'s man page.
|
|
3073 This section is intended to be a supplement to the man page.
|
|
3074 </para>
|
|
3075
|
|
3076 <para>
|
|
3077 The Xvid default settings are already a good tradeoff between
|
|
3078 speed and quality, therefore you can safely stick to them if
|
|
3079 the following section puzzles you.
|
|
3080 </para>
|
|
3081 </sect2>
|
|
3082
|
|
3083 <!-- ********** -->
|
|
3084
|
|
3085 <sect2 id="menc-feat-xvid-encoding-options">
|
|
3086 <title>Encoding options of <systemitem class="library">Xvid</systemitem></title>
|
|
3087
|
|
3088 <itemizedlist>
|
|
3089 <listitem><para>
|
|
3090 <emphasis role="bold">vhq</emphasis>
|
|
3091 This setting affects the macroblock decision algorithm, where the
|
|
3092 higher the setting, the wiser the decision.
|
|
3093 The default setting may be safely used for every encode, while
|
|
3094 higher settings always help PSNR but are significantly slower.
|
|
3095 Please note that a better PSNR does not necessarily mean
|
|
3096 that the picture will look better, but tells you that it is
|
|
3097 closer to the original.
|
|
3098 Turning it off will noticeably speed up encoding; if speed is
|
|
3099 critical for you, the tradeoff may be worth it.
|
|
3100 </para></listitem>
|
|
3101 <listitem><para>
|
|
3102 <emphasis role="bold">bvhq</emphasis>
|
|
3103 This does the same job as vhq, but does it on B-frames.
|
|
3104 It has a negligible impact on speed, and slightly improves quality
|
|
3105 (around +0.1dB PSNR).
|
|
3106 </para></listitem>
|
|
3107 <listitem><para>
|
|
3108 <emphasis role="bold">max_bframes</emphasis>
|
|
3109 A higher number of consecutive allowed B-frames usually improves
|
|
3110 compressibility, although it may also lead to more blocking artifacts.
|
|
3111 The default setting is a good tradeoff between compressibility and
|
|
3112 quality, but you may increase it up to 3 if you are bitrate-starved.
|
|
3113 You may also decrease it to 1 or 0 if you are aiming at perfect
|
|
3114 quality, though in that case you should make sure your
|
|
3115 target bitrate is high enough to ensure that the encoder does not
|
|
3116 have to increase quantizers to reach it.
|
|
3117 </para></listitem>
|
|
3118 <listitem><para>
|
|
3119 <emphasis role="bold">bf_threshold</emphasis>
|
|
3120 This controls the B-frame sensitivity of the encoder, where a higher
|
|
3121 value leads to more B-frames being used (and vice versa).
|
|
3122 This setting is to be used together with <option>max_bframes</option>;
|
|
3123 if you are bitrate-starved, you should increase both
|
|
3124 <option>max_bframes</option> and <option>bf_threshold</option>,
|
|
3125 while you may increase <option>max_bframes</option> and reduce
|
|
3126 <option>bf_threshold</option> so that the encoder may use more
|
|
3127 B-frames in places that only <emphasis role="bold">really</emphasis>
|
|
3128 need them.
|
|
3129 A low number of <option>max_bframes</option> and a high value of
|
|
3130 <option>bf_threshold</option> is probably not a wise choice as it
|
|
3131 will force the encoder to put B-frames in places that would not
|
|
3132 benefit from them, therefore reducing visual quality.
|
|
3133 However, if you need to be compatible with standalone players that
|
|
3134 only support old DivX profiles (which only supports up to 1
|
|
3135 consecutive B-frame), this would be your only way to
|
|
3136 increase compressibility through using B-frames.
|
|
3137 </para></listitem>
|
|
3138 <listitem><para>
|
|
3139 <emphasis role="bold">trellis</emphasis>
|
|
3140 Optimizes the quantization process to get an optimal tradeoff
|
|
3141 between PSNR and bitrate, which allows significant bit saving.
|
|
3142 These bits will in return be spent elsewhere on the video,
|
|
3143 raising overall visual quality.
|
|
3144 You should always leave it on as its impact on quality is huge.
|
|
3145 Even if you are looking for speed, do not disable it until you
|
|
3146 have turned down <option>vhq</option> and all other more
|
|
3147 CPU-hungry options to the minimum.
|
|
3148 </para></listitem>
|
|
3149 <listitem><para>
|
|
3150 <emphasis role="bold">hq_ac</emphasis>
|
|
3151 Activates a better coefficient cost estimation method, which slightly
|
|
3152 reduces filesize by around 0.15 to 0.19% (which corresponds to less
|
|
3153 than 0.01dB PSNR increase), while having a negligible impact on speed.
|
|
3154 It is therefore recommended to always leave it on.
|
|
3155 </para></listitem>
|
|
3156 <listitem><para>
|
|
3157 <emphasis role="bold">cartoon</emphasis>
|
|
3158 Designed to better encode cartoon content, and has no impact on
|
|
3159 speed as it just tunes the mode decision heuristics for this type
|
|
3160 of content.
|
|
3161 </para></listitem>
|
|
3162 <listitem>
|
|
3163 <para>
|
|
3164 <emphasis role="bold">me_quality</emphasis>
|
|
3165 This setting is to control the precision of the motion estimation.
|
|
3166 The higher <option>me_quality</option>, the more
|
|
3167 precise the estimation of the original motion will be, and the
|
|
3168 better the resulting clip will capture the original motion.
|
|
3169 </para>
|
|
3170 <para>
|
|
3171 The default setting is best in all cases;
|
|
3172 thus it is not recommended to turn it down unless you are
|
|
3173 really looking for speed, as all the bits saved by a good motion
|
|
3174 estimation would be spent elsewhere, raising overall quality.
|
|
3175 Therefore, do not go any lower than 5, and even that only as a last
|
|
3176 resort.
|
|
3177 </para>
|
|
3178 </listitem>
|
|
3179 <listitem><para>
|
|
3180 <emphasis role="bold">chroma_me</emphasis>
|
|
3181 Improves motion estimation by also taking the chroma (color)
|
|
3182 information into account, whereas <option>me_quality</option>
|
|
3183 alone only uses luma (grayscale).
|
|
3184 This slows down encoding by 5-10% but improves visual quality
|
|
3185 quite a bit by reducing blocking effects and reduces filesize by
|
|
3186 around 1.3%.
|
|
3187 If you are looking for speed, you should disable this option before
|
|
3188 starting to consider reducing <option>me_quality</option>.
|
|
3189 </para></listitem>
|
|
3190 <listitem><para>
|
|
3191 <emphasis role="bold">chroma_opt</emphasis>
|
|
3192 Is intended to increase chroma image quality around pure
|
|
3193 white/black edges, rather than improving compression.
|
|
3194 This can help to reduce the "red stairs" effect.
|
|
3195 </para></listitem>
|
|
3196 <listitem><para>
|
|
3197 <emphasis role="bold">lumi_mask</emphasis>
|
|
3198 Tries to give less bitrate to part of the picture that the
|
|
3199 human eye cannot see very well, which should allow the encoder
|
|
3200 to spend the saved bits on more important parts of the picture.
|
|
3201 The quality of the encode yielded by this option highly depends
|
|
3202 on personal preferences and on the type and monitor settings
|
|
3203 used to watch it (typically, it will not look as good if it is
|
|
3204 bright or if it is a TFT monitor).
|
|
3205 </para></listitem>
|
|
3206 <listitem>
|
|
3207 <para>
|
|
3208 <emphasis role="bold">qpel</emphasis>
|
|
3209 Raise the number of candidate motion vectors by increasing
|
|
3210 the precision of the motion estimation from halfpel to
|
|
3211 quarterpel.
|
|
3212 The idea is to find better motion vectors which will in return
|
|
3213 reduce bitrate (hence increasing quality).
|
|
3214 However, motion vectors with quarterpel precision require a
|
|
3215 few extra bits to code, but the candidate vectors do not always
|
|
3216 give (much) better results.
|
|
3217 Quite often, the codec still spends bits on the extra precision,
|
|
3218 but little or no extra quality is gained in return.
|
|
3219 Unfortunately, there is no way to foresee the possible gains of
|
|
3220 <option>qpel</option>, so you need to actually encode with and
|
|
3221 without it to know for sure.
|
|
3222 </para>
|
|
3223 <para>
|
|
3224 <option>qpel</option> can be almost double encoding time, and
|
|
3225 requires as much as 25% more processing power to decode.
|
|
3226 It is not supported by all standalone players.
|
|
3227 </para>
|
|
3228 </listitem>
|
|
3229 <listitem><para>
|
|
3230 <emphasis role="bold">gmc</emphasis>
|
|
3231 Tries to save bits on panning scenes by using a single motion
|
|
3232 vector for the whole frame.
|
|
3233 This almost always raises PSNR, but significantly slows down
|
|
3234 encoding (as well as decoding).
|
|
3235 Therefore, you should only use it when you have turned
|
|
3236 <option>vhq</option> to the maximum.
|
|
3237 <systemitem class="library">Xvid</systemitem>'s GMC is more
|
|
3238 sophisticated than DivX's, but is only supported by few
|
|
3239 standalone players.
|
|
3240 </para></listitem>
|
|
3241 </itemizedlist>
|
|
3242 </sect2>
|
|
3243
|
|
3244 <!-- ********** -->
|
|
3245
|
|
3246 <sect2 id="menc-feat-xvid-encoding-profiles">
|
|
3247 <title>Encoding profiles</title>
|
|
3248
|
|
3249 <para>
|
|
3250 Xvid supports encoding profiles through the <option>profile</option> option,
|
|
3251 which are used to impose restrictions on the properties of the Xvid video
|
|
3252 stream such that it will be playable on anything which supports the
|
|
3253 chosen profile.
|
|
3254 The restrictions relate to resolutions, bitrates and certain MPEG-4
|
|
3255 features.
|
|
3256 The following table shows what each profile supports.
|
|
3257 </para>
|
|
3258
|
|
3259 <informaltable>
|
|
3260 <tgroup cols="16" align="center">
|
|
3261 <colspec colnum="1" colname="col1"/>
|
|
3262 <colspec colnum="2" colname="col2"/>
|
|
3263 <colspec colnum="3" colname="col3"/>
|
|
3264 <colspec colnum="4" colname="col4"/>
|
|
3265 <colspec colnum="5" colname="col5"/>
|
|
3266 <colspec colnum="6" colname="col6"/>
|
|
3267 <colspec colnum="7" colname="col7"/>
|
|
3268 <colspec colnum="8" colname="col8"/>
|
|
3269 <colspec colnum="9" colname="col9"/>
|
|
3270 <colspec colnum="10" colname="col10"/>
|
|
3271 <colspec colnum="11" colname="col11"/>
|
|
3272 <colspec colnum="12" colname="col12"/>
|
|
3273 <colspec colnum="13" colname="col13"/>
|
|
3274 <colspec colnum="14" colname="col14"/>
|
|
3275 <colspec colnum="15" colname="col15"/>
|
|
3276 <colspec colnum="16" colname="col16"/>
|
|
3277 <colspec colnum="17" colname="col17"/>
|
|
3278 <spanspec spanname="spa2-5" namest="col2" nameend="col5"/>
|
|
3279 <spanspec spanname="spa6-11" namest="col6" nameend="col11"/>
|
|
3280 <spanspec spanname="spa12-17" namest="col12" nameend="col17"/>
|
|
3281 <tbody>
|
|
3282 <row>
|
|
3283 <entry></entry>
|
|
3284 <entry spanname="spa2-5">Simple</entry>
|
|
3285 <entry spanname="spa6-11">Advanced Simple</entry>
|
|
3286 <entry spanname="spa12-17">DivX</entry>
|
|
3287 </row>
|
|
3288 <row>
|
|
3289 <entry>Profile name</entry>
|
|
3290 <entry>0</entry>
|
|
3291 <entry>1</entry>
|
|
3292 <entry>2</entry>
|
|
3293 <entry>3</entry>
|
|
3294 <entry>0</entry>
|
|
3295 <entry>1</entry>
|
|
3296 <entry>2</entry>
|
|
3297 <entry>3</entry>
|
|
3298 <entry>4</entry>
|
|
3299 <entry>5</entry>
|
|
3300 <entry>Handheld</entry>
|
|
3301 <entry>Portable NTSC</entry>
|
|
3302 <entry>Portable PAL</entry>
|
|
3303 <entry>Home Theater NTSC</entry>
|
|
3304 <entry>Home Theater PAL</entry>
|
|
3305 <entry>HDTV</entry>
|
|
3306 </row>
|
|
3307 <row>
|
|
3308 <entry>Width [pixels]</entry>
|
|
3309 <entry>176</entry>
|
|
3310 <entry>176</entry>
|
|
3311 <entry>352</entry>
|
|
3312 <entry>352</entry>
|
|
3313 <entry>176</entry>
|
|
3314 <entry>176</entry>
|
|
3315 <entry>352</entry>
|
|
3316 <entry>352</entry>
|
|
3317 <entry>352</entry>
|
|
3318 <entry>720</entry>
|
|
3319 <entry>176</entry>
|
|
3320 <entry>352</entry>
|
|
3321 <entry>352</entry>
|
|
3322 <entry>720</entry>
|
|
3323 <entry>720</entry>
|
|
3324 <entry>1280</entry>
|
|
3325 </row>
|
|
3326 <row>
|
|
3327 <entry>Height [pixels]</entry>
|
|
3328 <entry>144</entry>
|
|
3329 <entry>144</entry>
|
|
3330 <entry>288</entry>
|
|
3331 <entry>288</entry>
|
|
3332 <entry>144</entry>
|
|
3333 <entry>144</entry>
|
|
3334 <entry>288</entry>
|
|
3335 <entry>288</entry>
|
|
3336 <entry>576</entry>
|
|
3337 <entry>576</entry>
|
|
3338 <entry>144</entry>
|
|
3339 <entry>240</entry>
|
|
3340 <entry>288</entry>
|
|
3341 <entry>480</entry>
|
|
3342 <entry>576</entry>
|
|
3343 <entry>720</entry>
|
|
3344 </row>
|
|
3345 <row>
|
|
3346 <entry>Frame rate [fps]</entry>
|
|
3347 <entry>15</entry>
|
|
3348 <entry>15</entry>
|
|
3349 <entry>15</entry>
|
|
3350 <entry>15</entry>
|
|
3351 <entry>30</entry>
|
|
3352 <entry>30</entry>
|
|
3353 <entry>15</entry>
|
|
3354 <entry>30</entry>
|
|
3355 <entry>30</entry>
|
|
3356 <entry>30</entry>
|
|
3357 <entry>15</entry>
|
|
3358 <entry>30</entry>
|
|
3359 <entry>25</entry>
|
|
3360 <entry>30</entry>
|
|
3361 <entry>25</entry>
|
|
3362 <entry>30</entry>
|
|
3363 </row>
|
|
3364 <row>
|
|
3365 <entry>Max average bitrate [kbps]</entry>
|
|
3366 <entry>64</entry>
|
|
3367 <entry>64</entry>
|
|
3368 <entry>128</entry>
|
|
3369 <entry>384</entry>
|
|
3370 <entry>128</entry>
|
|
3371 <entry>128</entry>
|
|
3372 <entry>384</entry>
|
|
3373 <entry>768</entry>
|
|
3374 <entry>3000</entry>
|
|
3375 <entry>8000</entry>
|
|
3376 <entry>537.6</entry>
|
|
3377 <entry>4854</entry>
|
|
3378 <entry>4854</entry>
|
|
3379 <entry>4854</entry>
|
|
3380 <entry>4854</entry>
|
|
3381 <entry>9708.4</entry>
|
|
3382 </row>
|
|
3383 <row>
|
|
3384 <entry>Peak average bitrate over 3 secs [kbps]</entry>
|
|
3385 <entry></entry>
|
|
3386 <entry></entry>
|
|
3387 <entry></entry>
|
|
3388 <entry></entry>
|
|
3389 <entry></entry>
|
|
3390 <entry></entry>
|
|
3391 <entry></entry>
|
|
3392 <entry></entry>
|
|
3393 <entry></entry>
|
|
3394 <entry></entry>
|
|
3395 <entry>800</entry>
|
|
3396 <entry>8000</entry>
|
|
3397 <entry>8000</entry>
|
|
3398 <entry>8000</entry>
|
|
3399 <entry>8000</entry>
|
|
3400 <entry>16000</entry>
|
|
3401 </row>
|
|
3402 <row>
|
|
3403 <entry>Max. B-frames</entry>
|
|
3404 <entry>0</entry>
|
|
3405 <entry>0</entry>
|
|
3406 <entry>0</entry>
|
|
3407 <entry>0</entry>
|
|
3408 <entry></entry>
|
|
3409 <entry></entry>
|
|
3410 <entry></entry>
|
|
3411 <entry></entry>
|
|
3412 <entry></entry>
|
|
3413 <entry></entry>
|
|
3414 <entry>0</entry>
|
|
3415 <entry>1</entry>
|
|
3416 <entry>1</entry>
|
|
3417 <entry>1</entry>
|
|
3418 <entry>1</entry>
|
|
3419 <entry>2</entry>
|
|
3420 </row>
|
|
3421 <row>
|
|
3422 <entry>MPEG quantization</entry>
|
|
3423 <entry></entry>
|
|
3424 <entry></entry>
|
|
3425 <entry></entry>
|
|
3426 <entry></entry>
|
|
3427 <entry>X</entry>
|
|
3428 <entry>X</entry>
|
|
3429 <entry>X</entry>
|
|
3430 <entry>X</entry>
|
|
3431 <entry>X</entry>
|
|
3432 <entry>X</entry>
|
|
3433 <entry></entry>
|
|
3434 <entry></entry>
|
|
3435 <entry></entry>
|
|
3436 <entry></entry>
|
|
3437 <entry></entry>
|
|
3438 <entry></entry>
|
|
3439 </row>
|
|
3440 <row>
|
|
3441 <entry>Adaptive quantization</entry>
|
|
3442 <entry></entry>
|
|
3443 <entry></entry>
|
|
3444 <entry></entry>
|
|
3445 <entry></entry>
|
|
3446 <entry>X</entry>
|
|
3447 <entry>X</entry>
|
|
3448 <entry>X</entry>
|
|
3449 <entry>X</entry>
|
|
3450 <entry>X</entry>
|
|
3451 <entry>X</entry>
|
|
3452 <entry>X</entry>
|
|
3453 <entry>X</entry>
|
|
3454 <entry>X</entry>
|
|
3455 <entry>X</entry>
|
|
3456 <entry>X</entry>
|
|
3457 <entry>X</entry>
|
|
3458 </row>
|
|
3459 <row>
|
|
3460 <entry>Interlaced encoding</entry>
|
|
3461 <entry></entry>
|
|
3462 <entry></entry>
|
|
3463 <entry></entry>
|
|
3464 <entry></entry>
|
|
3465 <entry>X</entry>
|
|
3466 <entry>X</entry>
|
|
3467 <entry>X</entry>
|
|
3468 <entry>X</entry>
|
|
3469 <entry>X</entry>
|
|
3470 <entry>X</entry>
|
|
3471 <entry></entry>
|
|
3472 <entry></entry>
|
|
3473 <entry></entry>
|
|
3474 <entry>X</entry>
|
|
3475 <entry>X</entry>
|
|
3476 <entry>X</entry>
|
|
3477 </row>
|
|
3478 <row>
|
|
3479 <entry>Quaterpixel</entry>
|
|
3480 <entry></entry>
|
|
3481 <entry></entry>
|
|
3482 <entry></entry>
|
|
3483 <entry></entry>
|
|
3484 <entry>X</entry>
|
|
3485 <entry>X</entry>
|
|
3486 <entry>X</entry>
|
|
3487 <entry>X</entry>
|
|
3488 <entry>X</entry>
|
|
3489 <entry>X</entry>
|
|
3490 <entry></entry>
|
|
3491 <entry></entry>
|
|
3492 <entry></entry>
|
|
3493 <entry></entry>
|
|
3494 <entry></entry>
|
|
3495 <entry></entry>
|
|
3496 </row>
|
|
3497 <row>
|
|
3498 <entry>Global motion compensation</entry>
|
|
3499 <entry></entry>
|
|
3500 <entry></entry>
|
|
3501 <entry></entry>
|
|
3502 <entry></entry>
|
|
3503 <entry>X</entry>
|
|
3504 <entry>X</entry>
|
|
3505 <entry>X</entry>
|
|
3506 <entry>X</entry>
|
|
3507 <entry>X</entry>
|
|
3508 <entry>X</entry>
|
|
3509 <entry></entry>
|
|
3510 <entry></entry>
|
|
3511 <entry></entry>
|
|
3512 <entry></entry>
|
|
3513 <entry></entry>
|
|
3514 <entry></entry>
|
|
3515 </row>
|
|
3516 </tbody>
|
|
3517 </tgroup>
|
|
3518 </informaltable>
|
|
3519 </sect2>
|
|
3520
|
|
3521 <!-- ********** -->
|
|
3522
|
|
3523 <sect2 id="menc-feat-xvid-example-settings">
|
|
3524 <title>Encoding setting examples</title>
|
|
3525
|
|
3526 <para>
|
|
3527 The following settings are examples of different encoding
|
|
3528 option combinations that affect the speed vs quality tradeoff
|
|
3529 at the same target bitrate.
|
|
3530 </para>
|
|
3531
|
|
3532 <para>
|
|
3533 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
3534 video sample, the target bitrate was 900kbps, and the machine was an
|
|
3535 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
3536 Each encoding setting features the measured encoding speed (in
|
|
3537 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
3538 high quality" setting.
|
|
3539 Please understand that depending on your source, your machine type
|
|
3540 and development advancements, you may get very different results.
|
|
3541 </para>
|
|
3542
|
|
3543 <informaltable frame="all">
|
|
3544 <tgroup cols="4">
|
|
3545 <thead>
|
|
3546 <row><entry>Description</entry><entry>Encoding options</entry><entry>speed (in fps)</entry><entry>Relative PSNR loss (in dB)</entry></row>
|
|
3547 </thead>
|
|
3548 <tbody>
|
|
3549 <row>
|
|
3550 <entry>Very high quality</entry>
|
|
3551 <entry><option>chroma_opt:vhq=4:bvhq=1:quant_type=mpeg</option></entry>
|
|
3552 <entry>16fps</entry>
|
|
3553 <entry>0dB</entry>
|
|
3554 </row>
|
|
3555 <row>
|
|
3556 <entry>High quality</entry>
|
|
3557 <entry><option>vhq=2:bvhq=1:chroma_opt:quant_type=mpeg</option></entry>
|
|
3558 <entry>18fps</entry>
|
|
3559 <entry>-0.1dB</entry>
|
|
3560 </row>
|
|
3561 <row>
|
|
3562 <entry>Fast</entry>
|
|
3563 <entry><option>turbo:vhq=0</option></entry>
|
|
3564 <entry>28fps</entry>
|
|
3565 <entry>-0.69dB</entry>
|
|
3566 </row>
|
|
3567 <row>
|
|
3568 <entry>Realtime</entry>
|
|
3569 <entry><option>turbo:nochroma_me:notrellis:max_bframes=0:vhq=0</option></entry>
|
|
3570 <entry>38fps</entry>
|
|
3571 <entry>-1.48dB</entry>
|
|
3572 </row>
|
|
3573 </tbody>
|
|
3574 </tgroup>
|
|
3575 </informaltable>
|
|
3576 </sect2>
|
|
3577 </sect1>
|
|
3578
|
|
3579
|
|
3580 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
3581
|
|
3582
|
|
3583 <sect1 id="menc-feat-x264">
|
|
3584 <title>Encoding with the
|
|
3585 <systemitem class="library">x264</systemitem> codec</title>
|
|
3586
|
|
3587 <para>
|
|
3588 <systemitem class="library">x264</systemitem> is a free library for
|
|
3589 encoding H.264/AVC video streams.
|
|
3590 Before starting to encode, you need to
|
|
3591 <link linkend="codec-x264-encode">set up <application>MEncoder</application> to support it</link>.
|
|
3592 </para>
|
|
3593
|
|
3594 <!-- ********** -->
|
|
3595
|
|
3596 <sect2 id="menc-feat-x264-encoding-options">
|
|
3597 <title>Encoding options of x264</title>
|
|
3598
|
|
3599 <para>
|
|
3600 Please begin by reviewing the
|
|
3601 <systemitem class="library">x264</systemitem> section of
|
|
3602 <application>MPlayer</application>'s man page.
|
|
3603 This section is intended to be a supplement to the man page.
|
|
3604 Here you will find quick hints about which options are most
|
|
3605 likely to interest most people. The man page is more terse,
|
|
3606 but also more exhaustive, and it sometimes offers much better
|
|
3607 technical detail.
|
|
3608 </para>
|
|
3609
|
|
3610
|
|
3611 <sect3 id="menc-feat-x264-encoding-options-intro">
|
|
3612 <title>Introduction</title>
|
|
3613
|
|
3614 <para>
|
|
3615 This guide considers two major categories of encoding options:
|
|
3616 </para>
|
|
3617
|
|
3618 <orderedlist>
|
|
3619 <listitem><para>
|
|
3620 Options which mainly trade off encoding time vs. quality
|
|
3621 </para></listitem>
|
|
3622 <listitem><para>
|
|
3623 Options which may be useful for fulfilling various personal
|
|
3624 preferences and special requirements
|
|
3625 </para></listitem>
|
|
3626 </orderedlist>
|
|
3627
|
|
3628 <para>
|
|
3629 Ultimately, only you can decide which options are best for your
|
|
3630 purposes. The decision for the first class of options is the simplest:
|
|
3631 you only have to decide whether you think the quality differences
|
|
3632 justify the speed differences. For the second class of options,
|
|
3633 preferences may be far more subjective, and more factors may be
|
|
3634 involved. Note that some of the "personal preferences and special
|
|
3635 requirements" options can still have large impacts on speed or quality,
|
|
3636 but that is not what they are primarily useful for. A couple of the
|
|
3637 "personal preference" options may even cause changes that look better
|
|
3638 to some people, but look worse to others.
|
|
3639 </para>
|
|
3640
|
|
3641 <para>
|
|
3642 Before continuing, you need to understand that this guide uses only one
|
|
3643 quality metric: global PSNR.
|
|
3644 For a brief explanation of what PSNR is, see
|
|
3645 <ulink url="http://en.wikipedia.org/wiki/PSNR">the Wikipedia article on PSNR</ulink>.
|
|
3646 Global PSNR is the last PSNR number reported when you include
|
|
3647 the <option>psnr</option> option in <option>x264encopts</option>.
|
|
3648 Any time you read a claim about PSNR, one of the assumptions
|
|
3649 behind the claim is that equal bitrates are used.
|
|
3650 </para>
|
|
3651
|
|
3652 <para>
|
|
3653 Nearly all of this guide's comments assume you are using two pass.
|
|
3654 When comparing options, there are two major reasons for using
|
|
3655 two pass encoding.
|
|
3656 First, using two pass often gains around 1dB PSNR, which is a
|
|
3657 very big difference.
|
|
3658 Secondly, testing options by doing direct quality comparisons
|
|
3659 with one pass encodes introduces a major confounding
|
|
3660 factor: bitrate often varies significantly with each encode.
|
|
3661 It is not always easy to tell whether quality changes are due
|
|
3662 mainly to changed options, or if they mostly reflect essentially
|
|
3663 random differences in the achieved bitrate.
|
|
3664 </para>
|
|
3665 </sect3>
|
|
3666
|
|
3667
|
|
3668 <sect3 id="menc-feat-x264-encoding-options-speedvquality">
|
|
3669 <title>Options which primarily affect speed and quality</title>
|
|
3670
|
|
3671 <itemizedlist>
|
|
3672 <listitem>
|
|
3673 <para>
|
|
3674 <emphasis role="bold">subq</emphasis>:
|
|
3675 Of the options which allow you to trade off speed for quality,
|
|
3676 <option>subq</option> and <option>frameref</option> (see below) are usually
|
|
3677 by far the most important.
|
|
3678 If you are interested in tweaking either speed or quality, these
|
|
3679 are the first options you should consider.
|
|
3680 On the speed dimension, the <option>frameref</option> and
|
|
3681 <option>subq</option> options interact with each other fairly
|
|
3682 strongly.
|
|
3683 Experience shows that, with one reference frame,
|
|
3684 <option>subq=5</option> (the default setting) takes about 35% more time than
|
|
3685 <option>subq=1</option>.
|
|
3686 With 6 reference frames, the penalty grows to over 60%.
|
|
3687 <option>subq</option>'s effect on PSNR seems fairly constant
|
|
3688 regardless of the number of reference frames.
|
|
3689 Typically, <option>subq=5</option> achieves 0.2-0.5 dB higher global
|
|
3690 PSNR in comparison <option>subq=1</option>.
|
|
3691 This is usually enough to be visible.
|
|
3692 </para>
|
|
3693 <para>
|
|
3694 <option>subq=6</option> is slower and yields better quality at a reasonable
|
|
3695 cost.
|
|
3696 In comparison to <option>subq=5</option>, it usually gains 0.1-0.4 dB
|
|
3697 global PSNR with speed costs varying from 25%-100%.
|
|
3698 Unlike other levels of <option>subq</option>, the behavior of
|
|
3699 <option>subq=6</option> does not depend much on <option>frameref</option>
|
|
3700 and <option>me</option>. Instead, the effectiveness of <option>subq=6
|
|
3701 </option> depends mostly upon the number of B-frames used. In normal
|
|
3702 usage, this means <option>subq=6</option> has a large impact on both speed
|
|
3703 and quality in complex, high motion scenes, but it may not have much effect
|
|
3704 in low-motion scenes. Note that it is still recommended to always set
|
|
3705 <option>bframes</option> to something other than zero (see below).
|
|
3706 </para>
|
|
3707 <para>
|
|
3708 <option>subq=7</option> is the slowest, highest quality mode.
|
|
3709 In comparison to <option>subq=6</option>, it usually gains 0.01-0.05 dB
|
|
3710 global PSNR with speed costs varying from 15%-33%.
|
|
3711 Since the tradeoff encoding time vs. quality is quite low, you should
|
|
3712 only use it if you are after every bit saving and if encoding time is
|
|
3713 not an issue.
|
|
3714 </para>
|
|
3715 </listitem>
|
|
3716 <listitem>
|
|
3717 <para>
|
|
3718 <emphasis role="bold">frameref</emphasis>:
|
|
3719 <option>frameref</option> is set to 1 by default, but this
|
|
3720 should not be taken to imply that it is reasonable to set it to 1.
|
|
3721 Merely raising <option>frameref</option> to 2 gains around
|
|
3722 0.15dB PSNR with a 5-10% speed penalty; this seems like a good tradeoff.
|
|
3723 <option>frameref=3</option> gains around 0.25dB PSNR over
|
|
3724 <option>frameref=1</option>, which should be a visible difference.
|
|
3725 <option>frameref=3</option> is around 15% slower than
|
|
3726 <option>frameref=1</option>.
|
|
3727 Unfortunately, diminishing returns set in rapidly.
|
|
3728 <option>frameref=6</option> can be expected to gain only
|
|
3729 0.05-0.1 dB over <option>frameref=3</option> at an additional
|
|
3730 15% speed penalty.
|
|
3731 Above <option>frameref=6</option>, the quality gains are
|
|
3732 usually very small (although you should keep in mind throughout
|
|
3733 this whole discussion that it can vary quite a lot depending on your source).
|
|
3734 In a fairly typical case, <option>frameref=12</option>
|
|
3735 will improve global PSNR by a tiny 0.02dB over
|
|
3736 <option>frameref=6</option>, at a speed cost of 15%-20%.
|
|
3737 At such high <option>frameref</option> values, the only really
|
|
3738 good thing that can be said is that increasing it even further will
|
|
3739 almost certainly never <emphasis role="bold">harm</emphasis>
|
|
3740 PSNR, but the additional quality benefits are barely even
|
|
3741 measurable, let alone perceptible.
|
|
3742 </para>
|
|
3743 <note><title>Note:</title>
|
|
3744 <para>
|
|
3745 Raising <option>frameref</option> to unnecessarily high values
|
|
3746 <emphasis role="bold">can</emphasis> and
|
|
3747 <emphasis role="bold">usually does</emphasis>
|
|
3748 hurt coding efficiency if you turn CABAC off.
|
|
3749 With CABAC on (the default behavior), the possibility of setting
|
|
3750 <option>frameref</option> "too high" currently seems too remote
|
|
3751 to even worry about, and in the future, optimizations may remove
|
|
3752 the possibility altogether.
|
|
3753 </para></note>
|
|
3754 <para>
|
|
3755 If you care about speed, a reasonable compromise is to use low
|
|
3756 <option>subq</option> and <option>frameref</option> values on
|
|
3757 the first pass, and then raise them on the second pass.
|
|
3758 Typically, this has a negligible negative effect on the final
|
|
3759 quality: You will probably lose well under 0.1dB PSNR, which
|
|
3760 should be much too small of a difference to see.
|
|
3761 However, different values of <option>frameref</option> can
|
|
3762 occasionally affect frametype decision.
|
|
3763 Most likely, these are rare outlying cases, but if you want to
|
|
3764 be pretty sure, consider whether your video has either
|
|
3765 fullscreen repetitive flashing patterns or very large temporary
|
|
3766 occlusions which might force an I-frame.
|
|
3767 Adjust the first-pass <option>frameref</option> so it is large
|
|
3768 enough to contain the duration of the flashing cycle (or occlusion).
|
|
3769 For example, if the scene flashes back and forth between two images
|
|
3770 over a duration of three frames, set the first pass
|
|
3771 <option>frameref</option> to 3 or higher.
|
|
3772 This issue is probably extremely rare in live action video material,
|
|
3773 but it does sometimes come up in video game captures.
|
|
3774 </para>
|
|
3775 </listitem>
|
|
3776 <listitem>
|
|
3777 <para>
|
|
3778 <emphasis role="bold">me</emphasis>:
|
|
3779 This option is for choosing the motion estimation search method.
|
|
3780 Altering this option provides a straightforward quality-vs-speed
|
|
3781 tradeoff. <option>me=dia</option> is only a few percent faster than
|
|
3782 the default search, at a cost of under 0.1dB global PSNR. The
|
|
3783 default setting (<option>me=hex</option>) is a reasonable tradeoff
|
|
3784 between speed and quality. <option>me=umh</option> gains a little under
|
|
3785 0.1dB global PSNR, with a speed penalty that varies depending on
|
|
3786 <option>frameref</option>. At high values of
|
|
3787 <option>frameref</option> (e.g. 12 or so), <option>me=umh</option>
|
|
3788 is about 40% slower than the default <option> me=hex</option>. With
|
|
3789 <option>frameref=3</option>, the speed penalty incurred drops to
|
|
3790 25%-30%.
|
|
3791 </para>
|
|
3792 <para>
|
|
3793 <option>me=esa</option> uses an exhaustive search that is too slow for
|
|
3794 practical use.
|
|
3795 </para>
|
|
3796 </listitem>
|
|
3797 <listitem><para>
|
|
3798 <emphasis role="bold">partitions=all</emphasis>:
|
|
3799 This option enables the use of 8x4, 4x8 and 4x4 subpartitions in
|
|
3800 predicted macroblocks (in addition to the default partitions).
|
|
3801 Enabling it results in a fairly consistent
|
|
3802 10%-15% loss of speed. This option is rather useless in source
|
|
3803 containing only low motion, however in some high-motion source,
|
|
3804 particularly source with lots of small moving objects, gains of
|
|
3805 about 0.1dB can be expected.
|
|
3806 </para></listitem>
|
|
3807 <listitem>
|
|
3808 <para>
|
|
3809 <emphasis role="bold">bframes</emphasis>:
|
|
3810 If you are used to encoding with other codecs, you may have found
|
|
3811 that B-frames are not always useful.
|
|
3812 In H.264, this has changed: there are new techniques and block
|
|
3813 types that are possible in B-frames.
|
|
3814 Usually, even a naive B-frame choice algorithm can have a
|
|
3815 significant PSNR benefit.
|
|
3816 It is interesting to note that using B-frames usually speeds up
|
|
3817 the second pass somewhat, and may also speed up a single
|
|
3818 pass encode if adaptive B-frame decision is turned off.
|
|
3819 </para>
|
|
3820 <para>
|
|
3821 With adaptive B-frame decision turned off
|
|
3822 (<option>x264encopts</option>'s <option>nob_adapt</option>),
|
|
3823 the optimal value for this setting is usually no more than
|
|
3824 <option>bframes=1</option>, or else high-motion scenes can suffer.
|
|
3825 With adaptive B-frame decision on (the default behavior), it is
|
|
3826 safe to use higher values; the encoder will reduce the use of
|
|
3827 B-frames in scenes where they would hurt compression.
|
|
3828 The encoder rarely chooses to use more than 3 or 4 B-frames;
|
|
3829 setting this option any higher will have little effect.
|
|
3830 </para>
|
|
3831 </listitem>
|
|
3832 <listitem>
|
|
3833 <para>
|
|
3834 <emphasis role="bold">b_adapt</emphasis>:
|
|
3835 Note: This is on by default.
|
|
3836 </para>
|
|
3837 <para>
|
|
3838 With this option enabled, the encoder will use a reasonably fast
|
|
3839 decision process to reduce the number of B-frames used in scenes that
|
|
3840 might not benefit from them as much.
|
|
3841 You can use <option>b_bias</option> to tweak how B-frame-happy
|
|
3842 the encoder is.
|
|
3843 The speed penalty of adaptive B-frames is currently rather modest,
|
|
3844 but so is the potential quality gain.
|
|
3845 It usually does not hurt, however.
|
|
3846 Note that this only affects speed and frametype decision on the
|
|
3847 first pass.
|
|
3848 <option>b_adapt</option> and <option>b_bias</option> have no
|
|
3849 effect on subsequent passes.
|
|
3850 </para>
|
|
3851 </listitem>
|
|
3852 <listitem><para>
|
|
3853 <emphasis role="bold">b_pyramid</emphasis>:
|
|
3854 You might as well enable this option if you are using >=2 B-frames;
|
|
3855 as the man page says, you get a little quality improvement at no
|
|
3856 speed cost.
|
|
3857 Note that these videos cannot be read by libavcodec-based decoders
|
|
3858 older than about March 5, 2005.
|
|
3859 </para></listitem>
|
|
3860 <listitem>
|
|
3861 <para>
|
|
3862 <emphasis role="bold">weight_b</emphasis>:
|
|
3863 In typical cases, there is not much gain with this option.
|
|
3864 However, in crossfades or fade-to-black scenes, weighted
|
|
3865 prediction gives rather large bitrate savings.
|
|
3866 In MPEG-4 ASP, a fade-to-black is usually best coded as a series
|
|
3867 of expensive I-frames; using weighted prediction in B-frames
|
|
3868 makes it possible to turn at least some of these into much smaller
|
|
3869 B-frames.
|
|
3870 Encoding time cost is minimal, as no extra decisions need to be made.
|
|
3871 Also, contrary to what some people seem to guess, the decoder
|
|
3872 CPU requirements are not much affected by weighted prediction,
|
|
3873 all else being equal.
|
|
3874 </para>
|
|
3875 <para>
|
|
3876 Unfortunately, the current adaptive B-frame decision algorithm
|
|
3877 has a strong tendency to avoid B-frames during fades.
|
|
3878 Until this changes, it may be a good idea to add
|
|
3879 <option>nob_adapt</option> to your x264encopts, if you expect
|
|
3880 fades to have a large effect in your particular video
|
|
3881 clip.
|
|
3882 </para>
|
|
3883 </listitem>
|
|
3884 <listitem id="menc-feat-x264-encoding-options-speedvquality-threads">
|
|
3885 <para>
|
|
3886 <emphasis role="bold">threads</emphasis>:
|
|
3887 This option allows to spawn threads to encode in parallel on multiple CPUs.
|
|
3888 You can manually select the number of threads to be created or, better, set
|
|
3889 <option>threads=auto</option> and let
|
|
3890 <systemitem class="library">x264</systemitem> detect how many CPUs are
|
|
3891 available and pick an appropriate number of threads.
|
|
3892 If you have a multi-processor machine, you should really consider using it
|
|
3893 as it can to increase encoding speed linearly with the number of CPU cores
|
|
3894 (about 94% per CPU core), with very little quality reduction (about 0.005dB
|
|
3895 for dual processor, about 0.01dB for a quad processor machine).
|
|
3896 </para>
|
|
3897 </listitem>
|
|
3898 </itemizedlist>
|
|
3899 </sect3>
|
|
3900
|
|
3901
|
|
3902 <sect3 id="menc-feat-x264-encoding-options-misc-preferences">
|
|
3903 <title>Options pertaining to miscellaneous preferences</title>
|
|
3904
|
|
3905 <itemizedlist>
|
|
3906 <listitem>
|
|
3907 <para>
|
|
3908 <emphasis role="bold">Two pass encoding</emphasis>:
|
|
3909 Above, it was suggested to always use two pass encoding, but there
|
|
3910 are still reasons for not using it. For instance, if you are capturing
|
|
3911 live TV and encoding in realtime, you are forced to use single-pass.
|
|
3912 Also, one pass is obviously faster than two passes; if you use the
|
|
3913 exact same set of options on both passes, two pass encoding is almost
|
|
3914 twice as slow.
|
|
3915 </para>
|
|
3916 <para>
|
|
3917 Still, there are very good reasons for using two pass encoding. For
|
|
3918 one thing, single pass ratecontrol is not psychic, and it often makes
|
|
3919 unreasonable choices because it cannot see the big picture. For example,
|
|
3920 suppose you have a two minute long video consisting of two distinct
|
|
3921 halves. The first half is a very high-motion scene lasting 60 seconds
|
|
3922 which, in isolation, requires about 2500kbps in order to look decent.
|
|
3923 Immediately following it is a much less demanding 60-second scene
|
|
3924 that looks good at 300kbps. Suppose you ask for 1400kbps on the theory
|
|
3925 that this is enough to accomodate both scenes. Single pass ratecontrol
|
|
3926 will make a couple of "mistakes" in such a case. First of all, it
|
|
3927 will target 1400kbps in both segments. The first segment may end up
|
|
3928 heavily overquantized, causing it to look unacceptably and unreasonably
|
|
3929 blocky. The second segment will be heavily underquantized; it may look
|
|
3930 perfect, but the bitrate cost of that perfection will be completely
|
|
3931 unreasonable. What is even harder to avoid is the problem at the
|
|
3932 transition between the two scenes. The first seconds of the low motion
|
|
3933 half will be hugely over-quantized, because the ratecontrol is still
|
|
3934 expecting the kind of bitrate requirements it met in the first half
|
|
3935 of the video. This "error period" of heavily over-quantized low motion
|
|
3936 will look jarringly bad, and will actually use less than the 300kbps
|
|
3937 it would have taken to make it look decent. There are ways to
|
|
3938 mitigate the pitfalls of single-pass encoding, but they may tend to
|
|
3939 increase bitrate misprediction.
|
|
3940 </para>
|
|
3941 <para>
|
|
3942 Multipass ratecontrol can offer huge advantages over a single pass.
|
|
3943 Using the statistics gathered from the first pass encode, the encoder
|
|
3944 can estimate, with reasonable accuracy, the "cost" (in bits) of
|
|
3945 encoding any given frame, at any given quantizer. This allows for
|
|
3946 a much more rational, better planned allocation of bits between the
|
|
3947 expensive (high-motion) and cheap (low-motion) scenes. See
|
|
3948 <option>qcomp</option> below for some ideas on how to tweak this
|
|
3949 allocation to your liking.
|
|
3950 </para>
|
|
3951 <para>
|
|
3952 Moreover, two passes need not take twice as long as one pass. You can
|
|
3953 tweak the options in the first pass for higher speed and lower quality.
|
|
3954 If you choose your options well, you can get a very fast first pass.
|
|
3955 The resulting quality in the second pass will be slightly lower because size
|
|
3956 prediction is less accurate, but the quality difference is normally much
|
|
3957 too small to be visible. Try, for example, adding
|
|
3958 <option>subq=1:frameref=1</option> to the first pass
|
|
3959 <option>x264encopts</option>. Then, on the second pass, use slower,
|
|
3960 higher-quality options:
|
|
3961 <option>subq=6:frameref=15:partitions=all:me=umh</option>
|
|
3962 </para>
|
|
3963 </listitem>
|
|
3964 <listitem><para>
|
|
3965 <emphasis role="bold">Three pass encoding</emphasis>?
|
|
3966 x264 offers the ability to make an arbitrary number of consecutive
|
|
3967 passes. If you specify <option>pass=1</option> on the first pass,
|
|
3968 then use <option>pass=3</option> on a subsequent pass, the subsequent
|
|
3969 pass will both read the statistics from the previous pass, and write
|
|
3970 its own statistics. An additional pass following this one will have
|
|
3971 a very good base from which to make highly accurate predictions of
|
|
3972 framesizes at a chosen quantizer. In practice, the overall quality
|
|
3973 gain from this is usually close to zero, and quite possibly a third
|
|
3974 pass will result in slightly worse global PSNR than the pass before
|
|
3975 it. In typical usage, three passes help if you get either bad bitrate
|
|
3976 prediction or bad looking scene transitions when using only two passes.
|
|
3977 This is somewhat likely to happen on extremely short clips. There are
|
|
3978 also a few special cases in which three (or more) passes are handy
|
|
3979 for advanced users, but for brevity, this guide omits discussing those
|
|
3980 special cases.
|
|
3981 </para></listitem>
|
|
3982 <listitem><para>
|
|
3983 <emphasis role="bold">qcomp</emphasis>:
|
|
3984 <option>qcomp</option> trades off the number of bits allocated
|
|
3985 to "expensive" high-motion versus "cheap" low-motion frames. At
|
|
3986 one extreme, <option>qcomp=0</option> aims for true constant
|
|
3987 bitrate. Typically this would make high-motion scenes look completely
|
|
3988 awful, while low-motion scenes would probably look absolutely
|
|
3989 perfect, but would also use many times more bitrate than they
|
|
3990 would need in order to look merely excellent. At the other extreme,
|
|
3991 <option>qcomp=1</option> achieves nearly constant quantization parameter
|
|
3992 (QP). Constant QP does not look bad, but most people think it is more
|
|
3993 reasonable to shave some bitrate off of the extremely expensive scenes
|
|
3994 (where the loss of quality is not as noticeable) and reallocate it to
|
|
3995 the scenes that are easier to encode at excellent quality.
|
|
3996 <option>qcomp</option> is set to 0.6 by default, which may be slightly
|
|
3997 low for many peoples' taste (0.7-0.8 are also commonly used).
|
|
3998 </para></listitem>
|
|
3999 <listitem><para>
|
|
4000 <emphasis role="bold">keyint</emphasis>:
|
|
4001 <option>keyint</option> is solely for trading off file seekability against
|
|
4002 coding efficiency. By default, <option>keyint</option> is set to 250. In
|
|
4003 25fps material, this guarantees the ability to seek to within 10 seconds
|
|
4004 precision. If you think it would be important and useful to be able to
|
|
4005 seek within 5 seconds of precision, set <option>keyint=125</option>;
|
|
4006 this will hurt quality/bitrate slightly. If you care only about quality
|
|
4007 and not about seekability, you can set it to much higher values
|
|
4008 (understanding that there are diminishing returns which may become
|
|
4009 vanishingly low, or even zero). The video stream will still have seekable
|
|
4010 points as long as there are some scene changes.
|
|
4011 </para></listitem>
|
|
4012 <listitem>
|
|
4013 <para>
|
|
4014 <emphasis role="bold">deblock</emphasis>:
|
|
4015 This topic is going to be a bit controversial.
|
|
4016 </para>
|
|
4017 <para>
|
|
4018 H.264 defines a simple deblocking procedure on I-blocks that uses
|
|
4019 pre-set strengths and thresholds depending on the QP of the block
|
|
4020 in question.
|
|
4021 By default, high QP blocks are filtered heavily, and low QP blocks
|
|
4022 are not deblocked at all.
|
|
4023 The pre-set strengths defined by the standard are well-chosen and
|
|
4024 the odds are very good that they are PSNR-optimal for whatever
|
|
4025 video you are trying to encode.
|
|
4026 The <option>deblock</option> allow you to specify offsets to the preset
|
|
4027 deblocking thresholds.
|
|
4028 </para>
|
|
4029 <para>
|
|
4030 Many people seem to think it is a good idea to lower the deblocking
|
|
4031 filter strength by large amounts (say, -3).
|
|
4032 This is however almost never a good idea, and in most cases,
|
|
4033 people who are doing this do not understand very well how
|
|
4034 deblocking works by default.
|
|
4035 </para>
|
|
4036 <para>
|
|
4037 The first and most important thing to know about the in-loop
|
|
4038 deblocking filter is that the default thresholds are almost always
|
|
4039 PSNR-optimal.
|
|
4040 In the rare cases that they are not optimal, the ideal offset is
|
|
4041 plus or minus 1.
|
|
4042 Adjusting deblocking parameters by a larger amount is almost
|
|
4043 guaranteed to hurt PSNR.
|
|
4044 Strengthening the filter will smear more details; weakening the
|
|
4045 filter will increase the appearance of blockiness.
|
|
4046 </para>
|
|
4047 <para>
|
|
4048 It is definitely a bad idea to lower the deblocking thresholds if
|
|
4049 your source is mainly low in spacial complexity (i.e., not a lot
|
|
4050 of detail or noise).
|
|
4051 The in-loop filter does a rather excellent job of concealing
|
|
4052 the artifacts that occur.
|
|
4053 If the source is high in spacial complexity, however, artifacts
|
|
4054 are less noticeable.
|
|
4055 This is because the ringing tends to look like detail or noise.
|
|
4056 Human visual perception easily notices when detail is removed,
|
|
4057 but it does not so easily notice when the noise is wrongly
|
|
4058 represented.
|
|
4059 When it comes to subjective quality, noise and detail are somewhat
|
|
4060 interchangeable.
|
|
4061 By lowering the deblocking filter strength, you are most likely
|
|
4062 increasing error by adding ringing artifacts, but the eye does
|
|
4063 not notice because it confuses the artifacts with detail.
|
|
4064 </para>
|
|
4065 <para>
|
|
4066 This <emphasis role="bold">still</emphasis> does not justify
|
|
4067 lowering the deblocking filter strength, however.
|
|
4068 You can generally get better quality noise from postprocessing.
|
|
4069 If your H.264 encodes look too blurry or smeared, try playing with
|
|
4070 <option>-vf noise</option> when you play your encoded movie.
|
|
4071 <option>-vf noise=8a:4a</option> should conceal most mild
|
|
4072 artifacting.
|
|
4073 It will almost certainly look better than the results you
|
|
4074 would have gotten just by fiddling with the deblocking filter.
|
|
4075 </para>
|
|
4076 </listitem>
|
|
4077 </itemizedlist>
|
|
4078 </sect3>
|
|
4079 </sect2>
|
|
4080
|
|
4081 <!-- ********** -->
|
|
4082
|
|
4083 <sect2 id="menc-feat-x264-example-settings">
|
|
4084 <title>Encoding setting examples</title>
|
|
4085
|
|
4086 <para>
|
|
4087 The following settings are examples of different encoding
|
|
4088 option combinations that affect the speed vs quality tradeoff
|
|
4089 at the same target bitrate.
|
|
4090 </para>
|
|
4091
|
|
4092 <para>
|
|
4093 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
4094 video sample, the target bitrate was 900kbps, and the machine was an
|
|
4095 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
4096 Each encoding setting features the measured encoding speed (in
|
|
4097 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
4098 high quality" setting.
|
|
4099 Please understand that depending on your source, your machine type
|
|
4100 and development advancements, you may get very different results.
|
|
4101 </para>
|
|
4102
|
|
4103 <informaltable frame="all">
|
|
4104 <tgroup cols="4">
|
|
4105 <thead>
|
|
4106 <row>
|
|
4107 <entry>Description</entry>
|
|
4108 <entry>Encoding options</entry>
|
|
4109 <entry>speed (in fps)</entry>
|
|
4110 <entry>Relative PSNR loss (in dB)</entry>
|
|
4111 </row>
|
|
4112 </thead>
|
|
4113 <tbody>
|
|
4114 <row>
|
|
4115 <entry>Very high quality</entry>
|
|
4116 <entry><option>subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4117 <entry>6fps</entry>
|
|
4118 <entry>0dB</entry>
|
|
4119 </row>
|
|
4120 <row>
|
|
4121 <entry>High quality</entry>
|
|
4122 <entry><option>subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4123 <entry>13fps</entry>
|
|
4124 <entry>-0.89dB</entry>
|
|
4125 </row>
|
|
4126 <row>
|
|
4127 <entry>Fast</entry>
|
|
4128 <entry><option>subq=4:bframes=2:b_pyramid:weight_b</option></entry>
|
|
4129 <entry>17fps</entry>
|
|
4130 <entry>-1.48dB</entry>
|
|
4131 </row>
|
|
4132 </tbody>
|
|
4133 </tgroup>
|
|
4134 </informaltable>
|
|
4135 </sect2>
|
|
4136 </sect1>
|
|
4137
|
|
4138
|
|
4139 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4140
|
|
4141
|
|
4142 <sect1 id="menc-feat-video-for-windows">
|
|
4143 <title>
|
|
4144 Encoding with the <systemitem class="library">Video For Windows</systemitem>
|
|
4145 codec family
|
|
4146 </title>
|
|
4147
|
|
4148 <para>
|
|
4149 Video for Windows provides simple encoding by means of binary video codecs.
|
|
4150 You can encode with the following codecs (if you have more, please tell us!)
|
|
4151 </para>
|
|
4152
|
|
4153 <para>
|
|
4154 Note that support for this is very experimental and some codecs may not work
|
|
4155 correctly. Some codecs will only work in certain colorspaces, try
|
|
4156 <option>-vf format=bgr24</option> and <option>-vf format=yuy2</option>
|
|
4157 if a codec fails or gives wrong output.
|
|
4158 </para>
|
|
4159
|
|
4160 <!-- ********** -->
|
|
4161
|
|
4162 <sect2 id="menc-feat-enc-vfw-video-codecs">
|
|
4163 <title>Video for Windows supported codecs</title>
|
|
4164
|
|
4165 <para>
|
|
4166 <informaltable frame="all">
|
|
4167 <tgroup cols="4">
|
|
4168 <thead>
|
|
4169 <row>
|
|
4170 <entry>Video codec file name</entry>
|
|
4171 <entry>Description (FourCC)</entry>
|
|
4172 <entry>md5sum</entry>
|
|
4173 <entry>Comment</entry>
|
|
4174 </row>
|
|
4175 </thead>
|
|
4176 <tbody>
|
|
4177 <row>
|
|
4178 <entry>aslcodec_vfw.dll</entry>
|
|
4179 <entry>Alparysoft lossless codec vfw (ASLC)</entry>
|
|
4180 <entry>608af234a6ea4d90cdc7246af5f3f29a</entry>
|
|
4181 <entry></entry>
|
|
4182 </row>
|
|
4183 <row>
|
|
4184 <entry>avimszh.dll</entry>
|
|
4185 <entry>AVImszh (MSZH)</entry>
|
|
4186 <entry>253118fe1eedea04a95ed6e5f4c28878</entry>
|
|
4187 <entry>needs <option>-vf format</option></entry>
|
|
4188 </row>
|
|
4189 <row>
|
|
4190 <entry>avizlib.dll</entry>
|
|
4191 <entry>AVIzlib (ZLIB)</entry>
|
|
4192 <entry>2f1cc76bbcf6d77d40d0e23392fa8eda</entry>
|
|
4193 <entry></entry>
|
|
4194 </row>
|
|
4195 <row>
|
|
4196 <entry>divx.dll</entry>
|
|
4197 <entry>DivX4Windows-VFW</entry>
|
|
4198 <entry>acf35b2fc004a89c829531555d73f1e6</entry>
|
|
4199 <entry></entry>
|
|
4200 </row>
|
|
4201 <row>
|
|
4202 <entry>huffyuv.dll</entry>
|
|
4203 <entry>HuffYUV (lossless) (HFYU)</entry>
|
|
4204 <entry>b74695b50230be4a6ef2c4293a58ac3b</entry>
|
|
4205 <entry></entry>
|
|
4206 </row>
|
|
4207 <row>
|
|
4208 <entry>iccvid.dll</entry>
|
|
4209 <entry>Cinepak Video (cvid)</entry>
|
|
4210 <entry>cb3b7ee47ba7dbb3d23d34e274895133</entry>
|
|
4211 <entry></entry>
|
|
4212 </row>
|
|
4213 <row>
|
|
4214 <entry>icmw_32.dll</entry>
|
|
4215 <entry>Motion Wavelets (MWV1)</entry>
|
|
4216 <entry>c9618a8fc73ce219ba918e3e09e227f2</entry>
|
|
4217 <entry></entry>
|
|
4218 </row>
|
|
4219 <row>
|
|
4220 <entry>jp2avi.dll</entry>
|
|
4221 <entry>ImagePower MJPEG2000 (IPJ2)</entry>
|
|
4222 <entry>d860a11766da0d0ea064672c6833768b</entry>
|
|
4223 <entry><option>-vf flip</option></entry>
|
|
4224 </row>
|
|
4225 <row>
|
|
4226 <entry>m3jp2k32.dll</entry>
|
|
4227 <entry>Morgan MJPEG2000 (MJ2C)</entry>
|
|
4228 <entry>f3c174edcbaef7cb947d6357cdfde7ff</entry>
|
|
4229 <entry></entry>
|
|
4230 </row>
|
|
4231 <row>
|
|
4232 <entry>m3jpeg32.dll</entry>
|
|
4233 <entry>Morgan Motion JPEG Codec (MJPG)</entry>
|
|
4234 <entry>1cd13fff5960aa2aae43790242c323b1</entry>
|
|
4235 <entry></entry>
|
|
4236 </row>
|
|
4237 <row>
|
|
4238 <entry>mpg4c32.dll</entry>
|
|
4239 <entry>Microsoft MPEG-4 v1/v2</entry>
|
|
4240 <entry>b5791ea23f33010d37ab8314681f1256</entry>
|
|
4241 <entry></entry>
|
|
4242 </row>
|
|
4243 <row>
|
|
4244 <entry>tsccvid.dll</entry>
|
|
4245 <entry>TechSmith Camtasia Screen Codec (TSCC)</entry>
|
|
4246 <entry>8230d8560c41d444f249802a2700d1d5</entry>
|
|
4247 <entry>shareware error on windows</entry>
|
|
4248 </row>
|
|
4249 <row>
|
|
4250 <entry>vp31vfw.dll</entry>
|
|
4251 <entry>On2 Open Source VP3 Codec (VP31)</entry>
|
|
4252 <entry>845f3590ea489e2e45e876ab107ee7d2</entry>
|
|
4253 <entry></entry>
|
|
4254 </row>
|
|
4255 <row>
|
|
4256 <entry>vp4vfw.dll</entry>
|
|
4257 <entry>On2 VP4 Personal Codec (VP40)</entry>
|
|
4258 <entry>fc5480a482ccc594c2898dcc4188b58f</entry>
|
|
4259 <entry></entry>
|
|
4260 </row>
|
|
4261 <row>
|
|
4262 <entry>vp6vfw.dll</entry>
|
|
4263 <entry>On2 VP6 Personal Codec (VP60)</entry>
|
|
4264 <entry>04d635a364243013898fd09484f913fb</entry>
|
|
4265 <entry></entry>
|
|
4266 </row>
|
|
4267 <row>
|
|
4268 <entry>vp7vfw.dll</entry>
|
|
4269 <entry>On2 VP7 Personal Codec (VP70)</entry>
|
|
4270 <entry>cb4cc3d4ea7c94a35f1d81c3d750bc8d</entry>
|
|
4271 <entry>wrong FourCC?</entry>
|
|
4272 </row>
|
|
4273 <row>
|
|
4274 <entry>ViVD2.dll</entry>
|
|
4275 <entry>SoftMedia ViVD V2 codec VfW (GXVE)</entry>
|
|
4276 <entry>a7b4bf5cac630bb9262c3f80d8a773a1</entry>
|
|
4277 <entry></entry>
|
|
4278 </row>
|
|
4279 <row>
|
|
4280 <entry>msulvc06.DLL</entry>
|
|
4281 <entry>MSU Lossless codec (MSUD)</entry>
|
|
4282 <entry>294bf9288f2f127bb86f00bfcc9ccdda</entry>
|
|
4283 <entry>
|
|
4284 Decodable by <application>Window Media Player</application>,
|
|
4285 not <application>MPlayer</application> (yet).
|
|
4286 </entry>
|
|
4287 </row>
|
|
4288 <row>
|
|
4289 <entry>camcodec.dll</entry>
|
|
4290 <entry>CamStudio lossless video codec (CSCD)</entry>
|
|
4291 <entry>0efe97ce08bb0e40162ab15ef3b45615</entry>
|
|
4292 <entry>sf.net/projects/camstudio</entry>
|
|
4293 </row>
|
|
4294 </tbody>
|
|
4295 </tgroup>
|
|
4296 </informaltable>
|
|
4297
|
|
4298 The first column contains the codec names that should be passed after the
|
|
4299 <literal>codec</literal> parameter,
|
|
4300 like: <option>-xvfwopts codec=divx.dll</option>
|
|
4301 The FourCC code used by each codec is given in the parentheses.
|
|
4302 </para>
|
|
4303
|
|
4304 <informalexample>
|
|
4305 <para>
|
|
4306 An example to convert an ISO DVD trailer to a VP6 flash video file
|
|
4307 using compdata bitrate settings:
|
|
4308 <screen>
|
|
4309 mencoder -dvd-device <replaceable>zeiram.iso</replaceable> dvd://7 -o <replaceable>trailer.flv</replaceable> \
|
|
4310 -ovc vfw -xvfwopts codec=vp6vfw.dll:compdata=onepass.mcf -oac mp3lame \
|
|
4311 -lameopts cbr:br=64 -af lavcresample=22050 -vf yadif,scale=320:240,flip \
|
|
4312 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
|
|
4313 </screen>
|
|
4314 </para>
|
|
4315 </informalexample>
|
|
4316 </sect2>
|
|
4317
|
|
4318 <sect2 id="menc-feat-video-for-windows-bitrate-settings">
|
|
4319 <title>Using vfw2menc to create a codec settings file.</title>
|
|
4320
|
|
4321 <para>
|
|
4322 To encode with the Video for Windows codecs, you will need to set bitrate
|
|
4323 and other options. This is known to work on x86 on both *NIX and Windows.
|
|
4324 </para>
|
|
4325 <para>
|
|
4326 First you must build the <application>vfw2menc</application> program.
|
|
4327 It is located in the <filename class="directory">TOOLS</filename> subdirectory
|
|
4328 of the MPlayer source tree.
|
|
4329 To build on Linux, this can be done using <application>Wine</application>:
|
|
4330 <screen>winegcc vfw2menc.c -o vfw2menc -lwinmm -lole32</screen>
|
|
4331
|
|
4332 To build on Windows in <application>MinGW</application> or
|
|
4333 <application>Cygwin</application> use:
|
|
4334 <screen>gcc vfw2menc.c -o vfw2menc.exe -lwinmm -lole32</screen>
|
|
4335
|
|
4336 To build on <application>MSVC</application> you will need getopt.
|
|
4337 Getopt can be found in the original <application>vfw2menc</application>
|
|
4338 archive available at:
|
|
4339 The <ulink url="http://oss.netfarm.it/mplayer-win32.php">MPlayer on win32</ulink> project.
|
|
4340 </para>
|
|
4341 <informalexample>
|
|
4342 <para>
|
|
4343 Below is an example with the VP6 codec.
|
|
4344 <screen>
|
|
4345 vfw2menc -f VP62 -d vp6vfw.dll -s firstpass.mcf
|
|
4346 </screen>
|
|
4347 This will open the VP6 codec dialog window.
|
|
4348 Repeat this step for the second pass
|
|
4349 and use <option>-s <replaceable>secondpass.mcf</replaceable></option>.
|
|
4350 </para>
|
|
4351 </informalexample>
|
|
4352 <para>
|
|
4353 Windows users can use
|
|
4354 <option>-xvfwopts codec=vp6vfw.dll:compdata=dialog</option> to have
|
|
4355 the codec dialog display before encoding starts.
|
|
4356 </para>
|
|
4357 </sect2>
|
|
4358 </sect1>
|
|
4359
|
|
4360
|
|
4361 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4362
|
|
4363
|
|
4364 <sect1 id="menc-feat-quicktime-7">
|
|
4365 <title>Using <application>MEncoder</application> to create
|
|
4366 <application>QuickTime</application>-compatible files</title>
|
|
4367
|
|
4368
|
|
4369 <sect2 id="menc-feat-quicktime-7-why-use-it">
|
|
4370 <title>Why would one want to produce <application>QuickTime</application>-compatible Files?</title>
|
|
4371
|
|
4372 <para>
|
|
4373 There are several reasons why producing
|
|
4374 <application>QuickTime</application>-compatible files can be desirable.
|
|
4375 </para>
|
|
4376 <itemizedlist>
|
|
4377 <listitem><para>
|
|
4378 You want any computer illiterate to be able to watch your encode on
|
|
4379 any major platform (Windows, Mac OS X, Unices …).
|
|
4380 </para></listitem>
|
|
4381 <listitem><para>
|
|
4382 <application>QuickTime</application> is able to take advantage of more
|
|
4383 hardware and software acceleration features of Mac OS X than
|
|
4384 platform-independent players like <application>MPlayer</application>
|
|
4385 or <application>VLC</application>.
|
|
4386 That means that your encodes have a chance to be played smoothly by older
|
|
4387 G4-powered machines.
|
|
4388 </para></listitem>
|
|
4389 <listitem><para>
|
|
4390 <application>QuickTime</application> 7 supports the next-generation codec H.264,
|
|
4391 which yields significantly better picture quality than previous codec
|
|
4392 generations (MPEG-2, MPEG-4 …).
|
|
4393 </para></listitem>
|
|
4394 </itemizedlist>
|
|
4395 </sect2>
|
|
4396
|
|
4397 <sect2 id="menc-feat-quicktime-7-constraints">
|
|
4398 <title><application>QuickTime</application> 7 limitations</title>
|
|
4399
|
|
4400 <para>
|
|
4401 <application>QuickTime</application> 7 supports H.264 video and AAC audio,
|
|
4402 but it does not support them muxed in the AVI container format.
|
|
4403 However, you can use <application>MEncoder</application> to encode
|
|
4404 the video and audio, and then use an external program such as
|
|
4405 <application>mp4creator</application> (part of the
|
|
4406 <ulink url="http://mpeg4ip.sourceforge.net/">MPEG4IP suite</ulink>)
|
|
4407 to remux the video and audio tracks into an MP4 container.
|
|
4408 </para>
|
|
4409
|
|
4410 <para>
|
|
4411 <application>QuickTime</application>'s support for H.264 is limited,
|
|
4412 so you will need to drop some advanced features.
|
|
4413 If you encode your video with features that
|
|
4414 <application>QuickTime</application> 7 does not support,
|
|
4415 <application>QuickTime</application>-based players will show you a pretty
|
|
4416 white screen instead of your expected video.
|
|
4417 </para>
|
|
4418
|
|
4419 <itemizedlist>
|
|
4420 <listitem><para>
|
|
4421 <emphasis role="bold">B-frames</emphasis>:
|
|
4422 <application>QuickTime</application> 7 supports a maximum of 1 B-frame, i.e.
|
|
4423 <option>-x264encopts bframes=1</option>. This means that
|
|
4424 <option>b_pyramid</option> and <option>weight_b</option> will have no
|
|
4425 effect, since they require <option>bframes</option> to be greater than 1.
|
|
4426 </para></listitem>
|
|
4427 <listitem><para>
|
|
4428 <emphasis role="bold">Macroblocks</emphasis>:
|
|
4429 <application>QuickTime</application> 7 does not support 8x8 DCT macroblocks.
|
|
4430 This option (<option>8x8dct</option>) is off by default, so just be sure
|
|
4431 not to explicitly enable it. This also means that the <option>i8x8</option>
|
|
4432 option will have no effect, since it requires <option>8x8dct</option>.
|
|
4433 </para></listitem>
|
|
4434 <listitem><para>
|
|
4435 <emphasis role="bold">Aspect ratio</emphasis>:
|
|
4436 <application>QuickTime</application> 7 does not support SAR (sample
|
|
4437 aspect ratio) information in MPEG-4 files; it assumes that SAR=1. Read
|
|
4438 <link linkend="menc-feat-quicktime-7-scale">the section on scaling</link>
|
|
4439 for a workaround.
|
|
4440 </para></listitem>
|
|
4441 </itemizedlist>
|
|
4442
|
|
4443 </sect2>
|
|
4444
|
|
4445 <sect2 id="menc-feat-quicktime-7-crop">
|
|
4446 <title>Cropping</title>
|
|
4447 <para>
|
|
4448 Suppose you want to rip your freshly bought copy of "The Chronicles of
|
|
4449 Narnia". Your DVD is region 1,
|
|
4450 which means it is NTSC. The example below would still apply to PAL,
|
|
4451 except you would omit <option>-ofps 24000/1001</option> and use slightly
|
|
4452 different <option>crop</option> and <option>scale</option> dimensions.
|
|
4453 </para>
|
|
4454
|
|
4455 <para>
|
|
4456 After running <option>mplayer dvd://1</option>, you follow the process
|
|
4457 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
4458 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
4459 24000/1001 fps progressive video. This simplifies the process somewhat,
|
|
4460 since you do not need to use an inverse telecine filter such as
|
|
4461 <option>pullup</option> or a deinterlacing filter such as
|
|
4462 <option>yadif</option>.
|
|
4463 </para>
|
|
4464
|
|
4465 <para>
|
|
4466 Next, you need to crop out the black bars from the top and bottom of the
|
|
4467 video, as detailed in <link linkend="menc-feat-dvd-mpeg4-example-crop">this</link>
|
|
4468 previous section.
|
|
4469 </para>
|
|
4470
|
|
4471 </sect2>
|
|
4472
|
|
4473 <sect2 id="menc-feat-quicktime-7-scale">
|
|
4474 <title>Scaling</title>
|
|
4475
|
|
4476 <para>
|
|
4477 The next step is truly heartbreaking.
|
|
4478 <application>QuickTime</application> 7 does not support MPEG-4 videos
|
|
4479 with a sample aspect ratio other than 1, so you will need to upscale
|
|
4480 (which wastes a lot of disk space) or downscale (which loses some
|
|
4481 details of the source) the video to square pixels.
|
|
4482 Either way you do it, this is highly inefficient, but simply cannot
|
|
4483 be avoided if you want your video to be playable by
|
|
4484 <application>QuickTime</application> 7.
|
|
4485 <application>MEncoder</application> can apply the appropriate upscaling
|
|
4486 or downscaling by specifying respectively <option>-vf scale=-10:-1</option>
|
|
4487 or <option>-vf scale=-1:-10</option>.
|
|
4488 This will scale your video to the correct width for the cropped height,
|
|
4489 rounded to the closest multiple of 16 for optimal compression.
|
|
4490 Remember that if you are cropping, you should crop first, then scale:
|
|
4491
|
|
4492 <screen>-vf crop=720:352:0:62,scale=-10:-1</screen>
|
|
4493 </para>
|
|
4494
|
|
4495 </sect2>
|
|
4496
|
|
4497 <sect2 id="menc-feat-quicktime-7-avsync">
|
|
4498 <title>A/V sync</title>
|
|
4499
|
|
4500 <para>
|
|
4501 Because you will be remuxing into a different container, you should
|
|
4502 always use the <option>harddup</option> option to ensure that duplicated
|
|
4503 frames are actually duplicated in the video output. Without this option,
|
|
4504 <application>MEncoder</application> will simply put a marker in the video
|
|
4505 stream that a frame was duplicated, and rely on the client software to
|
|
4506 show the same frame twice. Unfortunately, this "soft duplication" does
|
|
4507 not survive remuxing, so the audio would slowly lose sync with the video.
|
|
4508 </para>
|
|
4509
|
|
4510 <para>
|
|
4511 The final filter chain looks like this:
|
|
4512 <screen>-vf crop=720:352:0:62,scale=-10:-1,harddup</screen>
|
|
4513 </para>
|
|
4514
|
|
4515 </sect2>
|
|
4516
|
|
4517 <sect2 id="menc-feat-quicktime-7-bitrate">
|
|
4518 <title>Bitrate</title>
|
|
4519
|
|
4520 <para>
|
|
4521 As always, the selection of bitrate is a matter of the technical properties
|
|
4522 of the source, as explained
|
|
4523 <link linkend="menc-feat-dvd-mpeg4-resolution-bitrate">here</link>, as
|
|
4524 well as a matter of taste.
|
|
4525 This movie has a fair bit of action and lots of detail, but H.264 video
|
|
4526 looks good at much lower bitrates than XviD or other MPEG-4 codecs.
|
|
4527 After much experimentation, the author of this guide chose to encode
|
|
4528 this movie at 900kbps, and thought that it looked very good.
|
|
4529 You may decrease bitrate if you need to save more space, or increase
|
|
4530 it if you need to improve quality.
|
|
4531 </para>
|
|
4532
|
|
4533 </sect2>
|
|
4534
|
|
4535 <sect2 id="menc-feat-quicktime-7-example">
|
|
4536 <title>Encoding example</title>
|
|
4537
|
|
4538 <para>
|
|
4539 You are now ready to encode the video. Since you care about
|
|
4540 quality, of course you will be doing a two-pass encode. To shave off
|
|
4541 some encoding time, you can specify the <option>turbo</option> option
|
|
4542 on the first pass; this reduces <option>subq</option> and
|
|
4543 <option>frameref</option> to 1. To save some disk space, you can
|
|
4544 use the <option>ss</option> option to strip off the first few seconds
|
|
4545 of the video. (I found that this particular movie has 32 seconds of
|
|
4546 credits and logos.) <option>bframes</option> can be 0 or 1.
|
|
4547 The other options are documented in <link
|
|
4548 linkend="menc-feat-x264-encoding-options-speedvquality">Encoding with
|
|
4549 the <systemitem class="library">x264</systemitem> codec</link> and
|
|
4550 the man page.
|
|
4551
|
|
4552 <screen>mencoder dvd://1 -o /dev/null -ss 32 -ovc x264 \
|
|
4553 -x264encopts pass=1:turbo:bitrate=900:bframes=1:\
|
|
4554 me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
|
|
4555 -vf crop=720:352:0:62,scale=-10:-1,harddup \
|
|
4556 -oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
|
|
4557 -ofps 24000/1001</screen>
|
|
4558
|
|
4559 If you have a multi-processor machine, don't miss the opportunity to
|
|
4560 dramatically speed-up encoding by enabling
|
|
4561 <link linkend="menc-feat-x264-encoding-options-speedvquality-threads">
|
|
4562 <systemitem class="library">x264</systemitem>'s multi-threading mode</link>
|
|
4563 by adding <option>threads=auto</option> to your <option>x264encopts</option>
|
|
4564 command-line.
|
|
4565 </para>
|
|
4566
|
|
4567 <para>
|
|
4568 The second pass is the same, except that you specify the output file
|
|
4569 and set <option>pass=2</option>.
|
|
4570
|
|
4571 <screen>mencoder dvd://1 <emphasis role="bold">-o narnia.avi</emphasis> -ss 32 -ovc x264 \
|
|
4572 -x264encopts <emphasis role="bold">pass=2</emphasis>:turbo:bitrate=900:frameref=5:bframes=1:\
|
|
4573 me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
|
|
4574 -vf crop=720:352:0:62,scale=-10:-1,harddup \
|
|
4575 -oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
|
|
4576 -ofps 24000/1001</screen>
|
|
4577 </para>
|
|
4578
|
|
4579 <para>
|
|
4580 The resulting AVI should play perfectly in
|
|
4581 <application>MPlayer</application>, but of course
|
|
4582 <application>QuickTime</application> can not play it because it does
|
|
4583 not support H.264 muxed in AVI.
|
|
4584 So the next step is to remux the video into an MP4 container.
|
|
4585 </para>
|
|
4586 </sect2>
|
|
4587
|
|
4588 <sect2 id="menc-feat-quicktime-7-remux">
|
|
4589 <title>Remuxing as MP4</title>
|
|
4590
|
|
4591 <para>
|
|
4592 There are several ways to remux AVI files to MP4. You can use
|
|
4593 <application>mp4creator</application>, which is part of the
|
|
4594 <ulink url="http://mpeg4ip.sourceforge.net/">MPEG4IP suite</ulink>.
|
|
4595 </para>
|
|
4596
|
|
4597 <para>
|
|
4598 First, demux the AVI into separate audio and video streams using
|
|
4599 <application>MPlayer</application>.
|
|
4600
|
|
4601 <screen>mplayer narnia.avi -dumpaudio -dumpfile narnia.aac
|
|
4602 mplayer narnia.avi -dumpvideo -dumpfile narnia.h264</screen>
|
|
4603
|
|
4604 The filenames are important; <application>mp4creator</application>
|
|
4605 requires that AAC audio streams be named <systemitem>.aac</systemitem>
|
|
4606 and H.264 video streams be named <systemitem>.h264</systemitem>.
|
|
4607 </para>
|
|
4608
|
|
4609 <para>
|
|
4610 Now use <application>mp4creator</application> to create a new
|
|
4611 MP4 file out of the audio and video streams.
|
|
4612
|
|
4613 <screen>mp4creator -create=narnia.aac narnia.mp4
|
|
4614 mp4creator -create=narnia.h264 -rate=23.976 narnia.mp4</screen>
|
|
4615
|
|
4616 Unlike the encoding step, you must specify the framerate as a
|
|
4617 decimal (such as 23.976), not a fraction (such as 24000/1001).
|
|
4618 </para>
|
|
4619
|
|
4620 <para>
|
|
4621 This <systemitem>narnia.mp4</systemitem> file should now be playable
|
|
4622 with any <application>QuickTime</application> 7 application, such as
|
|
4623 <application>QuickTime Player</application> or
|
|
4624 <application>iTunes</application>. If you are planning to view the
|
|
4625 video in a web browser with the <application>QuickTime</application>
|
|
4626 plugin, you should also hint the movie so that the
|
|
4627 <application>QuickTime</application> plugin can start playing it
|
|
4628 while it is still downloading. <application>mp4creator</application>
|
|
4629 can create these hint tracks:
|
|
4630
|
|
4631 <screen>mp4creator -hint=1 narnia.mp4
|
|
4632 mp4creator -hint=2 narnia.mp4
|
|
4633 mp4creator -optimize narnia.mp4</screen>
|
|
4634
|
|
4635 You can check the final result to ensure that the hint tracks were
|
|
4636 created successfully:
|
|
4637
|
|
4638 <screen>mp4creator -list narnia.mp4</screen>
|
|
4639
|
|
4640 You should see a list of tracks: 1 audio, 1 video, and 2 hint tracks.
|
|
4641
|
|
4642 <screen>Track Type Info
|
|
4643 1 audio MPEG-4 AAC LC, 8548.714 secs, 190 kbps, 48000 Hz
|
|
4644 2 video H264 Main@5.1, 8549.132 secs, 899 kbps, 848x352 @ 23.976001 fps
|
|
4645 3 hint Payload mpeg4-generic for track 1
|
|
4646 4 hint Payload H264 for track 2
|
|
4647 </screen>
|
|
4648 </para>
|
|
4649
|
|
4650 </sect2>
|
|
4651
|
|
4652 <sect2 id="menc-feat-quicktime-7-metadata">
|
|
4653 <title>Adding metadata tags</title>
|
|
4654
|
|
4655 <para>
|
|
4656 If you want to add tags to your video that show up in iTunes, you can use
|
|
4657 <ulink url="http://atomicparsley.sourceforge.net/">AtomicParsley</ulink>.
|
|
4658
|
|
4659 <screen>AtomicParsley narnia.mp4 --metaEnema --title "The Chronicles of Narnia" --year 2005 --stik Movie --freefree --overWrite</screen>
|
|
4660
|
|
4661 The <option>--metaEnema</option> option removes any existing metadata
|
|
4662 (<application>mp4creator</application> inserts its name in the
|
|
4663 "encoding tool" tag), and <option>--freefree</option> reclaims the
|
|
4664 space from the deleted metadata.
|
|
4665 The <option>--stik</option> option sets the type of video (such as Movie
|
|
4666 or TV Show), which iTunes uses to group related video files.
|
|
4667 The <option>--overWrite</option> option overwrites the original file;
|
|
4668 without it, <application>AtomicParsley</application> creates a new
|
|
4669 auto-named file in the same directory and leaves the original file
|
|
4670 untouched.
|
|
4671 </para>
|
|
4672
|
|
4673 </sect2>
|
|
4674
|
|
4675 </sect1>
|
|
4676
|
|
4677
|
|
4678 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4679
|
|
4680
|
|
4681 <sect1 id="menc-feat-vcd-dvd">
|
|
4682 <title>Using <application>MEncoder</application>
|
|
4683 to create VCD/SVCD/DVD-compliant files</title>
|
|
4684
|
|
4685 <sect2 id="menc-feat-vcd-dvd-constraints">
|
|
4686 <title>Format Constraints</title>
|
|
4687
|
|
4688 <para>
|
|
4689 <application>MEncoder</application> is capable of creating VCD, SCVD
|
|
4690 and DVD format MPEG files using the
|
|
4691 <systemitem class="library">libavcodec</systemitem> library.
|
|
4692 These files can then be used in conjunction with
|
|
4693 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>
|
|
4694 or
|
|
4695 <ulink url="http://dvdauthor.sourceforge.net/">dvdauthor</ulink>
|
|
4696 to create discs that will play on a standard set-top player.
|
|
4697 </para>
|
|
4698
|
|
4699 <para>
|
|
4700 The DVD, SVCD, and VCD formats are subject to heavy constraints.
|
|
4701 Only a small selection of encoded picture sizes and aspect ratios are
|
|
4702 available.
|
|
4703 If your movie does not already meet these requirements, you may have
|
|
4704 to scale, crop or add black borders to the picture to make it
|
|
4705 compliant.
|
|
4706 </para>
|
|
4707
|
|
4708
|
|
4709 <sect3 id="menc-feat-vcd-dvd-constraints-resolution">
|
|
4710 <title>Format Constraints</title>
|
|
4711
|
|
4712 <informaltable frame="all">
|
|
4713 <tgroup cols="9">
|
|
4714 <thead>
|
|
4715 <row>
|
|
4716 <entry>Format</entry>
|
|
4717 <entry>Resolution</entry>
|
|
4718 <entry>V. Codec</entry>
|
|
4719 <entry>V. Bitrate</entry>
|
|
4720 <entry>Sample Rate</entry>
|
|
4721 <entry>A. Codec</entry>
|
|
4722 <entry>A. Bitrate</entry>
|
|
4723 <entry>FPS</entry>
|
|
4724 <entry>Aspect</entry>
|
|
4725 </row>
|
|
4726 </thead>
|
|
4727 <tbody>
|
|
4728 <row>
|
|
4729 <entry>NTSC DVD</entry>
|
|
4730 <entry>720x480, 704x480, 352x480, 352x240</entry>
|
|
4731 <entry>MPEG-2</entry>
|
|
4732 <entry>9800 kbps</entry>
|
|
4733 <entry>48000 Hz</entry>
|
|
4734 <entry>AC-3,PCM</entry>
|
|
4735 <entry>1536 kbps (max)</entry>
|
|
4736 <entry>30000/1001, 24000/1001</entry>
|
|
4737 <entry>4:3, 16:9 (only for 720x480)</entry>
|
|
4738 </row>
|
|
4739 <row>
|
|
4740 <entry>NTSC DVD</entry>
|
|
4741 <entry>352x240<footnote id='fn-rare-resolutions'><para>
|
|
4742 These resolutions are rarely used for DVDs because
|
|
4743 they are fairly low quality.</para></footnote></entry>
|
|
4744 <entry>MPEG-1</entry>
|
|
4745 <entry>1856 kbps</entry>
|
|
4746 <entry>48000 Hz</entry>
|
|
4747 <entry>AC-3,PCM</entry>
|
|
4748 <entry>1536 kbps (max)</entry>
|
|
4749 <entry>30000/1001, 24000/1001</entry>
|
|
4750 <entry>4:3, 16:9</entry>
|
|
4751 </row>
|
|
4752 <row>
|
|
4753 <entry>NTSC SVCD</entry>
|
|
4754 <entry>480x480</entry>
|
|
4755 <entry>MPEG-2</entry>
|
|
4756 <entry>2600 kbps</entry>
|
|
4757 <entry>44100 Hz</entry>
|
|
4758 <entry>MP2</entry>
|
|
4759 <entry>384 kbps (max)</entry>
|
|
4760 <entry>30000/1001</entry>
|
|
4761 <entry>4:3</entry>
|
|
4762 </row>
|
|
4763 <row>
|
|
4764 <entry>NTSC VCD</entry>
|
|
4765 <entry>352x240</entry>
|
|
4766 <entry>MPEG-1</entry>
|
|
4767 <entry>1150 kbps</entry>
|
|
4768 <entry>44100 Hz</entry>
|
|
4769 <entry>MP2</entry>
|
|
4770 <entry>224 kbps</entry>
|
|
4771 <entry>24000/1001, 30000/1001</entry>
|
|
4772 <entry>4:3</entry>
|
|
4773 </row>
|
|
4774 <row>
|
|
4775 <entry>PAL DVD</entry>
|
|
4776 <entry>720x576, 704x576, 352x576, 352x288</entry>
|
|
4777 <entry>MPEG-2</entry>
|
|
4778 <entry>9800 kbps</entry>
|
|
4779 <entry>48000 Hz</entry>
|
|
4780 <entry>MP2,AC-3,PCM</entry>
|
|
4781 <entry>1536 kbps (max)</entry>
|
|
4782 <entry>25</entry>
|
|
4783 <entry>4:3, 16:9 (only for 720x576)</entry>
|
|
4784 </row>
|
|
4785 <row>
|
|
4786 <entry>PAL DVD</entry>
|
|
4787 <entry>352x288<footnoteref linkend='fn-rare-resolutions'/></entry>
|
|
4788 <entry>MPEG-1</entry>
|
|
4789 <entry>1856 kbps</entry>
|
|
4790 <entry>48000 Hz</entry>
|
|
4791 <entry>MP2,AC-3,PCM</entry>
|
|
4792 <entry>1536 kbps (max)</entry>
|
|
4793 <entry>25</entry>
|
|
4794 <entry>4:3, 16:9</entry>
|
|
4795 </row>
|
|
4796 <row>
|
|
4797 <entry>PAL SVCD</entry>
|
|
4798 <entry>480x576</entry>
|
|
4799 <entry>MPEG-2</entry>
|
|
4800 <entry>2600 kbps</entry>
|
|
4801 <entry>44100 Hz</entry>
|
|
4802 <entry>MP2</entry>
|
|
4803 <entry>384 kbps (max)</entry>
|
|
4804 <entry>25</entry>
|
|
4805 <entry>4:3</entry>
|
|
4806 </row>
|
|
4807 <row>
|
|
4808 <entry>PAL VCD</entry>
|
|
4809 <entry>352x288</entry>
|
|
4810 <entry>MPEG-1</entry>
|
|
4811 <entry>1152 kbps</entry>
|
|
4812 <entry>44100 Hz</entry>
|
|
4813 <entry>MP2</entry>
|
|
4814 <entry>224 kbps</entry>
|
|
4815 <entry>25</entry>
|
|
4816 <entry>4:3</entry>
|
|
4817 </row>
|
|
4818 </tbody>
|
|
4819 </tgroup>
|
|
4820 </informaltable>
|
|
4821
|
|
4822 <para>
|
|
4823 If your movie has 2.35:1 aspect (most recent action movies), you will
|
|
4824 have to add black borders or crop the movie down to 16:9 to make a DVD or VCD.
|
|
4825 If you add black borders, try to align them at 16-pixel boundaries in
|
|
4826 order to minimize the impact on encoding performance.
|
|
4827 Thankfully DVD has sufficiently excessive bitrate that you do not have
|
|
4828 to worry too much about encoding efficiency, but SVCD and VCD are
|
|
4829 highly bitrate-starved and require effort to obtain acceptable quality.
|
|
4830 </para>
|
|
4831 </sect3>
|
|
4832
|
|
4833
|
|
4834 <sect3 id="menc-feat-vcd-dvd-constraints-gop">
|
|
4835 <title>GOP Size Constraints</title>
|
|
4836
|
|
4837 <para>
|
|
4838 DVD, VCD, and SVCD also constrain you to relatively low
|
|
4839 GOP (Group of Pictures) sizes.
|
|
4840 For 30 fps material the largest allowed GOP size is 18.
|
|
4841 For 25 or 24 fps, the maximum is 15.
|
|
4842 The GOP size is set using the <option>keyint</option> option.
|
|
4843 </para>
|
|
4844 </sect3>
|
|
4845
|
|
4846
|
|
4847 <sect3 id="menc-feat-vcd-dvd-constraints-bitrate">
|
|
4848 <title>Bitrate Constraints</title>
|
|
4849
|
|
4850 <para>
|
|
4851 VCD video is required to be CBR at 1152 kbps.
|
|
4852 This highly limiting constraint also comes along with an extremly low vbv
|
|
4853 buffer size of 327 kilobits.
|
|
4854 SVCD allows varying video bitrates up to 2500 kbps, and a somewhat less
|
|
4855 restrictive vbv buffer size of 917 kilobits is allowed.
|
|
4856 DVD video bitrates may range anywhere up to 9800 kbps (though typical
|
|
4857 bitrates are about half that), and the vbv buffer size is 1835 kilobits.
|
|
4858 </para>
|
|
4859 </sect3>
|
|
4860 </sect2>
|
|
4861
|
|
4862 <!-- ********** -->
|
|
4863
|
|
4864 <sect2 id="menc-feat-vcd-dvd-output">
|
|
4865 <title>Output Options</title>
|
|
4866
|
|
4867 <para>
|
|
4868 <application>MEncoder</application> has options to control the output
|
|
4869 format.
|
|
4870 Using these options we can instruct it to create the correct type of
|
|
4871 file.
|
|
4872 </para>
|
|
4873
|
|
4874 <para>
|
|
4875 The options for VCD and SVCD are called xvcd and xsvcd, because they
|
|
4876 are extended formats.
|
|
4877 They are not strictly compliant, mainly because the output does not
|
|
4878 contain scan offsets.
|
|
4879 If you need to generate an SVCD image, you should pass the output file to
|
|
4880 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>.
|
|
4881 </para>
|
|
4882
|
|
4883 <para>
|
|
4884 VCD:
|
|
4885 <screen>-of mpeg -mpegopts format=xvcd</screen>
|
|
4886 </para>
|
|
4887
|
|
4888 <para>
|
|
4889 SVCD:
|
|
4890 <screen>-of mpeg -mpegopts format=xsvcd</screen>
|
|
4891 </para>
|
|
4892
|
|
4893 <para>
|
|
4894 DVD (with timestamps on every frame, if possible):
|
|
4895 <screen>-of mpeg -mpegopts format=dvd:tsaf</screen>
|
|
4896 </para>
|
|
4897
|
|
4898 <para>
|
|
4899 DVD with NTSC Pullup:
|
|
4900 <screen>-of mpeg -mpegopts format=dvd:tsaf:telecine -ofps 24000/1001</screen>
|
|
4901 This allows 24000/1001 fps progressive content to be encoded at 30000/1001
|
|
4902 fps whilst maintaing DVD-compliance.
|
|
4903 </para>
|
|
4904
|
|
4905
|
|
4906 <sect3 id="menc-feat-vcd-dvd-output-aspect">
|
|
4907 <title>Aspect Ratio</title>
|
|
4908
|
|
4909 <para>
|
|
4910 The aspect argument of <option>-lavcopts</option> is used to encode
|
|
4911 the aspect ratio of the file.
|
|
4912 During playback the aspect ratio is used to restore the video to the
|
|
4913 correct size.
|
|
4914 </para>
|
|
4915
|
|
4916 <para>
|
|
4917 16:9 or "Widescreen"
|
|
4918 <screen>-lavcopts aspect=16/9</screen>
|
|
4919 </para>
|
|
4920
|
|
4921 <para>
|
|
4922 4:3 or "Fullscreen"
|
|
4923 <screen>-lavcopts aspect=4/3</screen>
|
|
4924 </para>
|
|
4925
|
|
4926 <para>
|
|
4927 2.35:1 or "Cinemascope" NTSC
|
|
4928 <screen>-vf scale=720:368,expand=720:480 -lavcopts aspect=16/9</screen>
|
|
4929 To calculate the correct scaling size, use the expanded NTSC width of
|
|
4930 854/2.35 = 368
|
|
4931 </para>
|
|
4932
|
|
4933 <para>
|
|
4934 2.35:1 or "Cinemascope" PAL
|
|
4935 <screen>-vf scale=720:432,expand=720:576 -lavcopts aspect=16/9</screen>
|
|
4936 To calculate the correct scaling size, use the expanded PAL width of
|
|
4937 1024/2.35 = 432
|
|
4938 </para>
|
|
4939 </sect3>
|
|
4940
|
|
4941
|
|
4942 <sect3 id="menc-feat-vcd-dvd-a-v-sync">
|
|
4943 <title>Maintaining A/V sync</title>
|
|
4944
|
|
4945 <para>
|
|
4946 In order to maintain audio/video synchronization throughout the encode,
|
|
4947 <application>MEncoder</application> has to drop or duplicate frames.
|
|
4948 This works rather well when muxing into an AVI file, but is almost
|
|
4949 guaranteed to fail to maintain A/V sync with other muxers such as MPEG.
|
|
4950 This is why it is necessary to append the
|
|
4951 <option>harddup</option> video filter at the end of the filter chain
|
|
4952 to avoid this kind of problem.
|
|
4953 You can find more technical information about <option>harddup</option>
|
|
4954 in the section
|
|
4955 <link linkend="menc-feat-dvd-mpeg4-muxing-filter-issues">Improving muxing and A/V sync reliability</link>
|
|
4956 or in the manual page.
|
|
4957 </para>
|
|
4958 </sect3>
|
|
4959
|
|
4960
|
|
4961 <sect3 id="menc-feat-vcd-dvd-output-srate">
|
|
4962 <title>Sample Rate Conversion</title>
|
|
4963
|
|
4964 <para>
|
|
4965 If the audio sample rate in the original file is not the same as
|
|
4966 required by the target format, sample rate conversion is required.
|
|
4967 This is achieved using the <option>-srate</option> option and
|
|
4968 the <option>-af lavcresample</option> audio filter together.
|
|
4969 </para>
|
|
4970
|
|
4971 <para>
|
|
4972 DVD:
|
|
4973 <screen>-srate 48000 -af lavcresample=48000</screen>
|
|
4974 </para>
|
|
4975
|
|
4976 <para>
|
|
4977 VCD and SVCD:
|
|
4978 <screen>-srate 44100 -af lavcresample=44100</screen>
|
|
4979 </para>
|
|
4980 </sect3>
|
|
4981 </sect2>
|
|
4982
|
|
4983 <!-- ********** -->
|
|
4984
|
|
4985 <sect2 id="menc-feat-vcd-dvd-lavc">
|
|
4986 <title>Using libavcodec for VCD/SVCD/DVD Encoding</title>
|
|
4987
|
|
4988 <sect3 id="menc-feat-vcd-dvd-lavc-intro">
|
|
4989 <title>Introduction</title>
|
|
4990
|
|
4991 <para>
|
|
4992 <systemitem class="library">libavcodec</systemitem> can be used to
|
|
4993 create VCD/SVCD/DVD compliant video by using the appropriate options.
|
|
4994 </para>
|
|
4995 </sect3>
|
|
4996
|
|
4997
|
|
4998 <sect3 id="menc-feat-vcd-dvd-lavc-options">
|
|
4999 <title>lavcopts</title>
|
|
5000
|
|
5001 <para>
|
|
5002 This is a list of fields in <option>-lavcopts</option> that you may
|
|
5003 be required to change in order to make a complaint movie for VCD, SVCD,
|
|
5004 or DVD:
|
|
5005 </para>
|
|
5006
|
|
5007 <itemizedlist>
|
|
5008 <listitem><para>
|
|
5009 <emphasis role="bold">acodec</emphasis>:
|
|
5010 <option>mp2</option> for VCD, SVCD, or PAL DVD;
|
|
5011 <option>ac3</option> is most commonly used for DVD.
|
|
5012 PCM audio may also be used for DVD, but this is mostly a big waste of
|
|
5013 space.
|
|
5014 Note that MP3 audio is not compliant for any of these formats, but
|
|
5015 players often have no problem playing it anyway.
|
|
5016 </para></listitem>
|
|
5017 <listitem><para>
|
|
5018 <emphasis role="bold">abitrate</emphasis>:
|
|
5019 224 for VCD; up to 384 for SVCD; up to 1536 for DVD, but commonly
|
|
5020 used values range from 192 kbps for stereo to 384 kbps for 5.1 channel
|
|
5021 sound.
|
|
5022 </para></listitem>
|
|
5023 <listitem><para>
|
|
5024 <emphasis role="bold">vcodec</emphasis>:
|
|
5025 <option>mpeg1video</option> for VCD;
|
|
5026 <option>mpeg2video</option> for SVCD;
|
|
5027 <option>mpeg2video</option> is usually used for DVD but you may also use
|
|
5028 <option>mpeg1video</option> for CIF resolutions.
|
|
5029 </para></listitem>
|
|
5030 <listitem><para>
|
|
5031 <emphasis role="bold">keyint</emphasis>:
|
|
5032 Used to set the GOP size.
|
|
5033 18 for 30fps material, or 15 for 25/24 fps material.
|
|
5034 Commercial producers seem to prefer keyframe intervals of 12.
|
|
5035 It is possible to make this much larger and still retain compatibility
|
|
5036 with most players.
|
|
5037 A <option>keyint</option> of 25 should never cause any problems.
|
|
5038 </para></listitem>
|
|
5039 <listitem><para>
|
|
5040 <emphasis role="bold">vrc_buf_size</emphasis>:
|
|
5041 327 for VCD, 917 for SVCD, and 1835 for DVD.
|
|
5042 </para></listitem>
|
|
5043 <listitem><para>
|
|
5044 <emphasis role="bold">vrc_minrate</emphasis>:
|
|
5045 1152, for VCD. May be left alone for SVCD and DVD.
|
|
5046 </para></listitem>
|
|
5047 <listitem><para>
|
|
5048 <emphasis role="bold">vrc_maxrate</emphasis>:
|
|
5049 1152 for VCD; 2500 for SVCD; 9800 for DVD.
|
|
5050 For SVCD and DVD, you might wish to use lower values depending on your
|
|
5051 own personal preferences and requirements.
|
|
5052 </para></listitem>
|
|
5053 <listitem><para>
|
|
5054 <emphasis role="bold">vbitrate</emphasis>:
|
|
5055 1152 for VCD;
|
|
5056 up to 2500 for SVCD;
|
|
5057 up to 9800 for DVD.
|
|
5058 For the latter two formats, vbitrate should be set based on personal
|
|
5059 preference.
|
|
5060 For instance, if you insist on fitting 20 or so hours on a DVD, you
|
|
5061 could use vbitrate=400.
|
|
5062 The resulting video quality would probably be quite bad.
|
|
5063 If you are trying to squeeze out the maximum possible quality on a DVD,
|
|
5064 use vbitrate=9800, but be warned that this could constrain you to less
|
|
5065 than an hour of video on a single-layer DVD.
|
|
5066 </para></listitem>
|
|
5067 <listitem><para>
|
|
5068 <emphasis role="bold">vstrict</emphasis>:
|
|
5069 <option>vstrict</option>=0 should be used to create DVDs.
|
|
5070 Without this option, <application>MEncoder</application> creates a
|
|
5071 stream that cannot be correctly decoded by some standalone DVD
|
|
5072 players.
|
|
5073 </para></listitem>
|
|
5074 </itemizedlist>
|
|
5075 </sect3>
|
|
5076
|
|
5077
|
|
5078 <sect3 id="menc-feat-vcd-dvd-lavc-examples">
|
|
5079 <title>Examples</title>
|
|
5080
|
|
5081 <para>
|
|
5082 This is a typical minimum set of <option>-lavcopts</option> for
|
|
5083 encoding video:
|
|
5084 </para>
|
|
5085 <para>
|
|
5086 VCD:
|
|
5087 <screen>
|
|
5088 -lavcopts vcodec=mpeg1video:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5089 vrc_maxrate=1152:vbitrate=1152:keyint=15:acodec=mp2
|
|
5090 </screen>
|
|
5091 </para>
|
|
5092
|
|
5093 <para>
|
|
5094 SVCD:
|
|
5095 <screen>
|
|
5096 -lavcopts vcodec=mpeg2video:vrc_buf_size=917:vrc_maxrate=2500:vbitrate=1800:\
|
|
5097 keyint=15:acodec=mp2
|
|
5098 </screen>
|
|
5099 </para>
|
|
5100
|
|
5101 <para>
|
|
5102 DVD:
|
|
5103 <screen>
|
|
5104 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5105 keyint=15:vstrict=0:acodec=ac3
|
|
5106 </screen>
|
|
5107 </para>
|
|
5108 </sect3>
|
|
5109
|
|
5110
|
|
5111 <sect3 id="menc-feat-vcd-dvd-lavc-advanced">
|
|
5112 <title>Advanced Options</title>
|
|
5113
|
|
5114 <para>
|
|
5115 For higher quality encoding, you may also wish to add quality-enhancing
|
|
5116 options to lavcopts, such as <option>trell</option>,
|
|
5117 <option>mbd=2</option>, and others.
|
|
5118 Note that <option>qpel</option> and <option>v4mv</option>, while often
|
|
5119 useful with MPEG-4, are not usable with MPEG-1 or MPEG-2.
|
|
5120 Also, if you are trying to make a very high quality DVD encode, it may
|
|
5121 be useful to add <option>dc=10</option> to lavcopts.
|
|
5122 Doing so may help reduce the appearance of blocks in flat-colored areas.
|
|
5123 Putting it all together, this is an example of a set of lavcopts for a
|
|
5124 higher quality DVD:
|
|
5125 </para>
|
|
5126
|
|
5127 <para>
|
|
5128 <screen>
|
|
5129 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:\
|
|
5130 keyint=15:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:\
|
|
5131 vqmin=1:lmin=1:dc=10:vstrict=0
|
|
5132 </screen>
|
|
5133 </para>
|
|
5134 </sect3>
|
|
5135 </sect2>
|
|
5136
|
|
5137 <!-- ********** -->
|
|
5138
|
|
5139 <sect2 id="menc-feat-vcd-dvd-audio">
|
|
5140 <title>Encoding Audio</title>
|
|
5141
|
|
5142 <para>
|
|
5143 VCD and SVCD support MPEG-1 layer II audio, using one of
|
|
5144 <systemitem class="library">toolame</systemitem>,
|
|
5145 <systemitem class="library">twolame</systemitem>,
|
|
5146 or <systemitem class="library">libavcodec</systemitem>'s MP2 encoder.
|
|
5147 The libavcodec MP2 is far from being as good as the other two libraries,
|
|
5148 however it should always be available to use.
|
|
5149 VCD only supports constant bitrate audio (CBR) whereas SVCD supports
|
|
5150 variable bitrate (VBR), too.
|
|
5151 Be careful when using VBR because some bad standalone players might not
|
|
5152 support it too well.
|
|
5153 </para>
|
|
5154
|
|
5155 <para>
|
|
5156 For DVD audio, <systemitem class="library">libavcodec</systemitem>'s
|
|
5157 AC-3 codec is used.
|
|
5158 </para>
|
|
5159
|
|
5160
|
|
5161 <sect3 id="menc-feat-vcd-dvd-audio-toolame">
|
|
5162 <title>toolame</title>
|
|
5163
|
|
5164 <para>
|
|
5165 For VCD and SVCD:
|
|
5166 <screen>-oac toolame -toolameopts br=224</screen>
|
|
5167 </para>
|
|
5168 </sect3>
|
|
5169
|
|
5170
|
|
5171 <sect3 id="menc-feat-vcd-dvd-audio-twolame">
|
|
5172 <title>twolame</title>
|
|
5173
|
|
5174 <para>
|
|
5175 For VCD and SVCD:
|
|
5176 <screen>-oac twolame -twolameopts br=224</screen>
|
|
5177 </para>
|
|
5178 </sect3>
|
|
5179
|
|
5180
|
|
5181 <sect3 id="menc-feat-vcd-dvd-audio-lavc">
|
|
5182 <title>libavcodec</title>
|
|
5183
|
|
5184 <para>
|
|
5185 For DVD with 2 channel sound:
|
|
5186 <screen>-oac lavc -lavcopts acodec=ac3:abitrate=192</screen>
|
|
5187 </para>
|
|
5188
|
|
5189 <para>
|
|
5190 For DVD with 5.1 channel sound:
|
|
5191 <screen>-channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=384</screen>
|
|
5192 </para>
|
|
5193
|
|
5194 <para>
|
|
5195 For VCD and SVCD:
|
|
5196 <screen>-oac lavc -lavcopts acodec=mp2:abitrate=224</screen>
|
|
5197 </para>
|
|
5198 </sect3>
|
|
5199 </sect2>
|
|
5200
|
|
5201 <!-- ********** -->
|
|
5202
|
|
5203 <sect2 id="menc-feat-vcd-dvd-all">
|
|
5204 <title>Putting it all Together</title>
|
|
5205
|
|
5206 <para>
|
|
5207 This section shows some complete commands for creating VCD/SVCD/DVD
|
|
5208 compliant videos.
|
|
5209 </para>
|
|
5210
|
|
5211
|
|
5212 <sect3 id="menc-feat-vcd-dvd-all-pal-dvd">
|
|
5213 <title>PAL DVD</title>
|
|
5214
|
|
5215 <para>
|
|
5216 <screen>
|
|
5217 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5218 -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 \
|
|
5219 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5220 keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 \
|
|
5221 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5222 </screen>
|
|
5223 </para>
|
|
5224 </sect3>
|
|
5225
|
|
5226
|
|
5227 <sect3 id="menc-feat-vcd-dvd-all-ntsc-dvd">
|
|
5228 <title>NTSC DVD</title>
|
|
5229
|
|
5230 <para>
|
|
5231 <screen>
|
|
5232 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5233 -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \
|
|
5234 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5235 keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 30000/1001 \
|
|
5236 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5237 </screen>
|
|
5238 </para>
|
|
5239 </sect3>
|
|
5240
|
|
5241
|
|
5242 <sect3 id="menc-feat-vcd-dvd-all-pal-ac3-copy">
|
|
5243 <title>PAL AVI Containing AC-3 Audio to DVD</title>
|
|
5244
|
|
5245 <para>
|
|
5246 If the source already has AC-3 audio, use -oac copy instead of re-encoding it.
|
|
5247 <screen>
|
|
5248 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5249 -vf scale=720:576,harddup -ofps 25 \
|
|
5250 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5251 keyint=15:vstrict=0:aspect=16/9 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5252 </screen>
|
|
5253 </para>
|
|
5254 </sect3>
|
|
5255
|
|
5256
|
|
5257 <sect3 id="menc-feat-vcd-dvd-all-ntsc-ac3-copy">
|
|
5258 <title>NTSC AVI Containing AC-3 Audio to DVD</title>
|
|
5259
|
|
5260 <para>
|
|
5261 If the source already has AC-3 audio, and is NTSC @ 24000/1001 fps:
|
|
5262 <screen>
|
|
5263 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf:telecine \
|
|
5264 -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:\
|
|
5265 vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:aspect=16/9 -ofps 24000/1001 \
|
|
5266 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5267 </screen>
|
|
5268 </para>
|
|
5269 </sect3>
|
|
5270
|
|
5271
|
|
5272 <sect3 id="menc-feat-vcd-dvd-all-pal-svcd">
|
|
5273 <title>PAL SVCD</title>
|
|
5274
|
|
5275 <para>
|
|
5276 <screen>
|
|
5277 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
5278 scale=480:576,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5279 vcodec=mpeg2video:mbd=2:keyint=15:vrc_buf_size=917:vrc_minrate=600:\
|
|
5280 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 25 \
|
|
5281 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5282 </screen>
|
|
5283 </para>
|
|
5284 </sect3>
|
|
5285
|
|
5286
|
|
5287 <sect3 id="menc-feat-vcd-dvd-all-ntsc-svcd">
|
|
5288 <title>NTSC SVCD</title>
|
|
5289
|
|
5290 <para>
|
|
5291 <screen>
|
|
5292 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
5293 scale=480:480,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5294 vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:\
|
|
5295 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
5296 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5297 </screen>
|
|
5298 </para>
|
|
5299 </sect3>
|
|
5300
|
|
5301
|
|
5302 <sect3 id="menc-feat-vcd-dvd-all-pal-vcd">
|
|
5303 <title>PAL VCD</title>
|
|
5304
|
|
5305 <para>
|
|
5306 <screen>
|
|
5307 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
5308 scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5309 vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5310 vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
|
|
5311 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5312 </screen>
|
|
5313 </para>
|
|
5314 </sect3>
|
|
5315
|
|
5316
|
|
5317 <sect3 id="menc-feat-vcd-dvd-all-ntsc-vcd">
|
|
5318 <title>NTSC VCD</title>
|
|
5319
|
|
5320 <para>
|
|
5321 <screen>
|
|
5322 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
5323 scale=352:240,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5324 vcodec=mpeg1video:keyint=18:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5325 vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
5326 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5327 </screen>
|
|
5328 </para>
|
|
5329 </sect3>
|
|
5330 </sect2>
|
|
5331 </sect1>
|
|
5332 </chapter>
|