25279
|
1 <?xml version="1.0" encoding="utf-8"?>
|
26811
|
2 <!-- 41% synced with r22753 (row 2212) -->
|
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 A meno che tu non stia per codificare con quantizzazione costante devi
|
|
982 impostare un bitrate.
|
|
983 La logica del bitrate è abbastanza semplice.
|
|
984 Normalmente il bitrate viene misurato in kilobit (1000 bit) al secondo.
|
|
985 La dimensione del filmato sul disco è il bitrate moltiplicato per la durata
|
|
986 del filmato, più un piccolo quantitativo in "surplus" (vedi per esempio la
|
|
987 sezione sul
|
|
988 <link linkend="menc-feat-dvd-mpeg4-muxing-avi-limitations">contenitore AVI</link>).
|
|
989 Altri parametri come ridimensionamento, taglio, etc...
|
|
990 <emphasis role="bold">non</emphasis> influiscono sulla dimensione del file a
|
|
991 meno che tu non cambi anche il bitrate!
|
|
992 </para>
|
|
993
|
|
994 <para>
|
|
995 Il bitrate <emphasis role="bold">non</emphasis> è direttamente proporzionale
|
|
996 alla risoluzione.
|
|
997 Tanto per capirci, un file 320x240 a 200 kbit/sec non avrà la stessa qualità
|
|
998 dello stesso filmato a 640x480 e 800 kbit/sec!
|
|
999 Ci sono due ragioni per ciò:
|
|
1000 <orderedlist>
|
|
1001 <listitem><para>
|
|
1002 <emphasis role="bold">Percettiva</emphasis>: noti di più gli artefatti MPEG
|
|
1003 quando sono più grandi!
|
|
1004 Gli artefatti appaiono a livello dei blocchi (8x8).
|
|
1005 Il tuo occhio non noterà errori in 4800 piccoli blocchi tanti quanti ne
|
|
1006 vedrà in 1200 grossi blocchi (assumendo che tu li stia ridimensionando tutti
|
|
1007 e due a schermo intero).
|
|
1008 </para></listitem>
|
|
1009 <listitem><para>
|
|
1010 <emphasis role="bold">Teorica</emphasis> : quando rimpicciolisci un immagine
|
|
1011 ma usi la stessa dimensione dei blocchi (8x8) per la trasformazione spaziale
|
|
1012 della frequenza, hai più dati nelle bande ad alta frequenza. In parole
|
|
1013 povere, ogni pixel contiene più dettagli di quanti ne contenesse prima.
|
|
1014 Quindi anche se la tua immagine rimpicciolita contiene 1/4 delle informazioni
|
|
1015 sulle direzioni spaziali, potrebbe ancora contenere una gran parte delle
|
|
1016 informazioni nel dominio delal frequenza (assumendo che le alte frequenze
|
|
1017 siano sotto-utilizzate nell'immagine di origine a 640x480).
|
|
1018 </para></listitem>
|
|
1019 </orderedlist>
|
|
1020 </para>
|
|
1021
|
|
1022 <para>
|
|
1023 Guide precendenti hanno consigliato di scegliere un bitrate e una risoluzione
|
|
1024 in base ad un approccio "bit al secondo", ma di solito ciò non è valido a
|
|
1025 causa delle ragioni suddette.
|
|
1026 Una stima migliore pare essere che il bitrate è proporzionale alla radice
|
|
1027 quadrata della risoluzione, per cui 320x240 e 400 kbit/sec sarà
|
|
1028 paragonabile a 640x480 a 800 kbit/sec.
|
|
1029 Tuttavia ciò non è stato verificato con certezza empirica o teorica.
|
|
1030 Inoltre, dato che i filmati hanno diversi livelli di disturbo, dettaglio, angoli
|
|
1031 di movimento, etc..., è vano dare consigli generici su bit per lunghezza della
|
|
1032 diagonale (analogamente a bit per pixel, usando la radice quadrata).
|
|
1033 </para>
|
|
1034 <para>
|
|
1035 Finora abbiamo parlato della difficoltà nel scegliere un bitrate e una
|
|
1036 risoluzione.
|
|
1037 </para>
|
|
1038
|
|
1039
|
|
1040 <sect3 id="menc-feat-dvd-mpeg4-resolution-bitrate-compute">
|
|
1041 <title>Calcolare la risoluzione</title>
|
|
1042
|
|
1043 <para>
|
|
1044 I passaggi seguenti ti guideranno nel calcolo della risoluzione per la tua
|
|
1045 codifica senza distorcere troppo il video, tenendo in considerazione vari tipo
|
|
1046 di informazioni riguardo la sorgente video.
|
|
1047 Per prima cosa dovresti calcolare il rapporto di aspetto codificato:
|
|
1048 <systemitem>ARc = (Wc x (ARa / PRdvd )) / Hc</systemitem>
|
|
1049
|
|
1050 <itemizedlist>
|
|
1051 <title>dove:</title>
|
|
1052 <listitem><para>
|
|
1053 Wc e Hc sono la larghezza e l'altezza del video tagliato,
|
|
1054 </para></listitem>
|
|
1055 <listitem><para>
|
|
1056 ARa è il rapporto di aspetto mostrato, che di solito è 4/3 o 16/9,
|
|
1057 </para></listitem>
|
|
1058 <listitem><para>
|
|
1059 PRdvd à il rapporto del pixel del DVD che è uguale a 1.25=(720/576) per DVD
|
|
1060 PAL e 1.5=(720/480) per DVD NTSC.
|
|
1061 </para></listitem>
|
|
1062 </itemizedlist>
|
|
1063 </para>
|
|
1064
|
|
1065 <para>
|
|
1066 Dopo puoi calcolare la risoluzione X e Y, basandoti su un dato fattore
|
|
1067 di qualità di compressione (Compression Quality, CQ):
|
|
1068 <systemitem>ResY = INT(SQRT( 1000*Bitrate/25/ARc/CQ )/16) * 16</systemitem>
|
|
1069 and
|
|
1070 <systemitem>ResX = INT( ResY * ARc / 16) * 16</systemitem>
|
|
1071 </para>
|
|
1072
|
|
1073 <para>
|
|
1074 Okay, ma cos'è la CQ?
|
|
1075 Il CQ rappresenta il numero di bit per pixel e per fotogramma in codifica.
|
|
1076 Parlando più semplicemente, più alto è la CQ, più difficilmente si vedranno
|
|
1077 codificati degli artefatti.
|
25449
|
1078 Tuttavia, se desideri una particolare dimensione per il tuo film (per esempio
|
|
1079 1 o 2 CD), hai un numero limitato di bit da utilizzare; devi quindi trovare un
|
|
1080 buon compromesso tra compressione e qualità.
|
25279
|
1081 </para>
|
|
1082
|
|
1083 <para>
|
|
1084 La CQ dipende dal bitrate, dall'efficienza del codec video e dalla risoluzione
|
|
1085 del filmato.
|
|
1086 Per alzare la CQ, di solito dovrai rimpicciolire il filmato visto che il bitrate
|
|
1087 viene calcolato in funzione della dimensione voluta e della lunghezza del
|
|
1088 filmato, che sono delle costanti.
|
|
1089 Con codec MPEG-4 ASP come <systemitem class="library">Xvid</systemitem> e
|
|
1090 <systemitem class="library">libavcodec</systemitem>, una CQ inferiore a 0.18
|
|
1091 solitamente genera un'immagine abbastanza squadrettata, perché non ci sono
|
|
1092 abbastanza bit per codificare l'informazione di ogni macroblocco. (MPEG4, come
|
|
1093 molti altri codec, ragruppa i pixel in blocchi di pixel per comprimere
|
|
1094 l'immagine; se non ci sono abbastanza bit, si vedono i bordi dei blocchi.)
|
|
1095 E' saggio anche prendere una CQ compresa tra 0.20 e 0.22 per un rip a 1 CD,
|
|
1096 e 0.26-0.28 per un rip a 2 CD con impostazioni standard di codifica.
|
|
1097 Opzioni più evolute di codifica come quelle qui indicate per
|
|
1098 <link linkend="menc-feat-mpeg4-lavc-example-settings"><systemitem class="library">libavcodec</systemitem></link>
|
|
1099 e
|
|
1100 <link linkend="menc-feat-xvid-example-settings"><systemitem class="library">Xvid</systemitem></link>
|
|
1101 dovrebbero permetterti di ottenere la stessa qualità con CQ compresa tra
|
|
1102 0.18 e 0.20 per un rip da 1 CD, e da 0.24 a 0.26 per 2 CD.
|
|
1103 Con codec MPEG-4 AVC come <systemitem class="library">x264</systemitem>,
|
|
1104 puoi usare una CQ che varia da 0.14 a 0.16 con opzioni standard di codifica, e
|
|
1105 dovresti riuscire a scendere tra 0.10 e 0.12 con <link linkend="menc-feat-x264-example-settings">impostazioni avanzate di codifica
|
|
1106 <systemitem class="library">x264</systemitem></link>.
|
|
1107 </para>
|
|
1108
|
|
1109 <para>
|
|
1110 Prendi per favore nota che CQ è solo un valore indicativo, dato che dipende dal
|
|
1111 contenuto che viene codificato, una CQ di 0.18 può andar bene per un Bergman,
|
|
1112 mentre per un film come Matrix, che contiene molte scene ad alta velocità, no.
|
|
1113 D'altro canto è inutile portare la CQ oltre 0.30 dato che sprecherai dei bit
|
|
1114 senza avere alcun guadagno visibile in qualità.
|
|
1115 Nota anche che come detto precedentemente in questa guida, per video a bassa
|
|
1116 risoluzione serve una CQ più alta (in rapporto, per esempio, alla risoluzione
|
|
1117 DVD) perché si vedano bene.
|
|
1118 </para>
|
|
1119 </sect3>
|
|
1120 </sect2>
|
|
1121
|
|
1122 <!-- ********** -->
|
|
1123
|
|
1124 <sect2 id="menc-feat-dvd-mpeg4-filtering">
|
|
1125 <title>Filtraggio</title>
|
|
1126
|
|
1127 <para>
|
|
1128 Imparare come usare i filtri video di <application>MEncoder</application> è
|
|
1129 essenziale per produrre delle buone codfiche.
|
|
1130 Tutta l'elaborazione video è eseguita attraverso i filtri -- taglio,
|
|
1131 ridimensionamento, aggiustamento del colore, rimozione del disturbo, rilevamento
|
|
1132 margini, deinterlacciatura, telecine, telecine inverso, e deblocco, solo per
|
|
1133 nominarne qualcuno.
|
|
1134 Insieme con la vasta gamma di formati di entrata gestiti, la varietà dei
|
|
1135 filtri disponibili in <application>MEncoder</application> è uno dei suoi
|
|
1136 più grandi vantaggi sugli altri programmi similari.
|
|
1137 </para>
|
|
1138
|
|
1139 <para>
|
|
1140 I filtri vengono caricati in catena usando l'opzione -vf:
|
|
1141
|
|
1142 <screen>-vf filtro1=opzioni,filtro2=opzioni,...</screen>
|
|
1143
|
|
1144 La maggior parte dei filtri riceve alcune opzioni numeriche separate da due
|
|
1145 punti, ma la sintassi per le opzioni cambia da filtro a filtro, indi leggiti la
|
|
1146 pagina man per i dettagli sul filtro che desideri usare.
|
|
1147 </para>
|
|
1148
|
|
1149 <para>
|
|
1150 I filtri lavorano sul video nell'ordine in cui vengono caricati.
|
|
1151 Per esempio la catena seguente:
|
|
1152
|
|
1153 <screen>-vf crop=688:464:12:4,scale=640:464</screen>
|
|
1154
|
|
1155 dapprima taglia la zona 688x464 dell'immagine con uno scostamento dall'alto a
|
|
1156 sinistra di (12,4), e poi ridimensiona il risultato a 640x464.
|
|
1157 </para>
|
|
1158
|
|
1159 <para>
|
|
1160 Taluni filtri devono essere caricati all'inizio o vicino all'inizio della
|
|
1161 catena di filtri, in modo da trarre vantaggio dalle informazioni che arrivano
|
|
1162 dal decoder video, che potrebbero essere perse o invalidate da altri filtri.
|
|
1163 Gli esempi principali sono <option>pp</option> (post elaborazione
|
|
1164 (postprocessing), solo quando esegue operazioni di deblock o dering),
|
|
1165 <option>spp</option> (un altra post elaborazione per eliminare artefatti MPEG),
|
|
1166 <option>pullup</option> (telecine inverso), e <option>softpulldown</option>
|
|
1167 (per passare da telecine soft a hard).
|
|
1168 </para>
|
|
1169
|
|
1170 <para>
|
|
1171 In generale vorrai filtrare il meno possibile in modo da rimaner fedele alla
|
|
1172 sorgente DVD originale. Il taglio è spesso necessario (com detto sopra), ma
|
|
1173 evita di ridimensionare il video. Anche se alcune volte si preferisce
|
|
1174 rimpicciolire per poter usare quantizzatori più alti, vogliamo evitare ciò:
|
|
1175 ricorda che abbiamo sin dall'inizio deciso di investire bit in qualità.
|
|
1176 </para>
|
|
1177
|
|
1178 <para>
|
|
1179 In più, non reimpostare la gamma, il contrasto, la luminosità, etc...
|
|
1180 Quello che si vede bene sul tuo schermo potrebbe non vedersi bene su altro.
|
|
1181 Queste modifiche dovrebbero esser fatte solo durante la riproduzione.
|
|
1182 </para>
|
|
1183
|
|
1184 <para>
|
|
1185 Una cosa che voresti però fare è tuttavia far passare il video attraverso un
|
|
1186 leggero filtro di rimozione disturbo, come <option>-vf hqdn3d=2:1:2</option>.
|
|
1187 Ancora, è una questione di poter meglio utilizzare quei bit: perché sprecarli
|
|
1188 codificando disturbo mentre puoi semplicemente aggiungerlo di nuovo durante la
|
|
1189 riproduzione? Alzando i parametri per <option>hqdn3d</option> aumenterà
|
|
1190 ancora la compressione, ma se aumenti troppo i valori, rischi un degrado pesante
|
|
1191 dell'immagine. I valori sopra consigliati (<option>2:1:2</option>) sono
|
|
1192 abbastanza conservativi; sentiti libero di sperimentare con valori più alti e
|
|
1193 verificare da solo il risultato.
|
|
1194 </para>
|
|
1195 </sect2>
|
|
1196
|
|
1197 <!-- ********** -->
|
|
1198
|
|
1199 <sect2 id="menc-feat-dvd-mpeg4-interlacing">
|
|
1200 <title>Interlacciamento e Telecine</title>
|
|
1201
|
|
1202 <para>
|
|
1203 Quasi tutti i film vengono ripresi a 24 fps. Dato che NTSC è 30000/1001 fps,
|
|
1204 si devono eseguire alcune elaborazioni affinché questo video a 24 fps sia
|
|
1205 letto al giusto framerate NTSC. Il processo è chiamato "3:2 pulldown", meglio
|
|
1206 conosciuto come "telecine" (poiché pulldown viene spesso applicato durante il
|
|
1207 processo di telecine), e descritto rozzamente, agisce rallentando il film a
|
|
1208 24000/1001 fps, e ripetendo ogni quarto fotogramma.
|
|
1209 </para>
|
|
1210
|
|
1211 <para>
|
|
1212 Non viene invece eseguita alcuna elaborazione sul video per i DVD PAL, che
|
|
1213 girano a 25 fps. (Tecnicamente, PAL può subire il telecine, chiamato
|
|
1214 "2:2 pulldown", ma non è usanza abituale.) Il film a 24 fps viene
|
|
1215 semplicemente riprodotto a 25 fps. Il risultato è che il filmato è leggermente
|
|
1216 più veloce, ma a meno che tu non sia un alieno, probabilmente non noterai la
|
|
1217 differenza.
|
|
1218 La maggior parte dei DVD PAL hanno audio corretto ai picchi, in modo che quando
|
|
1219 siano riprodotti a 25 fps le cose suonino giuste, anche se la traccia audio
|
|
1220 (e quindi tutto il filmato) ha un tempo di riproduzione che è il 4% inferiore
|
|
1221 ai DVD NTSC.
|
|
1222 </para>
|
|
1223
|
|
1224 <para>
|
|
1225 A causa del fatto che il video nei DVD PAL non è stato alterato, non dovrai
|
|
1226 preoccuperti molto della frequenza fotogrammi. La sorgente è 25 fps, e il tuo
|
|
1227 rip sarà a 25 fps. Tuttavia, se stai codificando un film da DVD NTSC,
|
|
1228 potresti dover applicare il telecine inverso.
|
|
1229 </para>
|
|
1230
|
|
1231 <para>
|
|
1232 Per film ripresi a 24 fps, il video sul DVD NTSC è o con telecine a 30000/1001,
|
|
1233 oppure è progressivo a 24000/1001 fps e destinato a subire il telecine al volo
|
|
1234 da un lettore DVD. D'altro canto le serie TV sono solitamente solo
|
|
1235 interlacciate, senza telecine. Questa non è una regola ferrea: alcune serie TV
|
|
1236 sono interlacciate (come Buffy the Vampire Slayer) mentre alcune sono un misto
|
|
1237 di progressivo e interlacciato (come Angel, o 24).
|
|
1238 </para>
|
|
1239
|
|
1240 <para>
|
|
1241 Si consiglia vivamente di leggere la sezione su
|
|
1242 <link linkend="menc-feat-telecine">Come trattare il telecine e l'interlacciamento nei DVD NTSC</link>
|
|
1243 per imparare come gestire le varie possibilità.
|
|
1244 </para>
|
|
1245
|
|
1246 <para>
|
|
1247 Ciononostante, se stai principalmente rippando solo film, solitamente ti
|
|
1248 troverai di fronte a video a 24 fps progressivo o con telecine, nel qual caso
|
|
1249 puoi usare il filtro <option>pullup</option> <option>-vf
|
|
1250 pullup,softskip</option>.
|
|
1251 </para>
|
|
1252 </sect2>
|
|
1253
|
|
1254 <!-- ********** -->
|
|
1255
|
|
1256 <sect2 id="menc-feat-dvd-mpeg4-encoding-interlaced">
|
|
1257 <title>Codificare video interlacciato</title>
|
|
1258
|
|
1259 <para>
|
|
1260 Se il film che vuoi codificare è interlacciato (video NTSC o PAL) dovrai
|
|
1261 scegliere se vuoi de-interlacciare o no.
|
|
1262 Se da un lato de-interlacciare renderà il tuo filmato utilizzabile su
|
|
1263 schermi a scansione progressiva come monitor di computer o proiettori, porta
|
|
1264 con sé un costo: la frequenza dei campi di 50 o 60000/1001 campi al secondo
|
|
1265 viene dimezzata a 25 o 30000/1001 fotogrammi al secondo, e circa la metà delle
|
|
1266 informazioni nel tuo film saranno perdute, in scene con movimento significativo.
|
|
1267 </para>
|
|
1268
|
|
1269 <para>
|
|
1270 Per di più, se stai codificando puntando ad alta qualità di archiviazione.
|
|
1271 si consiglia di non de-interlacciare.
|
|
1272 Puoi sempre de-interlacciare il film durante la riproduzione attraverso
|
|
1273 dispositivi a scansione progressiva.
|
|
1274 La potenza dei computer attuali forza per i riproduttori l'utilizzo di un filtro
|
|
1275 di de-interlacciamento, che porta un leggero degrado dell'immagine.
|
|
1276 Ma i lettori del futuro saranno in grado di simulare lo schermo di una TV,
|
|
1277 de-interlacciando a piena frequenza di campi e interpolando 50 o 60000/1001
|
|
1278 fotogrammi interi al secondo dal video interlacciato
|
|
1279 </para>
|
|
1280
|
|
1281 <para>
|
|
1282 Bisogna porre speciale attenzione quando si lavora con video interlacciato:
|
|
1283 </para>
|
|
1284
|
|
1285 <orderedlist>
|
|
1286 <listitem><para>
|
|
1287 Altezza e scostamento del taglio devono essere multipli di 4.
|
|
1288 </para></listitem>
|
|
1289 <listitem><para>
|
|
1290 Qualsiasi ridimensionamento verticale va fatto in modalità interlacciata.
|
|
1291 </para></listitem>
|
|
1292 <listitem><para>
|
|
1293 I filtri di post elaborazione e di rimozione disturbo potrebbero non
|
|
1294 funzionare come ci si aspetta a meno che tu non ponga particolare attenzione
|
|
1295 per farli lavorare su un campo per volta, e possono rovinare il video quando
|
|
1296 usati in modo non corretto.
|
|
1297 </para></listitem>
|
|
1298 </orderedlist>
|
|
1299
|
|
1300 <para>
|
|
1301 Tenendo a mente queste cose, ecco il nostro primo esempio:
|
|
1302 <screen>
|
|
1303 mencoder <replaceable>capture.avi</replaceable> -mc 0 -oac lavc -ovc lavc -lavcopts \
|
|
1304 vcodec=mpeg2video:vbitrate=6000:ilme:ildct:acodec=mp2:abitrate=224
|
|
1305 </screen>
|
|
1306 Nota le opzioni <option>ilme</option> e <option>ildct</option>.
|
|
1307 </para>
|
|
1308 </sect2>
|
|
1309
|
|
1310 <!-- ********** -->
|
|
1311
|
|
1312 <sect2 id="menc-feat-dvd-mpeg4-av-sync">
|
25449
|
1313 <title>Note sulla sincronizzazione Audio/Video</title>
|
|
1314
|
|
1315 <para>
|
|
1316 Gli algoritmi di sincronizzazione audio/video di
|
|
1317 <application>MEncoder</application> sono stati progettati con l'intento di
|
|
1318 recuperare file con sincronia danneggiata.
|
|
1319 In alcuni casi tuttavia, possono generare inutili duplicazioni o scarti di
|
|
1320 fotogrammi, e possibilmente leggera desincronia A/V quando vengono usati con
|
|
1321 sorgenti buone (i problemi di sincronizzazione A/V accadono solo se elabori o
|
|
1322 copi la traccia audio mentre transcodifichi il video, il che è decisamente
|
|
1323 consigliato).
|
|
1324 Perciò potresti dover passare ad una sincronizzazione di base con l'opzione
|
|
1325 <option>-mc 0</option>, o metterla nel tuo file di configurazione
|
|
1326 <systemitem>~/.mplayer/mencoder</systemitem>, sempre che tu stia lavorando con
|
|
1327 buone sorgenti (DVD, acquisizione TV, rip MPEG-4 ad alta qualità, etc) e non
|
|
1328 con file ASF/RM/MOV rovinati.
|
|
1329 </para>
|
|
1330
|
|
1331 <para>
|
|
1332 Se vuoi proteggerti ulteriormente da strani salti e duplicazioni di fotogrammi,
|
|
1333 puoi usare sia <option>-mc 0</option> che <option>-noskip</option>.
|
|
1334 Questo disabiliterà <emphasis>tutte</emphasis> le sincronizzazioni A/V, e
|
|
1335 copierà i fotogrammi uno ad uno, perciò è inutilizzabile se stai usando dei
|
|
1336 filtri che aggiungono o rimuovono arbitrariamente fotogrammi, ovvero se il
|
|
1337 tuo file sorgente ha una frequenza fotogrammi non costante!
|
|
1338 Quindi l'utilizzo di <option>-noskip</option> in linea di massima si sconsiglia.
|
|
1339 </para>
|
|
1340
|
|
1341 <para>
|
|
1342 Si sa che la cosiddetta codifica audio in "tre passi", che
|
|
1343 <application>MEncoder</application> gestisce, può causare desincronizzazione
|
|
1344 A/V.
|
|
1345 Il che capiterà prontamente se viene usata insieme con alcuni filtri, per cui
|
|
1346 si consiglia di <emphasis>non</emphasis> usare la modalità audio a tre passi.
|
|
1347 Questa caratteristica viene lasciata solo per finalità di compatibilità e
|
|
1348 per utenti esperti che sanno quando sia adeguato usarla e quando no.
|
|
1349 Se non hai mai sentito parlar prima della modalità a tre passi, dimenticati
|
|
1350 di averla anche solo sentita nominare!
|
|
1351 </para>
|
|
1352
|
|
1353 <para>
|
|
1354 Ci sono anche stati rapporti di desincronia A/V codificando con
|
|
1355 <application>MEncoder</application> da stdin.
|
|
1356 Non farlo! Usa sempre come ingresso un file o un dispositivo CD/DVD/etc.
|
25279
|
1357 </para>
|
|
1358 </sect2>
|
|
1359
|
|
1360 <!-- ********** -->
|
|
1361
|
|
1362 <sect2 id="menc-feat-dvd-mpeg4-codec">
|
25449
|
1363 <title>Scegliere il codec video</title>
|
|
1364
|
|
1365 <para>
|
|
1366 Quale possa esere il miglior codec video dipende da molti fattori, come
|
|
1367 dimensione, qualità, possibilita di farne lo streaming, usabilit, diffusione,
|
|
1368 alcuni dei quali dipendono fortemente dai gusti personali e dalle variabili
|
|
1369 tecniche in gioco.
|
25279
|
1370 </para>
|
|
1371 <itemizedlist>
|
|
1372 <listitem>
|
|
1373 <para>
|
25449
|
1374 E' abbastanza facile da capire che i codec più recenti sono fatti per
|
|
1375 aumentare qualità e compressione.
|
|
1376 Quindi gli autori di questa guida e moltra altra gente suggeriscono che non
|
|
1377 potete sbagliare
|
25279
|
1378 <footnote id='fn-menc-feat-dvd-mpeg4-codec-cpu'><para>
|
25449
|
1379 Fai comunque attenzione: la decodifica di video MPEG-4 AVC a risoluzione DVD
|
|
1380 richiede una macchina veloce (per es. un Pentium 4 oltre 1.5GHz o un Pentium
|
|
1381 M superiore a 1GHz).
|
25279
|
1382 </para></footnote>
|
25449
|
1383 quando scegliete un qualche codec MPEG-4 AVC come
|
|
1384 <systemitem class="library">x264</systemitem> piuttosto che un codec MPEG-4
|
|
1385 ASP come l'MPEG-4 di <systemitem class="library">libavcodec</systemitem> o
|
25279
|
1386 <systemitem class="library">Xvid</systemitem>.
|
25449
|
1387 (Per sviluppatori avenzati di codec potrebbe essere interessante leggere
|
|
1388 l'opinione di Michael Niedermayer sul
|
|
1389 "<ulink url="http://guru.multimedia.cx/?p=10">perché MPEG-4 ASP faccia schifo</ulink>"
|
|
1390 (in inglese).)
|
|
1391 Analogamente dovresti ottenere una miglior qualità usando MPEG-4 ASP rispetto
|
|
1392 a quella ottenuta con codec MPEG-2.
|
25279
|
1393 </para>
|
|
1394
|
|
1395 <para>
|
25449
|
1396 Tuttavia, i codec più recenti che sono sotto pesante sviluppo possono avere
|
|
1397 problemi che non sono ancora stati scoperti, e che possono rovinare una
|
|
1398 codifica.
|
|
1399 Questo è semplicemente il contrappasso per usare la tecnologia di punta.
|
25279
|
1400 </para>
|
|
1401
|
|
1402 <para>
|
25449
|
1403 Inoltre iniziare ad utilizzare un codec nuovo richiede l'utilizzo di un po'
|
|
1404 di tempo per familiarizzare con le sue opzioni, affinché tu sappia cosa
|
|
1405 impostare per ottenere la qualità dell'immagine voluta.
|
25279
|
1406 </para>
|
|
1407 </listitem>
|
|
1408
|
|
1409 <listitem><para>
|
25449
|
1410 <emphasis role="bold">Compatibilità Hardware</emphasis>:
|
|
1411 Solitamente ci va un po' di tempo prima che i lettori da tavolo incomincino ad
|
|
1412 includere il supporto per il video codec più recente.
|
|
1413 Il risultato è che la maggior parte legge MPEG-1 (come i VCD, XVCD e KVCD),
|
|
1414 MPEG-2 (come DVD, SVCD e KVCD) e MPEG-4 ASP (come DivX,
|
|
1415 LMP4 di <systemitem class="library">libavcodec</systemitem> e
|
25279
|
1416 <systemitem class="library">Xvid</systemitem>)
|
25449
|
1417 (attenzione: solitamente non sono gestite tutte le caratteristiche
|
|
1418 MPEG-4 ASP).
|
|
1419 Fai per favore riferimento alle specifiche tecniche del tuo lettore (ove
|
|
1420 disponibili) o cerca su internet per ulteriori informazioni.
|
25279
|
1421 </para></listitem>
|
|
1422
|
|
1423 <listitem>
|
|
1424 <para>
|
25449
|
1425 <emphasis role="bold">Miglior qualità per tempo di codifica</emphasis>:
|
|
1426 Codec che sono in giro da parecchio tempo (come MPEG-4 di
|
|
1427 <systemitem class="library">libavcodec</systemitem> e
|
|
1428 <systemitem class="library">Xvid</systemitem>) sono spesso molto ottimizzati
|
|
1429 con ogni tipo di algoritmo furbo e codice SIMD in assembly.
|
|
1430 Per questo tendono a fornire il miglior rapporto tra qualità e tempo di
|
|
1431 codifica. Tuttavia, possono avere delle opzioni avanzate che, quando
|
|
1432 abilitate, rendono la codifica molto lenta fornendo poco guadagno.
|
25279
|
1433 </para>
|
|
1434
|
|
1435 <para>
|
25449
|
1436 Se stai cercando di incrementare la velocità dovresti cercare di non
|
|
1437 modificare troppo le impostazioni di default del codec video (anche se
|
|
1438 dovresti comunque provare le altre opzioni che sono citate in altre sezioni
|
|
1439 di questa guida).
|
25279
|
1440 </para>
|
|
1441
|
|
1442 <para>
|
25449
|
1443 Puoi tenere in considerazione anche la scelta di un codec che possa eseguire
|
|
1444 elaborazioni multi-thread, anche se ciò è utile solo per utenti di macchine
|
|
1445 con più di una CPU.
|
|
1446 MPEG-4 di <systemitem class="library">libavcodec</systemitem> lo permette,
|
|
1447 ma il guadagno in velocità è limitato, e c'è un leggere effetto negativo
|
|
1448 sulla qualità dell'immagine.
|
|
1449 La codifica multi-thread di <systemitem class="library">Xvid</systemitem>,
|
|
1450 attivata dall'opzione <option>threads</option>, può essere usata per
|
|
1451 accelerare la velocità di codifica — tipicamente di circa il 40-60%
|
|
1452 — con poco se non nessun degrado dell'immagine.
|
|
1453 Anche <systemitem class="library">x264</systemitem> permette la codifica in
|
|
1454 multi-thread, la quale attualmente velocizza la codifica del 94% per core di
|
|
1455 CPU mentre abbassa il PSNR tra 0.005dB e 0.01dB, con impostazioni tipiche.
|
25279
|
1456 </para>
|
|
1457 </listitem>
|
|
1458
|
|
1459 <listitem>
|
|
1460 <para>
|
25449
|
1461 <emphasis role="bold">Gusto personale</emphasis>:
|
|
1462 Qui è dove capita l'irrazionale: per la stessa ragione per cui alcuni
|
|
1463 restano attaccati a DivX 3 per anni, mentre nuovi codec stanno
|
|
1464 facendo meraviglie, alcuni personaggi preferiranno
|
|
1465 <systemitem class="library">Xvid</systemitem> o MPEG-4 di
|
|
1466 <systemitem class="library">libavcodec</systemitem> a
|
25279
|
1467 <systemitem class="library">x264</systemitem>.
|
|
1468 </para>
|
|
1469 <para>
|
25449
|
1470 Dovresti prendere le tue decisioni; non prendere consigli da gente che
|
|
1471 fanno giuramenti su un codec.
|
|
1472 Prendi alcuni pezzi di esempio da sorgenti grezze e compara le diverse
|
|
1473 opzioni di codifica e di codec per trovare quello che ti garba di più.
|
|
1474 Il miglior codec è quello che riesci a gestire al meglio, e quello che ai
|
|
1475 tuoi occhi e sul tuo schermo si vede meglio.
|
25279
|
1476 <footnote id='fn-menc-feat-dvd-mpeg4-codec-playback'><para>
|
25449
|
1477 La stessa codifica potrebbe non apparire uguale sullo schermo di qualcun
|
|
1478 altro o se riprodotta con un decodificatore differente, perciò controlla
|
|
1479 i tuoi risultati riproducendoli in diverse condizioni.
|
25279
|
1480 </para></footnote>!
|
|
1481 </para>
|
|
1482 </listitem>
|
|
1483 </itemizedlist>
|
|
1484
|
|
1485 <para>
|
25449
|
1486 Fai per favore riferimento alla sezione
|
|
1487 <link linkend="menc-feat-selecting-codec">selezionare codec e formati contenitore</link>
|
|
1488 per avere un elenco dei codec usabili.
|
25279
|
1489 </para>
|
|
1490 </sect2>
|
|
1491
|
|
1492 <!-- ********** -->
|
|
1493
|
|
1494 <sect2 id="menc-feat-dvd-mpeg4-audio">
|
|
1495 <title>Audio</title>
|
|
1496
|
|
1497 <para>
|
25449
|
1498 L'audio è un problema di decisamente più facile soluzione: se ti interessa la
|
|
1499 qualità, lascialo semplicemente com'è.
|
|
1500 Anche i flussi AC-3 5.1 sono al massimo a 448Kbit/s, e ne valgono ogni bit.
|
|
1501 Potresti esser tentato di trascodificare l'audio in Vorbis ad alta qualità, ma
|
|
1502 solo perché a tutt'oggi non hai un decodificatore AC-3 pass-through ciò non
|
|
1503 significa che non ne avrai uno in futuro. Assicura un futuro ai tuoi rip da DVD
|
|
1504 preservando il flusso in AC-3.
|
|
1505 Puoi mantenere il flusso AC-3 anche copiandolo direttamente nel flusso video
|
|
1506 <link linkend="menc-feat-mpeg4">durante la codifica</link>.
|
|
1507 Puoi anche estrarre il flusso AC-3 al fine di farne il mux in contenitori come
|
|
1508 NUT o Matroska.
|
25279
|
1509 <screen>
|
25449
|
1510 mplayer <replaceable>file_sorgente.vob</replaceable> -aid 129 -dumpaudio -dumpfile <replaceable>suono.ac3</replaceable>
|
25279
|
1511 </screen>
|
25449
|
1512 effettuerà il dump della traccia audio numero 129 dal file
|
|
1513 <replaceable>file_sorgente.vob</replaceable> nel file
|
|
1514 <replaceable>suono.ac3</replaceable> (NB: i file VOB da DVD spesso usano una
|
|
1515 numerazione dell'audio diversa, il che significa che la traccia audio 129 è la
|
|
1516 seconda traccia del file).
|
|
1517 </para>
|
|
1518
|
|
1519 <para>
|
|
1520 Alcune volte invece, non hai davvero altra scelta se non comprimere
|
|
1521 ulteriormente il suono per poter usare più bit per il video.
|
|
1522 La maggior parte delle persone sceglie di comprimere l'audio con i codec MP3
|
|
1523 ovvero Vorbis.
|
|
1524 Mentre quest'ultimo è un codec decisamente efficiente per lo spazio, MP3 è
|
|
1525 meglio supportato dai lettori da tavolo, anche se la situazione sta cambiando.
|
|
1526 </para>
|
|
1527
|
|
1528 <para>
|
|
1529 <emphasis>Non</emphasis> usare <option>-nosound</option> mentre codifichi un
|
|
1530 file con dell'audio, anche se farai la codifica e il mux dell'audio
|
|
1531 separatamente in seguito.
|
|
1532 Anche se potesse andar bene in casi ideali, facilmente usare
|
|
1533 <option>-nosound</option> nasconderà alcuni problemi nelle tue impostazioni di
|
|
1534 codifica sulla riga comando.
|
|
1535 In altre parole mantenere la colonna sonora durante la codifica ti assicura,
|
|
1536 a patto che tu non veda messaggi del tipo
|
|
1537 <quote>Troppi pacchetti audio nel buffer</quote>, di ottenere un'adeguata
|
|
1538 sincronizzazione.
|
|
1539 </para>
|
|
1540
|
|
1541 <para>
|
|
1542 Devi fare in modo che <application>MEncoder</application> processi il suono.
|
|
1543 Puoi per esempio copiare la colonna sonora originaria durante la codifica con
|
|
1544 <option>-oac copy</option>, o convertirla in un "leggero" PCM WAV mono a 4 kHz
|
|
1545 con <option>-oac pcm -channels 1 -srate 4000</option>.
|
|
1546 In caso contrario in alcuni casi verrà generato un file video che sarà
|
|
1547 desincronizzato con l'audio.
|
|
1548 Casi del genere sono quelli in cui il numero dei fotogrammi video nel file di
|
|
1549 origine non corrisponde alla lunghezza totale dei fotogrammi audio oppure
|
|
1550 ogniqualvolta vi siano delle discontinuità/splice in cui mancano o ci sono
|
|
1551 fotogrammi audio in più.
|
|
1552 Il modo giusto di gestire questo tipo di problemi è inserire del silenzio o
|
|
1553 tagliare l'audio in quei punti.
|
|
1554 Tuttavia <application>MPlayer</application> non è in grado di farlo, per cui se
|
|
1555 fai il demux dell'audio AC-3 e lo codifichi con un'altro programma (o ne fai il
|
|
1556 dump in PCM con <application>MPlayer</application>), gli splice rimarranno
|
|
1557 sbagliati e l'unico modo per correggerli è scartare/duplicare fotogrammi video
|
|
1558 nel punto di splice.
|
|
1559 Fintantochè <application>MEncoder</application> vede l'audio mentre codifica il
|
|
1560 video, può eseguire questo scarto/duplicazione (che solitamente è OK, dato che
|
|
1561 capita con scene nere o cambi scena), ma se <application>MEncoder</application>
|
|
1562 non vede l'audio, processerà i fotogrammi così come sono e alla fine non
|
|
1563 corrisponderanno al flusso audio finale quando per esempio inserirai i flussi
|
|
1564 audio e video dentro a un file Matroska.
|
|
1565 </para>
|
|
1566
|
|
1567 <para>
|
|
1568 Prima di tutto dovrai convertire l'audio DVD in un file WAV che il codec audio
|
|
1569 possa usare come ingresso.
|
|
1570 Per esempio:
|
25279
|
1571 <screen>
|
25449
|
1572 mplayer <replaceable>file_sorgente.vob</replaceable> -ao pcm:file=<replaceable>suono_destinazione.wav</replaceable> \
|
25279
|
1573 -vc dummy -aid 1 -vo null
|
|
1574 </screen>
|
25449
|
1575 eseguirà il dump della seconda traccia audio dal file
|
|
1576 <replaceable>file_sorgente.vob</replaceable> sul file
|
|
1577 <replaceable>suono_destinazione.wav</replaceable>.
|
|
1578 Potresti voler normalizzare il suono prima della codifica, visto che le tracce
|
|
1579 audio dei DVD spesso sono registrate a volumi bassi.
|
|
1580 Puoi usare per esempio lo strumento <application>normalize</application>, che
|
|
1581 è disponibile nella maggior parte delle distribuzioni.
|
|
1582 Se stai usando Windows, lo stesso mestiere lo può fare uno strumento tipo
|
|
1583 <application>BeSweet</application>.
|
|
1584 Effettuerai la compressione in Vorbis ovvero in MP3.
|
|
1585
|
|
1586 Per esempio:
|
|
1587 <screen>oggenc -q1 <replaceable>suono_destinazione.wav</replaceable></screen>
|
|
1588 codificherà <replaceable>suono_destinazione.wav</replaceable> con qualità
|
|
1589 di codifica 1, che equivale circa a 80Kb/s, ed è la qualità minima in cui
|
|
1590 dovresti codificare se ti interessa la qualità.
|
|
1591 Fai per favore attenzione che attualmente <application>MEncoder</application>
|
|
1592 non è in grado di fare il mux di tracce audio Vorbis nel file di uscita,
|
|
1593 perché gestisce solo contenitori AVI e MPEG in uscita, ognuno dei quali può
|
|
1594 portare a problemi di sincronizzazione audio/video durante la riproduzione con
|
|
1595 alcuni lettori quando il file AVI contiene flussi audio VBR come Vorbis.
|
|
1596 Non preoccuparti, questa documentazione ti mostrerà come tu possa farlo
|
|
1597 comunque con programmi di terze parti.
|
25279
|
1598 </para>
|
|
1599 </sect2>
|
|
1600
|
|
1601 <!-- ********** -->
|
|
1602
|
|
1603 <sect2 id="menc-feat-dvd-mpeg4-muxing">
|
|
1604 <title>Muxing</title>
|
|
1605
|
|
1606 <para>
|
26192
|
1607 Ora che hai codificato il tuo video, vorrai verosimilmente farne il mux in un
|
|
1608 contenitore di filmati con una o più tracce audio, come AVI, MPEG, Matroska o
|
|
1609 NUT.
|
|
1610 <application>MEncoder</application> è attualmente in grado di generare in modo
|
|
1611 nativo solo video in formati contenitore MPEG o AVI.
|
|
1612 Per esempio:
|
25279
|
1613 <screen>
|
26192
|
1614 mencoder -oac copy -ovc copy -o <replaceable>film_in_uscita.avi</replaceable> \
|
|
1615 -audiofile <replaceable>audio_in_ingresso.mp2</replaceable> <replaceable>video_in_ingresso.avi</replaceable>
|
25279
|
1616 </screen>
|
26192
|
1617 Questo miscelerà i file video <replaceable>video_in_ingresso.avi</replaceable>
|
|
1618 e audio <replaceable>audio_in_ingresso.mp2</replaceable> nel file AVI
|
|
1619 <replaceable>film_in_uscita.avi</replaceable>.
|
|
1620 Questo comando funziona con audio MPEG-1 layer I, II e III (più comunemente
|
|
1621 conosciuto come MP3), WAV e qualche altro formato audio.
|
|
1622 </para>
|
|
1623
|
|
1624 <para>
|
|
1625 <application>MEncoder</application> vanta un supporto sperimentale per
|
|
1626 <systemitem class="library">libavformat</systemitem>, che è una libreria del
|
|
1627 progetto FFmpeg che può fare il mux e il demux di svariati contenitori.
|
|
1628 Per esempio:
|
25279
|
1629 <screen>
|
26192
|
1630 mencoder -oac copy -ovc copy -o <replaceable>film_di_uscita.asf</replaceable> -audiofile <replaceable>audio_in_ingresso.mp2</replaceable> \
|
|
1631 <replaceable>video_in_ingresso.avi</replaceable> -of lavf -lavfopts format=asf
|
25279
|
1632 </screen>
|
26192
|
1633 Questo farà la stessa cosa dell'esempio precedente, trannce che il contenitore
|
|
1634 di uscita sarà ASF.
|
|
1635 Per favore nota che questo supporto è altamente sperimentale (ma migliora di
|
|
1636 giorno in giorno), e funzionerà solo se hai compilato
|
|
1637 <application>MPlayer</application> con il supporto per
|
|
1638 <systemitem class="library">libavformat</systemitem> abilitato (il che
|
|
1639 significa che una versione precompilata nella maggior parte dei casi non
|
|
1640 funzionerà).
|
25279
|
1641 </para>
|
|
1642
|
|
1643
|
|
1644 <sect3 id="menc-feat-dvd-mpeg4-muxing-filter-issues">
|
26192
|
1645 <title>Migliorare il mux e l'affidabilità di sincronizzazione A/V</title>
|
|
1646
|
|
1647 <para>
|
|
1648 Potresti avere dei seri problemi di sincronizzazione cercando di fare il mux
|
|
1649 del tuo video con alcune tracce audio, indipendentemente da come tu corregga il
|
|
1650 ritardo audio, non otterrai mai una sincronia corretta.
|
|
1651 Ciò potrebbe succedere quando usi un qualche filtro video che scarti o duplichi
|
|
1652 alcuni fotogrammi, come il filtro di telecine inverso.
|
|
1653 Si consiglia vivamente di appendere il filtro video <option>harddup</option>
|
|
1654 alla fine della catena dei filtri, per evitare questo tipo di problema.
|
|
1655 </para>
|
|
1656
|
|
1657 <para>
|
|
1658 Senza <option>harddup</option>, se <application>MEncoder</application> vuole
|
|
1659 duplicare un fotogramma, chiede al muxer di mettere un segno sul contenitore
|
|
1660 affinché l'ultimo fotogramma venga mostrato di nuovo per mantenere la
|
|
1661 sincronia, senza scriverne effettivamente alcuno.
|
|
1662 Con <option>harddup</option>, <application>MEncoder</application> farà
|
|
1663 semplicemente passare di nuovo l'ultimo fotogramma nella catena di filtri.
|
|
1664 Questo significa che il codificatore riceve <emphasis>esattamente</emphasis> lo
|
|
1665 stesso fotogramma due volte, e lo comprime.
|
|
1666 Ciò genera un file leggermente più grosso, ma non causerà problemi
|
|
1667 effettuando il demux o il remux in altri formati contenitore.
|
|
1668 </para>
|
|
1669
|
|
1670 <para>
|
|
1671 Potresti non avere altra scelta che usare <option>harddup</option> con formati
|
|
1672 contenitore che non siano così legati a <application>MEncoder</application>
|
|
1673 come quelli gestiti attraverso
|
|
1674 <systemitem class="library">libavformat</systemitem>, e che possano non gestire
|
|
1675 la duplicazione fotogrammi a livello contenitore.
|
25279
|
1676 </para>
|
|
1677 </sect3>
|
|
1678
|
|
1679
|
|
1680 <sect3 id="menc-feat-dvd-mpeg4-muxing-avi-limitations">
|
26192
|
1681 <title>Limitazioni del contenitore AVI</title>
|
|
1682
|
|
1683 <para>
|
|
1684 Anche se AVI è il formato contenitore più ampiamente gestito dopo MPEG-1, ha
|
|
1685 anche molti gravi inconvenienti.
|
|
1686 Forse il più ovvio è lo spreco di banda.
|
|
1687 Per ogni blocco del file AVI, 24 byte sono sprecati per intestazione e indice.
|
|
1688 Questo porta a poco più di 5 MB per ora, o 1-2.5% di dimensione supplementare
|
|
1689 per un film da 700 MB. Potrebbe non sembrare poi così tanto, ma potrebbe far
|
|
1690 la differenza tra poter utilizzare 700 oppure 714 kbit/sec per il video, e ogni
|
|
1691 bit è importante per la qualità.
|
|
1692 </para>
|
|
1693
|
|
1694 <para>
|
|
1695 Oltre a questa grave inefficenza, AVI ha anche le grandi limitazioni che
|
|
1696 seguono:
|
25279
|
1697 </para>
|
|
1698
|
|
1699 <orderedlist>
|
|
1700 <listitem><para>
|
26192
|
1701 Può essere immagazzinato solo contenuto a fps costanti. Questo è decisamente
|
|
1702 limitante se il materiale di origine che vuoi codificare è contenuto misto,
|
|
1703 per esempio un misto di video NTSC e film.
|
|
1704 Ci sono invero alcuni trucchi che possono essere usati per salvare negli AVI
|
|
1705 contenuto a frequenza di fotogrammi mista, ma aumentano il (già immenso)
|
|
1706 spreco di banda di cinque volte o giù di lì e quindi non sono pratici.
|
25279
|
1707 </para></listitem>
|
|
1708 <listitem><para>
|
26192
|
1709 L'audio nei file AVI deve essere a bitrate costante (CBR) o a dimensione di
|
|
1710 fotogramma fissa (per es. tutti i fotogrammi decodificano lo stesso numero di
|
|
1711 campioni).
|
|
1712 Sfortunatamente, il codec più efficente, Vorbis, non ha alcuna delle suddette
|
|
1713 caratteristiche.
|
|
1714 Se decidi di salvare il tuo film in AVI, dovrai perciò usare un codec meno
|
|
1715 efficente, come MP3 o AC-3.
|
25279
|
1716 </para></listitem>
|
|
1717 </orderedlist>
|
|
1718
|
|
1719 <para>
|
26192
|
1720 Detto tutto ciò, <application>MEncoder</application> non gestisce attualmente
|
|
1721 la codifica in uscita a fps variabile o la codifica in Vorbis.
|
|
1722 Quindi non noterai le limitazioni su citate se
|
|
1723 <application>MEncoder</application> è l'unico strumento che userai per produrre
|
|
1724 le tue codifiche.
|
|
1725 Tuttavia è possibile usare <application>MEncoder</application> solo per la
|
|
1726 codifica del video, e poi utilizzare strumenti di terze parti per codificare
|
|
1727 l'audio e farne il mux in un altro formato contenitore.
|
25279
|
1728 </para>
|
|
1729 </sect3>
|
|
1730
|
|
1731
|
|
1732 <sect3 id="menc-feat-dvd-mpeg4-muxing-matroska">
|
26192
|
1733 <title>Mux nel contenitore Matroska</title>
|
|
1734
|
|
1735 <para>
|
|
1736 Matroska è un formato contenitore libero, a standard aperti, che punta ad
|
|
1737 offrire molte caratteristiche avanzate, che contenitori più vecchi come AVI non
|
|
1738 sono in grado di manipolare.
|
|
1739 Per esempio Matroska supporta contenuto audio a bitrate variabile (VBR),
|
|
1740 frequenza fotogrammi variabile (VFR), capitoli, file allegati, codice di
|
|
1741 gestione errori (EDC) e Codec A/V moderni come "Advanced Audio Coding" (AAC),
|
|
1742 "Vorbis" or "MPEG-4 AVC" (H.264), comparato al nulla gestito da AVI.
|
|
1743 </para>
|
|
1744
|
|
1745 <para>
|
|
1746 Gli strumenti necessari per creare file Matroska sono chiamati nel loro insieme
|
|
1747 <application>mkvtoolnix</application> e sono disponibili per la maggior parte
|
|
1748 delle piattaforme Unix, così come per <application>Windows</application>.
|
|
1749 Dato che Matroska è uno standard aperto, potresti trovare altri strumenti che
|
|
1750 ti tornino più utili, ma dato che mkvtoolnix è il più diffuso, ed è
|
|
1751 supportato dal team stesso di Matroska, illustreremo il suo solo utilizzo.
|
|
1752 </para>
|
|
1753
|
|
1754 <para>
|
|
1755 Probabilmente il modo più semplice di avvicinarsi a Matroska è utilizzare
|
|
1756 <application>MMG</application>, il frontend grafico fornito con
|
|
1757 <application>mkvtoolnix</application>, e seguire la <ulink url="http://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge-gui.html">guida della GUI di mkvmerge (mmg)</ulink>.
|
|
1758 </para>
|
|
1759
|
|
1760 <para>
|
|
1761 Puoi anche fare il mux dei file audio e video usando la riga comando:
|
25279
|
1762 <screen>
|
26192
|
1763 mkvmerge -o <replaceable>destinazione.mkv</replaceable> <replaceable>video_sorgente.avi</replaceable> <replaceable>audio_sorgente1.mp3</replaceable> <replaceable>audio_sorgente2.ac3</replaceable>
|
25279
|
1764 </screen>
|
26192
|
1765 Questo unirà il file video <replaceable>video_sorgente.avi</replaceable> e i
|
|
1766 due file audio <replaceable>audio_sorgente1.mp3</replaceable> e
|
|
1767 <replaceable>audio_sorgente2.ac3</replaceable> nel file Matroska
|
|
1768 <replaceable>destinazione.mkv</replaceable>.
|
|
1769 Matroska, come detto precedentemente, è in grado di far molto più di questo,
|
|
1770 come tracce audio multiple (inclusa una fine sincronia audio/video), capitoli,
|
|
1771 sottotitoli, salti, etc...
|
|
1772 Fai per favore riferimento alla documentazione di queste applicazioni per
|
|
1773 maggiori delucidazioni.
|
25279
|
1774 </para>
|
|
1775 </sect3>
|
|
1776 </sect2>
|
|
1777 </sect1>
|
|
1778
|
|
1779
|
|
1780 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
1781
|
|
1782
|
|
1783 <sect1 id="menc-feat-telecine">
|
26192
|
1784 <title>Come trattare telecine e interlacciamento nei DVD NTSC</title>
|
25279
|
1785
|
|
1786 <sect2 id="menc-feat-telecine-intro">
|
26192
|
1787 <title>Introduzione</title>
|
25279
|
1788
|
|
1789 <formalpara>
|
26192
|
1790 <title>Cos'è telecine?</title>
|
|
1791 <para>
|
|
1792 Se non comprendi molto quello che è scritto in questo documento, leggi la
|
|
1793 <ulink url="http://en.wikipedia.org/wiki/Telecine">definizione di telecine su Wikipedia</ulink>
|
|
1794 (<ulink url="http://en.wikipedia.org/wiki/Telecine">pagina inglese</ulink>).
|
|
1795 E' una descrizione comprensibile e ragionevolmente completa di cosa si indichi
|
|
1796 con telecine.
|
25279
|
1797 </para></formalpara>
|
|
1798
|
|
1799 <formalpara>
|
26192
|
1800 <title>Una nota riguardo i numeri.</title>
|
|
1801 <para>
|
|
1802 Molti documenti, inclusa la guida su indicata, fanno riferimento al valore dei
|
|
1803 campi per secondo del video NTSC come 59.94 e i valori corrispondenti di
|
|
1804 fotogrammi al secondo come 29.97 (con telecine e interlacciamento) e 23.976
|
|
1805 (per il progressivo). Per semplicità alcune documentazioni arrotondano tali
|
|
1806 cifre a 60, 30 e 24.
|
25279
|
1807 </para></formalpara>
|
|
1808
|
|
1809 <para>
|
26192
|
1810 Strettamente parlando, tutti questi numeri sono approssimati. Il video NTSC in
|
|
1811 bianco e nero era esattamente 60 campi al secondo, ma successivamente venne
|
|
1812 scelto 60000/1001 per incastrare i dati del colore e rimanere compatibili con
|
|
1813 le televisioni bianco e nero contemporanee. Anche il video NTSC digitale (come
|
|
1814 quello sui DVD) è a 60000/1001 campi al secondo. Da ciò discende che il video
|
|
1815 interlacciato e telecine è 30000/1001 fotogrammi al secondo; il video
|
|
1816 progressivo è 24000/1001 fotogrammi al secondo.
|
|
1817 </para>
|
|
1818
|
|
1819 <para>
|
|
1820 Precedenti versioni della documentazioni di <application>MEncoder</application>
|
|
1821 a molti post archiviati della mailig list fanno riferimento a 59.94, 29.97 e
|
|
1822 23.976.
|
|
1823 Tutta la documentazioni di <application>MEncoder</application> è stata
|
|
1824 aggiornata per usare i valori in frazione, e anche tu dovresti usare questi.
|
|
1825 </para>
|
|
1826
|
|
1827 <para>
|
|
1828 <option>-ofps 23.976</option> è sbagliato.
|
|
1829 <option>-ofps 24000/1001</option> dovrebbe invece essere usato.
|
25279
|
1830 </para>
|
|
1831
|
|
1832 <formalpara>
|
26192
|
1833 <title>Come viene usato telecine.</title>
|
25279
|
1834 <para>
|
26192
|
1835 Tutto il video pensato per essere riprodotto su televisione NTSC deve essere a
|
|
1836 60000/1001 campi al secondo. I film per la TV e gli spettacoli sono spesso
|
|
1837 registrati direttamente a 60000/1001 campi al secondo, ma la stragrande
|
|
1838 maggioranzna dei film per cinema è filmata a 24 o 24000/1001 fotogrammi al
|
|
1839 secondo. Quando i film da cinema vengono masterizzati su DVD, il video viene
|
|
1840 quindi convertito per la televisione usando un processo chiamato telecine
|
|
1841 (o telecinema).
|
25279
|
1842 </para></formalpara>
|
|
1843
|
|
1844 <para>
|
26192
|
1845 Su un DVD il video non è praticamente mai memorizzato con 60000/1001 campi al
|
|
1846 secondo. Per un video che originariamente era 60000/1001, ogni coppia di campi
|
|
1847 viene combinata in un fotogramma, risultando in 30000/1001 fotogrammi al
|
|
1848 secondo. I lettori DVD hardware leggono quindi un parametro codificato nel
|
|
1849 flusso video pe rdeterminare se le linee pari o quelle dispari debbano formare
|
|
1850 il primo campo.
|
|
1851 </para>
|
|
1852
|
|
1853 <para>
|
|
1854 Solitamente il contenuto a 24000/1001 fotogrammi per secondi resta così com'è
|
|
1855 quando viene codificato per un DVD, e il lettore DVD deve eseguire il telecine
|
|
1856 al momento. Alcune volte invece, il video subisce il telecine
|
|
1857 <emphasis>prima</emphasis> di essere scritto su DVD; anche se in origine era a
|
|
1858 24000/1001 fotogrammi al secondi, diventa 60000/1001 campi al secondo. Quando
|
|
1859 viene memorizzato su DVD, le coppie di campi vengono assemblate per formare
|
|
1860 30000/1001 fotogrammi al secondo.
|
|
1861 </para>
|
|
1862
|
|
1863 <para>
|
|
1864 Guardando i singoli fotogrammi generati da video a 60000/1001 campi al secondo,
|
|
1865 che sia telecine o no, l'interlacciamento è chiaramente visibile ovunque vi sia
|
|
1866 del movimento, dato che un campo (diciamo le linee pari) rappresenta un istante
|
|
1867 nel tempo 1/(60000/1001) secondi dopo l'altro. Riprodurre video interlacciato
|
|
1868 su un computer risulta brutto sia perché il monitor ha una risoluzione maggiore
|
|
1869 sia perché il video viene mostrato un fotogramma dopo l'altro invece che un
|
|
1870 campo dopo l'altro.
|
25279
|
1871 </para>
|
|
1872
|
|
1873 <itemizedlist>
|
26192
|
1874 <title>Note:</title>
|
25279
|
1875 <listitem><para>
|
26192
|
1876 Questa sezione si applica solo ai DVD NTSC, e non a quelli PAL.
|
25279
|
1877 </para></listitem>
|
|
1878 <listitem><para>
|
26192
|
1879 Le righe di esempio per <application>MEncoder</application> proposte nella
|
|
1880 documentazione <emphasis role="bold">non</emphasis> sono pensate per un
|
|
1881 utilizzo reale. Sono solo quelle minimali richieste per codificare la
|
|
1882 relativa categoria di video. Come fare buoni rip di DVD o configurare bene
|
|
1883 <systemitem class="library">libavcodec</systemitem> per la massima qualità
|
|
1884 non è lo scopo di questa documentazione.
|
25279
|
1885 </para></listitem>
|
|
1886 <listitem><para>
|
26192
|
1887 Ci sono alcune note a piè di pagina specifiche di questa guida, così
|
|
1888 indicate:
|
25279
|
1889 <link linkend="menc-feat-telecine-footnotes">[1]</link>
|
|
1890 </para></listitem>
|
|
1891 </itemizedlist>
|
|
1892 </sect2>
|
|
1893
|
|
1894 <!-- ********** -->
|
|
1895
|
|
1896 <sect2 id="menc-feat-telecine-ident">
|
26253
|
1897 <title>Come scoprire il tipo di video che possiedi</title>
|
25279
|
1898
|
|
1899 <sect3 id="menc-feat-telecine-ident-progressive">
|
26827
|
1900 <title>Progressivo</title>
|
26253
|
1901
|
|
1902 <para>
|
|
1903 Il video progressivo è stato originariamente filmato a 24000/1001 fps, e
|
|
1904 memorizzato sul DVD senza modifica alcuna.
|
|
1905 </para>
|
|
1906
|
|
1907 <para>
|
|
1908 Quando riproduci un DVD progressivo con <application>MPlayer</application>,
|
|
1909 <application>MPlayer</application> emette la riga seguente appena il video
|
|
1910 inizia la riproduzione:
|
25279
|
1911 <screen>
|
|
1912 demux_mpg: 24000/1001 fps progressive NTSC content detected, switching framerate.
|
|
1913 </screen>
|
26253
|
1914 Da qui in poi, demux_mpg non dovrebbe mai comunicare di aver trovato
|
|
1915 "30000/1001 fps NTSC content" (contenuto NTSC a 30000/1001 fps).
|
|
1916 </para>
|
|
1917
|
|
1918 <para>
|
|
1919 Quando guardi video progressivo, non dovresti mai vedere alcuna interlacciatura.
|
|
1920 Fai tuttavia attenzione, poiché alcune volte c'è una piccola parte in telecine
|
|
1921 infilata dove non te la aspetteresti. Ho trovato alcuni DVD di spettacoli
|
|
1922 televisivi che hanno un secondo di telecine ad ogni cambio di scena, o anche in
|
|
1923 momenti casuali. Una volta ho guardato un DVD che aveva una prima parte
|
|
1924 progressiva e la seconda in telecine. Se vuoi esserne
|
|
1925 <emphasis>davvero</emphasis> certo, devi controllare tutto il video:
|
25279
|
1926 <screen>mplayer dvd://1 -nosound -vo null -benchmark</screen>
|
|
1927 Using <option>-benchmark</option> makes
|
26253
|
1928 L'utilizzo di <option>-benchmark</option> fa sì che
|
|
1929 <application>MPlayer</application> riproduca il filmato il più velocemente
|
|
1930 possibile; tuttavia, in dipendenza dal tuo hardware, può metterci un po'.
|
|
1931 Ogni volta che demux_mpg segnala un cambio nella frequenza fotogrammi
|
|
1932 (framerate), la linea immediatamente sopra ti dirà il tempo ove è cambiata.
|
|
1933 </para>
|
|
1934
|
|
1935 <para>
|
|
1936 Alcune volte il video progressivo sui DVD viene indicato come "soft-telecine"
|
|
1937 perché è fatto in modo che il lettore DVD esegua il telecine.
|
25279
|
1938 </para>
|
|
1939 </sect3>
|
|
1940
|
|
1941
|
|
1942 <sect3 id="menc-feat-telecine-ident-telecined">
|
26253
|
1943 <title>Telecine</title>
|
|
1944
|
|
1945 <para>
|
|
1946 Il video in telecine è stato filmato in origine a 24000/1001, ma ha subito il
|
|
1947 telecine <emphasis>prima</emphasis> di essere scritto sul DVD.
|
|
1948 </para>
|
|
1949
|
|
1950 <para>
|
|
1951 Quando <application>MPlayer</application> riproduce video in telecine non
|
|
1952 segnala (mai) alcun cambio di framerate.
|
|
1953 </para>
|
|
1954
|
|
1955 <para>
|
|
1956 Guardado un video in telecine, noterai artefatti che sembrano "lampeggiare":
|
|
1957 appaiono e scompaiono ripetutamente.
|
|
1958 Puoi notarlo meglio facendo quello che segue
|
25279
|
1959 <orderedlist>
|
|
1960 <listitem><screen>mplayer dvd://1</screen></listitem>
|
|
1961 <listitem><para>
|
26253
|
1962 Ricerca una parte con movimento.
|
25279
|
1963 </para></listitem>
|
|
1964 <listitem><para>
|
26253
|
1965 Usa il tasto <keycap>.</keycap> per avanzare di un fotogramma per volta.
|
25279
|
1966 </para></listitem>
|
|
1967 <listitem><para>
|
26253
|
1968 Guarda il pattern dei fotogrammi che paiono interlacciati e di quelli
|
|
1969 progressivi. Se il pattern che vedi è PPPII,PPPII,PPPII,... allora il video
|
|
1970 è in telecine. Se vedi qualche altro pattern, allora il video può aver
|
|
1971 subito il telecine attraverso qualche metodo strano;
|
|
1972 <application>MEncoder</application> può effettuare la conversione senza
|
|
1973 perdita da telecine non standard a progressivo. Se non vedi alcun pattern,
|
|
1974 allora molto probabilmente è interlacciato.
|
25279
|
1975 </para></listitem>
|
|
1976 </orderedlist>
|
|
1977 </para>
|
|
1978
|
|
1979 <para>
|
26253
|
1980 Alcune volte il video in telecine sui DVD viene indicato come "hard-telecine".
|
|
1981 Dato che l'hard-telecine è già a 60000/1001 campi al secondi, il lettore DVD
|
|
1982 riproduce il video senza elaborazione alcuna.
|
|
1983 </para>
|
|
1984
|
|
1985 <para>
|
|
1986 Un altro modo per scoprire se la tua sorgente è in telecine o no è riprodurla
|
|
1987 con le opzioni <option>-vf pullup</option> e <option>-v</option> da riga
|
|
1988 comando per vedere come <option>pullup</option> relaziona i fotogrammi.
|
|
1989 Se la sorgente è in telecine, dovresti vedere sulla console un pattern 3:2 con
|
|
1990 <systemitem>0+.1.+2</systemitem> e <systemitem>0++1</systemitem> che si
|
|
1991 alternano.
|
|
1992 Questa tecnica ha il vantaggio di evitare di guardare la sorgente per doverla
|
|
1993 identificare, il che può tornare utile se vuoi automatizzare la procedura di
|
|
1994 codifica ovvero se vuoi eseguire tale procedura in remoto su una connessione
|
|
1995 lenta.
|
25279
|
1996 </para>
|
|
1997 </sect3>
|
|
1998
|
|
1999
|
|
2000 <sect3 id="menc-feat-telecine-ident-interlaced">
|
26253
|
2001 <title>Interlacciato</title>
|
|
2002
|
|
2003 <para>
|
|
2004 Il video interlacciato è stato filmato in origine a 60000/1001 campi al
|
|
2005 secondo ed è memorizzato sul DVD a 30000/1001 fotogrammi al secondo. L'effetto
|
|
2006 di interlacciatura (spesso chimato "combing") è un risultato di coppie di
|
|
2007 campi che vengono combinate in fotogrammi. Ogni campo è spostato di
|
|
2008 1/(60000/1001) secondi e quando vengono mostrati contemporaneamente la
|
|
2009 differenza si nota.
|
|
2010 </para>
|
|
2011
|
|
2012 <para>
|
|
2013 Come per il video in telecine, <application>MPlayer</application> non dovrebbe
|
|
2014 mai segnalare alcun cambio di framerete, riproducendo contenuto interlacciato.
|
|
2015 </para>
|
|
2016
|
|
2017 <para>
|
|
2018 Quando guardi attentamente un video interlacciato avanzando fotogramma per
|
|
2019 fotogramma col tasto <keycap>.</keycap>, noterai che ogni singolo fotogramma è
|
|
2020 interlacciato.
|
25279
|
2021 </para>
|
|
2022 </sect3>
|
|
2023
|
|
2024
|
|
2025 <sect3 id="menc-feat-telecine-ident-mixedpt">
|
26253
|
2026 <title>Progressivo e telecine miscelati</title>
|
|
2027
|
|
2028 <para>
|
|
2029 Tutto il contenuto di un video "progressivo e telecine miscelato" è stato
|
|
2030 in origine filmato a 24000/1001 fotogrammi al secondo, ma alcune parti alla
|
|
2031 fine hanno subito il telecine.
|
|
2032 </para>
|
|
2033
|
|
2034 <para>
|
|
2035 Quando <application>MPlayer</application> riproduce questa tipologia di video
|
|
2036 salta (spesso ripetutamente) avanti e indietro tra "30000/1001 fps NTSC" e
|
|
2037 "24000/1001 fps progressive NTSC". Controlla le ultime righe dell'emissione di
|
|
2038 <application>MPlayer</application> per vedere questi messaggi.
|
|
2039 </para>
|
|
2040
|
|
2041 <para>
|
|
2042 Dovresti controllare le sezioni "30000/1001 fps NTSC" per assicurarti che siano
|
|
2043 davvero in telecine e non solamente interlacciate.
|
25279
|
2044 </para>
|
|
2045 </sect3>
|
|
2046
|
|
2047
|
|
2048 <sect3 id="menc-feat-telecine-ident-mixedpi">
|
26253
|
2049 <title>Progressivo e interlacciato miscelati</title>
|
|
2050
|
|
2051 <para>
|
|
2052 Nei contenuti con video "progressivo e interlacciato miscelati", il video
|
|
2053 progressivo e interlacciato sono mescolati tra loro.
|
|
2054 </para>
|
|
2055
|
|
2056 <para>
|
|
2057 Questa categoria è decisamente simile a "progressivo e telecine miscelato",
|
|
2058 fino a quando non controlli le parti a 30000/1001 fps e scopri che non hanno
|
|
2059 il pattern del telecine.
|
25279
|
2060 </para>
|
|
2061 </sect3>
|
|
2062 </sect2>
|
|
2063
|
|
2064 <!-- ********** -->
|
|
2065
|
|
2066 <sect2 id="menc-feat-telecine-encode">
|
26811
|
2067 <title>Come codificare ciascuna categoria</title>
|
|
2068 <para>
|
|
2069 Come menzionato all'inizio, le linee di esempio qui sotto per
|
|
2070 <application>MEncoder</application> <emphasis role="bold">non</emphasis> sono
|
|
2071 pensate per essere usate davvero; dimostrano solamente i parametri minimi per
|
|
2072 codificare correttamente ciascuna categoria.
|
25279
|
2073 </para>
|
|
2074
|
|
2075
|
|
2076 <sect3 id="menc-feat-telecine-encode-progressive">
|
26811
|
2077 <title>Progressivo</title>
|
|
2078 <para>
|
|
2079 Il video progressivo non richiede particolari filtri per la codifica. L'unico
|
26827
|
2080 parametrioche devi assicurarti di usare è <option>-ofps 24000/1001</option>.
|
|
2081 Se non lo usi, <application>MEncoder</application> cercherà di codificare a
|
|
2082 30000/1001 fps e duplicherà i fotogrammi.
|
25279
|
2083 </para>
|
|
2084
|
|
2085 <para>
|
|
2086 <screen>mencoder dvd://1 -oac copy -ovc lavc -ofps 24000/1001</screen>
|
|
2087 </para>
|
|
2088
|
|
2089 <para>
|
26811
|
2090 Spesso e volentieri capita che un video che sembra progressivo contenga anche
|
|
2091 alcune brevi parti di telecine miscelate. A meno che tu non sia sicuro,
|
|
2092 conviene trattare il video come
|
|
2093 <link linkend="menc-feat-telecine-encode-mixedpt">progressivo e telecine miscelati</link>.
|
26827
|
2094 Il calo di prestazioni è piccolo
|
25279
|
2095 <link linkend="menc-feat-telecine-footnotes">[3]</link>.
|
|
2096 </para>
|
|
2097 </sect3>
|
|
2098
|
|
2099
|
|
2100 <sect3 id="menc-feat-telecine-encode-telecined">
|
26811
|
2101 <title>Telecine</title>
|
|
2102
|
|
2103 <para>
|
26827
|
2104 Il telecine può essere invertito per ricavare il contenuto originario a
|
26811
|
2105 24000/1001 usando un processo conosciuto come telecine-inverso.
|
26827
|
2106 <application>MPlayer</application> include vari filtri per ottenere ciò;
|
|
2107 il filtro migliore, <option>pullup</option>, è descritto nella sezione
|
26811
|
2108 <link linkend="menc-feat-telecine-encode-mixedpt">progressivo e telecine
|
|
2109 miscelati</link>.
|
25279
|
2110 </para>
|
|
2111 </sect3>
|
|
2112
|
|
2113
|
|
2114 <sect3 id="menc-feat-telecine-encode-interlaced">
|
26811
|
2115 <title>Interlacciato</title>
|
|
2116
|
|
2117 <para>
|
26827
|
2118 Nella maggior parte dei casi reali non è possibile ricavare un video
|
26811
|
2119 progressivo completo da contenuto interlacciato. L'unico modo di farlo senza
|
26827
|
2120 perdere metà della risoluzione verticale è raddoppiare il framerate e provare
|
26811
|
2121 ad "indovinare" quello che forma le linee corrispondenti per ogni campo
|
|
2122 (questo ha delle controindicazioni - vedi il metodo 3).
|
25279
|
2123 </para>
|
|
2124
|
|
2125 <orderedlist>
|
|
2126 <listitem><para>
|
26811
|
2127 Codifica il video in forma interlacciata. Normalmente l'interlacciatura fa a
|
26827
|
2128 pugni con l'abilità del codificatore di comprimere bene, ma
|
26811
|
2129 <systemitem class="library">libavcodec</systemitem> ha due parametri
|
|
2130 appositamente per gestire un pochino meglio il video interlacciato:
|
|
2131 <option>ildct</option> e <option>ilme</option>. Inoltre viene caldamente
|
|
2132 consigliato l'utilizzo di <option>mbd=2</option>
|
26827
|
2133 <link linkend="menc-feat-telecine-footnotes">[2] </link> poiché
|
|
2134 codificherà i macroblocchi come non interlacciati in posti dove non c'è
|
26811
|
2135 movimento. Nota che <option>-ofps</option> qui NON serve.
|
25279
|
2136 <screen>mencoder dvd://1 -oac copy -ovc lavc -lavcopts ildct:ilme:mbd=2</screen>
|
|
2137 </para></listitem>
|
|
2138 <listitem><para>
|
26811
|
2139 Usa un filtro di de-interlacciatura prima della codifica. Ci sono vari filtri
|
|
2140 disponibili tra cui scegliere, ognuno dei quali con i suoi pro e i suoi
|
|
2141 contro. Controlla <option>mplayer -pphelp</option> e
|
26827
|
2142 <option>mplayer -vf help</option> per vedere cosa c'è disponibile
|
26811
|
2143 (fa in grep per "deint"), leggi il <ulink url="http://guru.multimedia.cx/deinterlacing-filters/">confronto tra filtri di deinterlacciatura
|
|
2144 (Deinterlacing filters comparison)</ulink> di Michael Niedermayer, e cerca
|
|
2145 nelle <ulink url="http://www.mplayerhq.hu/design7/mailing_lists.html">
|
|
2146 mailing list di MPlayer</ulink> per trovare discussioni riguardanti i vari
|
|
2147 filtri.
|
|
2148 Di nuovo il framerate non cambia, indi niente <option>-ofps</option>.
|
|
2149 Inoltre, la deinterlacciatura dovrebbe essere eseguita dopo il ritaglio
|
|
2150 <link linkend="menc-feat-telecine-footnotes">[1]</link> e prima del
|
|
2151 ridimensionamento.
|
25279
|
2152 <screen>mencoder dvd://1 -oac copy -vf yadif -ovc lavc</screen>
|
|
2153 </para></listitem>
|
|
2154 <listitem><para>
|
26811
|
2155 Sfortunatamente, quest'opzione non funziona bene con
|
|
2156 <application>MEncoder</application>; dovrebbe funzionar bene con
|
|
2157 <application>MEncoder G2</application>, ma ancora non esiste. Puoi subire
|
26827
|
2158 dei crash. Tuttavia l'obiettivo di <option>-vf tfields</option> è di
|
26811
|
2159 generare un fotogramma completo da ogni campo, portando il framerate a
|
26827
|
2160 60000/1001. Il vantaggio di questo approccio è che non viene mai perso alcun
|
26811
|
2161 dato; d'altro canto, dato che ogni fotogramma deriva da un solo campo, le
|
|
2162 righe mancanti devono essere interpolate in qualche modo. Non ci sono metodi
|
26827
|
2163 veramente validi per ricreare i dati mancanti, quindi il risultato apparirà
|
26811
|
2164 molto simile a quando vengono usati dei filtri di deinterlacciatura.
|
26827
|
2165 La generazione delle righe che mancano è foriera di altri problemi,
|
26811
|
2166 solamente per il fatto che i dati sono raddoppiati. Conseguentemente per
|
26827
|
2167 mantenere la qualità si rendono necessari bitrate più elevati e viene usata
|
26811
|
2168 una maggior potenza di CPU sia per la codifica che la decodifica.
|
|
2169 tfields ha varie opzioni su come generare le righe mancanti di ogni
|
|
2170 fotogramma. Se usi questo metodo, fai riferimento al manuale, e scegli
|
26827
|
2171 l'opzione che può andar meglio per il tuo materiale sorgente. Fai attenzione
|
26811
|
2172 che usando <option>tfields</option> <emphasis role="bold">devi</emphasis>
|
|
2173 specificare sia <option>-fps</option> che <option>-ofps</option> pari al
|
|
2174 doppio della sorgente originaria.
|
25279
|
2175 <screen>
|
|
2176 mencoder dvd://1 -oac copy -vf tfields=2 -ovc lavc \
|
|
2177 -fps 60000/1001 -ofps 60000/1001<!--
|
|
2178 --></screen>
|
|
2179 </para></listitem>
|
|
2180 <listitem><para>
|
26811
|
2181 Se conti di ridurre drasticamente le dimensioni puoi estrarre e decodificare
|
26827
|
2182 sono uno dei due campi. Perderai di sicuro metà della risoluzione verticale,
|
|
2183 ma se pensi di ridurla almeno a 1/2 dell'originale, la perdità non sarà poi
|
|
2184 molta. Il risultato sarà un file progressivo a 30000/1001 fotogrammi per
|
|
2185 secondo. La procedura è utilizzare <option>-vf field</option>, poi crop
|
26811
|
2186 <link linkend="menc-feat-telecine-footnotes">[1]</link> e scale in modo
|
|
2187 corretto. Ricorda che dovrai correggere scale per compensare la risoluzione
|
|
2188 verticale dimezzata.
|
25279
|
2189 <screen>mencoder dvd://1 -oac copy -vf field=0 -ovc lavc</screen>
|
|
2190 </para></listitem>
|
|
2191 </orderedlist>
|
|
2192 </sect3>
|
|
2193
|
|
2194
|
|
2195 <sect3 id="menc-feat-telecine-encode-mixedpt">
|
26811
|
2196 <title>Progressivo e telecine miscelati</title>
|
|
2197
|
|
2198 <para>
|
|
2199 Per poter portare un video progressivo e telecine miscelati in un video
|
|
2200 completamente progressivo, le parti in telecine devono essere passate in
|
26827
|
2201 telecine inverso. Ci son tre modi per ottenere ciò, e sono descritti qui sotto.
|
26811
|
2202 Nota che dovresti <emphasis role="bold">sempre</emphasis> effettuare il
|
|
2203 telecine inverso prima di ogni ridimensionamento; a meno che tu non sappia
|
26827
|
2204 davvero cosa tu stia facendo, applica il telecine inverso anche prima del ritaglio (crop)
|
|
2205 <link linkend="menc-feat-telecine-footnotes">[1]</link>.
|
|
2206 In questo caso serve <option>-ofps 24000/1001</option> perché il video in
|
|
2207 uscita sarà a 24000/1001 fotogrammi al secondo.
|
25279
|
2208 </para>
|
|
2209
|
|
2210 <itemizedlist>
|
|
2211 <listitem><para>
|
|
2212 <option>-vf pullup</option> is designed to inverse-telecine
|
|
2213 telecined material while leaving progressive data alone. In order to
|
|
2214 work properly, <option>pullup</option> <emphasis role="bold">must</emphasis>
|
|
2215 be followed by the <option>softskip</option> filter or
|
|
2216 else <application>MEncoder</application> will crash.
|
|
2217 <option>pullup</option> is, however, the cleanest and most
|
|
2218 accurate method available for encoding both telecine and
|
|
2219 "mixed progressive and telecine".
|
|
2220 <screen>
|
|
2221 mencoder dvd://1 -oac copy -vf pullup,softskip
|
|
2222 -ovc lavc -ofps 24000/1001<!--
|
|
2223 --></screen>
|
|
2224 </para></listitem>
|
|
2225 <listitem><para>
|
|
2226 An older method
|
|
2227 is to, rather than inverse-telecine the telecined parts, telecine
|
|
2228 the non-telecined parts and then inverse-telecine the whole
|
|
2229 video. Sound confusing? softpulldown is a filter that goes through
|
|
2230 a video and makes the entire file telecined. If we follow
|
|
2231 softpulldown with either <option>detc</option> or
|
|
2232 <option>ivtc</option>, the final result will be entirely
|
|
2233 progressive. <option>-ofps 24000/1001</option> is needed.
|
|
2234 <screen>
|
|
2235 mencoder dvd://1 -oac copy -vf softpulldown,ivtc=1 -ovc lavc -ofps 24000/1001
|
|
2236 </screen>
|
|
2237 </para></listitem>
|
|
2238
|
|
2239 <listitem><para>
|
|
2240 I have not used <option>-vf filmdint</option> myself, but here is what
|
|
2241 D Richard Felker III has to say:
|
|
2242
|
|
2243 <blockquote><para>It is OK, but IMO it tries to deinterlace rather
|
|
2244 than doing inverse telecine too often (much like settop DVD
|
|
2245 players & progressive TVs) which gives ugly flickering and
|
|
2246 other artifacts. If you are going to use it, you at least need to
|
|
2247 spend some time tuning the options and watching the output first
|
|
2248 to make sure it is not messing up.
|
|
2249 </para></blockquote>
|
|
2250 </para></listitem>
|
|
2251 </itemizedlist>
|
|
2252 </sect3>
|
|
2253
|
|
2254
|
|
2255 <sect3 id="menc-feat-telecine-encode-mixedpi">
|
|
2256 <title>Mixed progressive and interlaced</title>
|
|
2257
|
|
2258 <para>
|
|
2259 There are two options for dealing with this category, each of
|
|
2260 which is a compromise. You should decide based on the
|
|
2261 duration/location of each type.
|
|
2262 </para>
|
|
2263
|
|
2264 <itemizedlist>
|
|
2265 <listitem>
|
|
2266 <para>
|
|
2267 Treat it as progressive. The interlaced parts will look interlaced,
|
|
2268 and some of the interlaced fields will have to be dropped, resulting
|
|
2269 in a bit of uneven jumpiness. You can use a postprocessing filter if
|
|
2270 you want to, but it may slightly degrade the progressive parts.
|
|
2271 </para>
|
|
2272
|
|
2273 <para>
|
|
2274 This option should definitely not be used if you want to eventually
|
|
2275 display the video on an interlaced device (with a TV card, for
|
|
2276 example). If you have interlaced frames in a 24000/1001 frames per
|
|
2277 second video, they will be telecined along with the progressive
|
|
2278 frames. Half of the interlaced "frames" will be displayed for three
|
|
2279 fields' duration (3/(60000/1001) seconds), resulting in a flicking
|
|
2280 "jump back in time" effect that looks quite bad. If you
|
|
2281 even attempt this, you <emphasis role="bold">must</emphasis> use a
|
|
2282 deinterlacing filter like <option>lb</option> or
|
|
2283 <option>l5</option>.
|
|
2284 </para>
|
|
2285
|
|
2286 <para>
|
|
2287 It may also be a bad idea for progressive display, too. It will drop
|
|
2288 pairs of consecutive interlaced fields, resulting in a discontinuity
|
|
2289 that can be more visible than with the second method, which shows
|
|
2290 some progressive frames twice. 30000/1001 frames per second interlaced
|
|
2291 video is already a bit choppy because it really should be shown at
|
|
2292 60000/1001 fields per second, so the duplicate frames do not stand out as
|
|
2293 much.
|
|
2294 </para>
|
|
2295
|
|
2296 <para>
|
|
2297 Either way, it is best to consider your content and how you intend to
|
|
2298 display it. If your video is 90% progressive and you never intend to
|
|
2299 show it on a TV, you should favor a progressive approach. If it is
|
|
2300 only half progressive, you probably want to encode it as if it is all
|
|
2301 interlaced.
|
|
2302 </para>
|
|
2303 </listitem>
|
|
2304
|
|
2305 <listitem><para>
|
|
2306 Treat it as interlaced. Some frames of the progressive parts will
|
|
2307 need to be duplicated, resulting in uneven jumpiness. Again,
|
|
2308 deinterlacing filters may slightly degrade the progressive parts.
|
|
2309 </para></listitem>
|
|
2310 </itemizedlist>
|
|
2311 </sect3>
|
|
2312 </sect2>
|
|
2313
|
|
2314 <!-- ********** -->
|
|
2315
|
|
2316 <sect2 id="menc-feat-telecine-footnotes">
|
|
2317 <title>Footnotes</title>
|
|
2318
|
|
2319 <orderedlist>
|
|
2320 <listitem>
|
|
2321 <formalpara>
|
|
2322 <title>About cropping:</title>
|
|
2323 <para>
|
|
2324 Video data on DVDs are stored in a format called YUV 4:2:0. In YUV
|
|
2325 video, luma ("brightness") and chroma ("color")
|
|
2326 are stored separately. Because the human eye is somewhat less
|
|
2327 sensitive to color than it is to brightness, in a YUV 4:2:0 picture
|
|
2328 there is only one chroma pixel for every four luma pixels. In a
|
|
2329 progressive picture, each square of four luma pixels (two on each
|
|
2330 side) has one common chroma pixel. You must crop progressive YUV
|
|
2331 4:2:0 to even resolutions, and use even offsets. For example,
|
|
2332 <option>crop=716:380:2:26</option> is OK but
|
|
2333 <option>crop=716:380:3:26 </option> is not.
|
|
2334 </para>
|
|
2335 </formalpara>
|
|
2336
|
|
2337 <para>
|
|
2338 When you are dealing with interlaced YUV 4:2:0, the situation is a
|
|
2339 bit more complicated. Instead of every four luma pixels in the
|
|
2340 <emphasis>frame</emphasis> sharing a chroma pixel, every four luma
|
|
2341 pixels in each <emphasis> field</emphasis> share a chroma
|
|
2342 pixel. When fields are interlaced to form a frame, each scanline is
|
|
2343 one pixel high. Now, instead of all four luma pixels being in a
|
|
2344 square, there are two pixels side-by-side, and the other two pixels
|
|
2345 are side-by-side two scanlines down. The two luma pixels in the
|
|
2346 intermediate scanline are from the other field, and so share a
|
|
2347 different chroma pixel with two luma pixels two scanlines away. All
|
|
2348 this confusion makes it necessary to have vertical crop dimensions
|
|
2349 and offsets be multiples of four. Horizontal can stay even.
|
|
2350 </para>
|
|
2351
|
|
2352 <para>
|
|
2353 For telecined video, I recommend that cropping take place after
|
|
2354 inverse telecining. Once the video is progressive you only need to
|
|
2355 crop by even numbers. If you really want to gain the slight speedup
|
|
2356 that cropping first may offer, you must crop vertically by multiples
|
|
2357 of four or else the inverse-telecine filter will not have proper data.
|
|
2358 </para>
|
|
2359
|
|
2360 <para>
|
|
2361 For interlaced (not telecined) video, you must always crop
|
|
2362 vertically by multiples of four unless you use <option>-vf
|
|
2363 field</option> before cropping.
|
|
2364 </para>
|
|
2365 </listitem>
|
|
2366
|
|
2367 <listitem><formalpara>
|
|
2368 <title>About encoding parameters and quality:</title>
|
|
2369 <para>
|
|
2370 Just because I recommend <option>mbd=2</option> here does not mean it
|
|
2371 should not be used elsewhere. Along with <option>trell</option>,
|
|
2372 <option>mbd=2</option> is one of the two
|
|
2373 <systemitem class="library">libavcodec</systemitem> options that
|
|
2374 increases quality the most, and you should always use at least those
|
|
2375 two unless the drop in encoding speed is prohibitive (e.g. realtime
|
|
2376 encoding). There are many other options to
|
|
2377 <systemitem class="library">libavcodec</systemitem> that increase
|
|
2378 encoding quality (and decrease encoding speed) but that is beyond
|
|
2379 the scope of this document.
|
|
2380 </para>
|
|
2381 </formalpara></listitem>
|
|
2382
|
|
2383 <listitem><formalpara>
|
|
2384 <title>About the performance of pullup:</title>
|
|
2385 <para>
|
|
2386 It is safe to use <option>pullup</option> (along with <option>softskip
|
|
2387 </option>) on progressive video, and is usually a good idea unless
|
|
2388 the source has been definitively verified to be entirely progressive.
|
|
2389 The performace loss is small for most cases. On a bare-minimum encode,
|
|
2390 <option>pullup</option> causes <application>MEncoder</application> to
|
|
2391 be 50% slower. Adding sound processing and advanced <option>lavcopts
|
|
2392 </option> overshadows that difference, bringing the performance
|
|
2393 decrease of using <option>pullup</option> down to 2%.
|
|
2394 </para>
|
|
2395 </formalpara></listitem>
|
|
2396 </orderedlist>
|
|
2397 </sect2>
|
|
2398 </sect1>
|
|
2399
|
|
2400
|
|
2401 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
2402
|
|
2403
|
|
2404 <sect1 id="menc-feat-enc-libavcodec">
|
|
2405 <title>Encoding with the <systemitem class="library">libavcodec</systemitem>
|
|
2406 codec family</title>
|
|
2407
|
|
2408 <para>
|
27831
|
2409 <systemitem class="library">libavcodec</systemitem>
|
25279
|
2410 provides simple encoding to a lot of interesting video and audio formats.
|
|
2411 You can encode to the following codecs (more or less up to date):
|
|
2412 </para>
|
|
2413
|
|
2414 <!-- ********** -->
|
|
2415
|
|
2416 <sect2 id="menc-feat-enc-libavcodec-video-codecs">
|
|
2417 <title><systemitem class="library">libavcodec</systemitem>'s
|
|
2418 video codecs</title>
|
|
2419
|
|
2420 <para>
|
|
2421 <informaltable frame="all">
|
|
2422 <tgroup cols="2">
|
|
2423 <thead>
|
|
2424 <row><entry>Video codec name</entry><entry>Description</entry></row>
|
|
2425 </thead>
|
|
2426 <tbody>
|
|
2427 <row>
|
|
2428 <entry>mjpeg</entry>
|
|
2429 <entry>Motion JPEG</entry>
|
|
2430 </row>
|
|
2431 <row>
|
|
2432 <entry>ljpeg</entry>
|
|
2433 <entry>lossless JPEG</entry>
|
|
2434 </row>
|
|
2435 <row>
|
|
2436 <entry>jpegls</entry>
|
|
2437 <entry>JPEG LS</entry>
|
|
2438 </row>
|
|
2439 <row>
|
|
2440 <entry>targa</entry>
|
|
2441 <entry>Targa image</entry>
|
|
2442 </row>
|
|
2443 <row>
|
|
2444 <entry>gif</entry>
|
|
2445 <entry>GIF image</entry>
|
|
2446 </row>
|
|
2447 <row>
|
|
2448 <entry>bmp</entry>
|
|
2449 <entry>BMP image</entry>
|
|
2450 </row>
|
|
2451 <row>
|
|
2452 <entry>png</entry>
|
|
2453 <entry>PNG image</entry>
|
|
2454 </row>
|
|
2455 <row>
|
|
2456 <entry>h261</entry>
|
|
2457 <entry>H.261</entry>
|
|
2458 </row>
|
|
2459 <row>
|
|
2460 <entry>h263</entry>
|
|
2461 <entry>H.263 </entry>
|
|
2462 </row>
|
|
2463 <row>
|
|
2464 <entry>h263p</entry>
|
|
2465 <entry>H.263+</entry>
|
|
2466 </row>
|
|
2467 <row>
|
|
2468 <entry>mpeg4</entry>
|
|
2469 <entry>ISO standard MPEG-4 (DivX, Xvid compatible)</entry>
|
|
2470 </row>
|
|
2471 <row>
|
|
2472 <entry>msmpeg4</entry>
|
|
2473 <entry>pre-standard MPEG-4 variant by MS, v3 (AKA DivX3)</entry>
|
|
2474 </row>
|
|
2475 <row>
|
|
2476 <entry>msmpeg4v2</entry>
|
|
2477 <entry>pre-standard MPEG-4 by MS, v2 (used in old ASF files)</entry>
|
|
2478 </row>
|
|
2479 <row>
|
|
2480 <entry>wmv1</entry>
|
|
2481 <entry>Windows Media Video, version 1 (AKA WMV7)</entry>
|
|
2482 </row>
|
|
2483 <row>
|
|
2484 <entry>wmv2</entry>
|
|
2485 <entry>Windows Media Video, version 2 (AKA WMV8)</entry>
|
|
2486 </row>
|
|
2487 <row>
|
|
2488 <entry>rv10</entry>
|
|
2489 <entry>RealVideo 1.0</entry>
|
|
2490 </row>
|
|
2491 <row>
|
|
2492 <entry>rv20</entry>
|
|
2493 <entry>RealVideo 2.0</entry>
|
|
2494 </row>
|
|
2495 <row>
|
|
2496 <entry>mpeg1video</entry>
|
|
2497 <entry>MPEG-1 video</entry>
|
|
2498 </row>
|
|
2499 <row>
|
|
2500 <entry>mpeg2video</entry>
|
|
2501 <entry>MPEG-2 video</entry>
|
|
2502 </row>
|
|
2503 <row>
|
|
2504 <entry>huffyuv</entry>
|
|
2505 <entry>lossless compression</entry>
|
|
2506 </row>
|
|
2507 <row>
|
|
2508 <entry>ffvhuff</entry>
|
|
2509 <entry>FFmpeg modified huffyuv lossless</entry>
|
|
2510 </row>
|
|
2511 <row>
|
|
2512 <entry>asv1</entry>
|
|
2513 <entry>ASUS Video v1</entry>
|
|
2514 </row>
|
|
2515 <row>
|
|
2516 <entry>asv2</entry>
|
|
2517 <entry>ASUS Video v2</entry>
|
|
2518 </row>
|
|
2519 <row>
|
|
2520 <entry>ffv1</entry>
|
|
2521 <entry>FFmpeg's lossless video codec</entry>
|
|
2522 </row>
|
|
2523 <row>
|
|
2524 <entry>svq1</entry>
|
|
2525 <entry>Sorenson video 1</entry>
|
|
2526 </row>
|
|
2527 <row>
|
|
2528 <entry>flv</entry>
|
|
2529 <entry>Sorenson H.263 used in Flash Video</entry>
|
|
2530 </row>
|
|
2531 <row>
|
|
2532 <entry>flashsv</entry>
|
|
2533 <entry>Flash Screen Video</entry>
|
|
2534 </row>
|
|
2535 <row>
|
|
2536 <entry>dvvideo</entry>
|
|
2537 <entry>Sony Digital Video</entry>
|
|
2538 </row>
|
|
2539 <row>
|
|
2540 <entry>snow</entry>
|
|
2541 <entry>FFmpeg's experimental wavelet-based codec</entry>
|
|
2542 </row>
|
|
2543 <row>
|
|
2544 <entry>zbmv</entry>
|
|
2545 <entry>Zip Blocks Motion Video</entry>
|
|
2546 </row>
|
|
2547 </tbody>
|
|
2548 </tgroup>
|
|
2549 </informaltable>
|
|
2550
|
|
2551 The first column contains the codec names that should be passed after the
|
|
2552 <literal>vcodec</literal> config,
|
|
2553 like: <option>-lavcopts vcodec=msmpeg4</option>
|
|
2554 </para>
|
|
2555
|
|
2556 <informalexample><para>
|
|
2557 An example with MJPEG compression:
|
|
2558 <screen>
|
|
2559 mencoder dvd://2 -o <replaceable>title2.avi</replaceable> -ovc lavc -lavcopts vcodec=mjpeg -oac copy
|
|
2560 </screen>
|
|
2561 </para></informalexample>
|
|
2562 </sect2>
|
|
2563
|
|
2564 <!-- ********** -->
|
|
2565
|
|
2566 <sect2 id="menc-feat-enc-libavcodec-audio-codecs">
|
|
2567 <title><systemitem class="library">libavcodec</systemitem>'s
|
|
2568 audio codecs</title>
|
|
2569
|
|
2570 <para>
|
|
2571 <informaltable frame="all">
|
|
2572 <tgroup cols="2">
|
|
2573 <thead>
|
|
2574 <row><entry>Audio codec name</entry><entry>Description</entry></row>
|
|
2575 </thead>
|
|
2576 <tbody>
|
|
2577 <row>
|
|
2578 <entry>mp2</entry>
|
|
2579 <entry>MPEG Layer 2</entry>
|
|
2580 </row>
|
|
2581 <row>
|
|
2582 <entry>ac3</entry>
|
|
2583 <entry>AC-3, AKA Dolby Digital</entry>
|
|
2584 </row>
|
|
2585 <row>
|
|
2586 <entry>adpcm_ima_wav</entry>
|
|
2587 <entry>IMA adaptive PCM (4 bits per sample, 4:1 compression)</entry>
|
|
2588 </row>
|
|
2589 <row>
|
|
2590 <entry>sonic</entry>
|
|
2591 <entry>experimental FFmpeg lossy codec</entry>
|
|
2592 </row>
|
|
2593 <row>
|
|
2594 <entry>sonicls</entry>
|
|
2595 <entry>experimental FFmpeg lossless codec</entry>
|
|
2596 </row>
|
|
2597 <row>
|
|
2598 <entry>vorbis</entry>
|
|
2599 <entry>Xiph Ogg Vorbis codec</entry>
|
|
2600 </row>
|
|
2601 <row>
|
|
2602 <entry>wmav1</entry>
|
|
2603 <entry>Windows Media Audio v1 codec</entry>
|
|
2604 </row>
|
|
2605 <row>
|
|
2606 <entry>wmav2</entry>
|
|
2607 <entry>Windows Media Audio v2 codec</entry>
|
|
2608 </row>
|
|
2609 </tbody>
|
|
2610 </tgroup>
|
|
2611 </informaltable>
|
|
2612
|
|
2613 The first column contains the codec names that should be passed after the
|
|
2614 <literal>acodec</literal> option, like: <option>-lavcopts acodec=ac3</option>
|
|
2615 </para>
|
|
2616
|
|
2617 <informalexample><para>
|
|
2618 An example with AC-3 compression:
|
|
2619 <screen>
|
|
2620 mencoder dvd://2 -o <replaceable>title2.avi</replaceable> -oac lavc -lavcopts acodec=ac3 -ovc copy
|
|
2621 </screen>
|
|
2622 </para></informalexample>
|
|
2623
|
|
2624 <para>
|
|
2625 Contrary to <systemitem class="library">libavcodec</systemitem>'s video
|
|
2626 codecs, its audio codecs do not make a wise usage of the bits they are
|
|
2627 given as they lack some minimal psychoacoustic model (if at all)
|
|
2628 which most other codec implementations feature.
|
|
2629 However, note that all these audio codecs are very fast and work
|
|
2630 out-of-the-box everywhere <application>MEncoder</application> has been
|
|
2631 compiled with <systemitem class="library">libavcodec</systemitem> (which
|
|
2632 is the case most of time), and do not depend on external libraries.
|
|
2633 </para>
|
|
2634 </sect2>
|
|
2635
|
|
2636 <!-- ********** -->
|
|
2637
|
|
2638 <sect2 id="menc-feat-dvd-mpeg4-lavc-encoding-options">
|
|
2639 <title>Encoding options of libavcodec</title>
|
|
2640
|
|
2641 <para>
|
|
2642 Ideally, you would probably want to be able to just tell the encoder to switch
|
|
2643 into "high quality" mode and move on.
|
|
2644 That would probably be nice, but unfortunately hard to implement as different
|
|
2645 encoding options yield different quality results depending on the source
|
|
2646 material. That is because compression depends on the visual properties of the
|
|
2647 video in question.
|
|
2648 For example, anime and live action have very different properties and
|
|
2649 thus require different options to obtain optimum encoding.
|
|
2650 The good news is that some options should never be left out, like
|
|
2651 <option>mbd=2</option>, <option>trell</option>, and <option>v4mv</option>.
|
|
2652 See below for a detailed description of common encoding options.
|
|
2653 </para>
|
|
2654
|
|
2655 <itemizedlist>
|
|
2656 <title>Options to adjust:</title>
|
|
2657 <listitem><para>
|
|
2658 <emphasis role="bold">vmax_b_frames</emphasis>: 1 or 2 is good, depending on
|
|
2659 the movie.
|
|
2660 Note that if you need to have your encode be decodable by DivX5, you
|
|
2661 need to activate closed GOP support, using
|
|
2662 <systemitem class="library">libavcodec</systemitem>'s <option>cgop</option>
|
|
2663 option, but you need to deactivate scene detection, which
|
|
2664 is not a good idea as it will hurt encode efficiency a bit.
|
|
2665 </para></listitem>
|
|
2666 <listitem><para>
|
|
2667 <emphasis role="bold">vb_strategy=1</emphasis>: helps in high-motion scenes.
|
|
2668 On some videos, vmax_b_frames may hurt quality, but vmax_b_frames=2 along
|
|
2669 with vb_strategy=1 helps.
|
|
2670 </para></listitem>
|
|
2671 <listitem><para>
|
|
2672 <emphasis role="bold">dia</emphasis>: motion search range. Bigger is better
|
|
2673 and slower.
|
|
2674 Negative values are a completely different scale.
|
|
2675 Good values are -1 for a fast encode, or 2-4 for slower.
|
|
2676 </para></listitem>
|
|
2677 <listitem><para>
|
|
2678 <emphasis role="bold">predia</emphasis>: motion search pre-pass.
|
|
2679 Not as important as dia. Good values are 1 (default) to 4. Requires preme=2
|
|
2680 to really be useful.
|
|
2681 </para></listitem>
|
|
2682 <listitem><para>
|
|
2683 <emphasis role="bold">cmp, subcmp, precmp</emphasis>: Comparison function for
|
|
2684 motion estimation.
|
|
2685 Experiment with values of 0 (default), 2 (hadamard), 3 (dct), and 6 (rate
|
|
2686 distortion).
|
|
2687 0 is fastest, and sufficient for precmp.
|
|
2688 For cmp and subcmp, 2 is good for anime, and 3 is good for live action.
|
|
2689 6 may or may not be slightly better, but is slow.
|
|
2690 </para></listitem>
|
|
2691 <listitem><para>
|
|
2692 <emphasis role="bold">last_pred</emphasis>: Number of motion predictors to
|
|
2693 take from the previous frame.
|
|
2694 1-3 or so help at little speed cost.
|
|
2695 Higher values are slow for no extra gain.
|
|
2696 </para></listitem>
|
|
2697 <listitem><para>
|
|
2698 <emphasis role="bold">cbp, mv0</emphasis>: Controls the selection of
|
|
2699 macroblocks. Small speed cost for small quality gain.
|
|
2700 </para></listitem>
|
|
2701 <listitem><para>
|
|
2702 <emphasis role="bold">qprd</emphasis>: adaptive quantization based on the
|
|
2703 macroblock's complexity.
|
|
2704 May help or hurt depending on the video and other options.
|
|
2705 This can cause artifacts unless you set vqmax to some reasonably small value
|
|
2706 (6 is good, maybe as low as 4); vqmin=1 should also help.
|
|
2707 </para></listitem>
|
|
2708 <listitem><para>
|
|
2709 <emphasis role="bold">qns</emphasis>: very slow, especially when combined
|
|
2710 with qprd.
|
|
2711 This option will make the encoder minimize noise due to compression
|
|
2712 artifacts instead of making the encoded video strictly match the source.
|
|
2713 Do not use this unless you have already tweaked everything else as far as it
|
|
2714 will go and the results still are not good enough.
|
|
2715 </para></listitem>
|
|
2716 <listitem><para>
|
|
2717 <emphasis role="bold">vqcomp</emphasis>: Tweak ratecontrol.
|
|
2718 What values are good depends on the movie.
|
|
2719 You can safely leave this alone if you want.
|
|
2720 Reducing vqcomp puts more bits on low-complexity scenes, increasing it puts
|
|
2721 them on high-complexity scenes (default: 0.5, range: 0-1. recommended range:
|
|
2722 0.5-0.7).
|
|
2723 </para></listitem>
|
|
2724 <listitem><para>
|
|
2725 <emphasis role="bold">vlelim, vcelim</emphasis>: Sets the single coefficient
|
|
2726 elimination threshold for luminance and chroma planes.
|
|
2727 These are encoded separately in all MPEG-like algorithms.
|
|
2728 The idea behind these options is to use some good heuristics to determine
|
|
2729 when the change in a block is less than the threshold you specify, and in
|
|
2730 such a case, to just encode the block as "no change".
|
|
2731 This saves bits and perhaps speeds up encoding. vlelim=-4 and vcelim=9
|
|
2732 seem to be good for live movies, but seem not to help with anime;
|
|
2733 when encoding animation, you should probably leave them unchanged.
|
|
2734 </para></listitem>
|
|
2735 <listitem><para>
|
|
2736 <emphasis role="bold">qpel</emphasis>: Quarter pixel motion estimation.
|
|
2737 MPEG-4 uses half pixel precision for its motion search by default,
|
|
2738 therefore this option comes with an overhead as more information will be
|
|
2739 stored in the encoded file.
|
|
2740 The compression gain/loss depends on the movie, but it is usually not very
|
|
2741 effective on anime.
|
|
2742 qpel always incurs a significant cost in CPU decode time (+25% in
|
|
2743 practice).
|
|
2744 </para></listitem>
|
|
2745 <listitem><para>
|
|
2746 <emphasis role="bold">psnr</emphasis>: does not affect the actual encoding,
|
|
2747 but writes a log file giving the type/size/quality of each frame, and
|
|
2748 prints a summary of PSNR (Peak Signal to Noise Ratio) at the end.
|
|
2749 </para></listitem>
|
|
2750 </itemizedlist>
|
|
2751
|
|
2752 <itemizedlist>
|
|
2753 <title>Options not recommended to play with:</title>
|
|
2754 <listitem><para>
|
|
2755 <emphasis role="bold">vme</emphasis>: The default is best.
|
|
2756 </para></listitem>
|
|
2757 <listitem><para>
|
|
2758 <emphasis role="bold">lumi_mask, dark_mask</emphasis>: Psychovisual adaptive
|
|
2759 quantization.
|
|
2760 You do not want to play with those options if you care about quality.
|
|
2761 Reasonable values may be effective in your case, but be warned this is very
|
|
2762 subjective.
|
|
2763 </para></listitem>
|
|
2764 <listitem><para>
|
|
2765 <emphasis role="bold">scplx_mask</emphasis>: Tries to prevent blocky
|
|
2766 artifacts, but postprocessing is better.
|
|
2767 </para></listitem>
|
|
2768 </itemizedlist>
|
|
2769 </sect2>
|
|
2770
|
|
2771 <!-- ********** -->
|
|
2772
|
|
2773 <sect2 id="menc-feat-mpeg4-lavc-example-settings">
|
|
2774 <title>Encoding setting examples</title>
|
|
2775
|
|
2776 <para>
|
|
2777 The following settings are examples of different encoding
|
|
2778 option combinations that affect the speed vs quality tradeoff
|
|
2779 at the same target bitrate.
|
|
2780 </para>
|
|
2781
|
|
2782 <para>
|
|
2783 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
2784 video sample, the target bitrate was 900kbps, and the machine was an
|
|
2785 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
2786 Each encoding setting features the measured encoding speed (in
|
|
2787 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
2788 high quality" setting.
|
|
2789 Please understand that depending on your source, your machine type
|
|
2790 and development advancements, you may get very different results.
|
|
2791 </para>
|
|
2792
|
|
2793 <para>
|
|
2794 <informaltable frame="all">
|
|
2795 <tgroup cols="4">
|
|
2796 <thead>
|
|
2797 <row>
|
|
2798 <entry>Description</entry>
|
|
2799 <entry>Encoding options</entry>
|
|
2800 <entry>speed (in fps)</entry>
|
|
2801 <entry>Relative PSNR loss (in dB)</entry>
|
|
2802 </row>
|
|
2803 </thead>
|
|
2804 <tbody>
|
|
2805 <row>
|
|
2806 <entry>Very high quality</entry>
|
|
2807 <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>
|
|
2808 <entry>6fps</entry>
|
|
2809 <entry>0dB</entry>
|
|
2810 </row>
|
|
2811 <row>
|
|
2812 <entry>High quality</entry>
|
|
2813 <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>
|
|
2814 <entry>15fps</entry>
|
|
2815 <entry>-0.5dB</entry>
|
|
2816 </row>
|
|
2817 <row>
|
|
2818 <entry>Fast</entry>
|
|
2819 <entry><option>vcodec=mpeg4:mbd=2:trell:v4mv:turbo</option></entry>
|
|
2820 <entry>42fps</entry>
|
|
2821 <entry>-0.74dB</entry>
|
|
2822 </row>
|
|
2823 <row>
|
|
2824 <entry>Realtime</entry>
|
|
2825 <entry><option>vcodec=mpeg4:mbd=2:turbo</option></entry>
|
|
2826 <entry>54fps</entry>
|
|
2827 <entry>-1.21dB</entry>
|
|
2828 </row>
|
|
2829 </tbody>
|
|
2830 </tgroup>
|
|
2831 </informaltable>
|
|
2832 </para>
|
|
2833 </sect2>
|
|
2834
|
|
2835 <!-- ********** -->
|
|
2836
|
|
2837 <sect2 id="custommatrices">
|
|
2838 <title>Custom inter/intra matrices</title>
|
|
2839
|
|
2840 <para>
|
|
2841 With this feature of
|
27831
|
2842 <systemitem class="library">libavcodec</systemitem>
|
25279
|
2843 you are able to set custom inter (I-frames/keyframes) and intra
|
|
2844 (P-frames/predicted frames) matrices. It is supported by many of the codecs:
|
|
2845 <systemitem>mpeg1video</systemitem> and <systemitem>mpeg2video</systemitem>
|
|
2846 are reported as working.
|
|
2847 </para>
|
|
2848
|
|
2849 <para>
|
|
2850 A typical usage of this feature is to set the matrices preferred by the
|
|
2851 <ulink url="http://www.kvcd.net/">KVCD</ulink> specifications.
|
|
2852 </para>
|
|
2853
|
|
2854 <para>
|
|
2855 The <emphasis role="bold">KVCD "Notch" Quantization Matrix:</emphasis>
|
|
2856 </para>
|
|
2857
|
|
2858 <para>
|
|
2859 Intra:
|
|
2860 <screen>
|
|
2861 8 9 12 22 26 27 29 34
|
|
2862 9 10 14 26 27 29 34 37
|
|
2863 12 14 18 27 29 34 37 38
|
|
2864 22 26 27 31 36 37 38 40
|
|
2865 26 27 29 36 39 38 40 48
|
|
2866 27 29 34 37 38 40 48 58
|
|
2867 29 34 37 38 40 48 58 69
|
|
2868 34 37 38 40 48 58 69 79
|
|
2869 </screen>
|
|
2870
|
|
2871 Inter:
|
|
2872 <screen>
|
|
2873 16 18 20 22 24 26 28 30
|
|
2874 18 20 22 24 26 28 30 32
|
|
2875 20 22 24 26 28 30 32 34
|
|
2876 22 24 26 30 32 32 34 36
|
|
2877 24 26 28 32 34 34 36 38
|
|
2878 26 28 30 32 34 36 38 40
|
|
2879 28 30 32 34 36 38 42 42
|
|
2880 30 32 34 36 38 40 42 44
|
|
2881 </screen>
|
|
2882 </para>
|
|
2883
|
|
2884 <para>
|
|
2885 Usage:
|
|
2886 <screen>
|
|
2887 mencoder <replaceable>input.avi</replaceable> -o <replaceable>output.avi</replaceable> -oac copy -ovc lavc \
|
|
2888 -lavcopts inter_matrix=...:intra_matrix=...
|
|
2889 </screen>
|
|
2890 </para>
|
|
2891
|
|
2892 <para>
|
|
2893 <screen>
|
|
2894 mencoder <replaceable>input.avi</replaceable> -ovc lavc -lavcopts \
|
|
2895 vcodec=mpeg2video:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,\
|
|
2896 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,\
|
|
2897 29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79\
|
|
2898 :inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,\
|
|
2899 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,\
|
|
2900 36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 -oac copy -o svcd.mpg
|
|
2901 </screen>
|
|
2902 </para>
|
|
2903 </sect2>
|
|
2904
|
|
2905 <!-- ********** -->
|
|
2906
|
|
2907 <sect2 id="menc-feat-dvd-mpeg4-example">
|
|
2908 <title>Example</title>
|
|
2909
|
|
2910 <para>
|
|
2911 So, you have just bought your shiny new copy of Harry Potter and the Chamber
|
|
2912 of Secrets (widescreen edition, of course), and you want to rip this DVD
|
|
2913 so that you can add it to your Home Theatre PC. This is a region 1 DVD,
|
|
2914 so it is NTSC. The example below will still apply to PAL, except you will
|
|
2915 omit <option>-ofps 24000/1001</option> (because the output framerate is the
|
|
2916 same as the input framerate), and of course the crop dimensions will be
|
|
2917 different.
|
|
2918 </para>
|
|
2919
|
|
2920 <para>
|
|
2921 After running <option>mplayer dvd://1</option>, we follow the process
|
|
2922 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
2923 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
2924 24000/1001 fps progressive video, which means that we need not use an inverse
|
|
2925 telecine filter, such as <option>pullup</option> or
|
|
2926 <option>filmdint</option>.
|
|
2927 </para>
|
|
2928
|
|
2929 <para id="menc-feat-dvd-mpeg4-example-crop">
|
|
2930 Next, we want to determine the appropriate crop rectangle, so we use the
|
|
2931 cropdetect filter:
|
|
2932 <screen>mplayer dvd://1 -vf cropdetect</screen>
|
|
2933 Make sure you seek to a fully filled frame (such as a bright scene,
|
|
2934 past the opening credits and logos), and
|
|
2935 you will see in <application>MPlayer</application>'s console output:
|
|
2936 <screen>crop area: X: 0..719 Y: 57..419 (-vf crop=720:362:0:58)</screen>
|
|
2937 We then play the movie back with this filter to test its correctness:
|
|
2938 <screen>mplayer dvd://1 -vf crop=720:362:0:58</screen>
|
|
2939 And we see that it looks perfectly fine. Next, we ensure the width and
|
|
2940 height are a multiple of 16. The width is fine, however the height is
|
|
2941 not. Since we did not fail 7th grade math, we know that the nearest
|
|
2942 multiple of 16 lower than 362 is 352.
|
|
2943 </para>
|
|
2944
|
|
2945 <para>
|
|
2946 We could just use <option>crop=720:352:0:58</option>, but it would be nice
|
|
2947 to take a little off the top and a little off the bottom so that we
|
|
2948 retain the center. We have shrunk the height by 10 pixels, but we do not
|
|
2949 want to increase the y-offset by 5-pixels since that is an odd number and
|
|
2950 will adversely affect quality. Instead, we will increase the y-offset by
|
|
2951 4 pixels:
|
|
2952 <screen>mplayer dvd://1 -vf crop=720:352:0:62</screen>
|
|
2953 Another reason to shave pixels from both the top and the bottom is that we
|
|
2954 ensure we have eliminated any half-black pixels if they exist. Note that if
|
|
2955 your video is telecined, make sure the <option>pullup</option> filter (or
|
|
2956 whichever inverse telecine filter you decide to use) appears in the filter
|
|
2957 chain before you crop. If it is interlaced, deinterlace before cropping.
|
|
2958 (If you choose to preserve the interlaced video, then make sure your
|
|
2959 vertical crop offset is a multiple of 4.)
|
|
2960 </para>
|
|
2961
|
|
2962 <para>
|
|
2963 If you are really concerned about losing those 10 pixels, you might
|
|
2964 prefer instead to scale the dimensions down to the nearest multiple of 16.
|
|
2965 The filter chain would look like:
|
|
2966 <screen>-vf crop=720:362:0:58,scale=720:352</screen>
|
|
2967 Scaling the video down like this will mean that some small amount of
|
|
2968 detail is lost, though it probably will not be perceptible. Scaling up will
|
|
2969 result in lower quality (unless you increase the bitrate). Cropping
|
|
2970 discards those pixels altogether. It is a tradeoff that you will want to
|
|
2971 consider for each circumstance. For example, if the DVD video was made
|
|
2972 for television, you might want to avoid vertical scaling, since the line
|
|
2973 sampling corresponds to the way the content was originally recorded.
|
|
2974 </para>
|
|
2975
|
|
2976 <para>
|
|
2977 On inspection, we see that our movie has a fair bit of action and high
|
|
2978 amounts of detail, so we pick 2400Kbit for our bitrate.
|
|
2979 </para>
|
|
2980
|
|
2981 <para>
|
|
2982 We are now ready to do the two pass encode. Pass one:
|
|
2983 <screen>
|
|
2984 mencoder dvd://1 -ofps 24000/1001 -oac copy -o <replaceable>Harry_Potter_2.avi</replaceable> -ovc lavc \
|
|
2985 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=1 \
|
|
2986 -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
|
|
2987 </screen>
|
|
2988 And pass two is the same, except that we specify <option>vpass=2</option>:
|
|
2989 <screen>
|
|
2990 mencoder dvd://1 -ofps 24000/1001 -oac copy -o <replaceable>Harry_Potter_2.avi</replaceable> -ovc lavc \
|
|
2991 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=2 \
|
|
2992 -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
|
|
2993 </screen>
|
|
2994 </para>
|
|
2995
|
|
2996 <para>
|
|
2997 The options <option>v4mv:mbd=2:trell</option> will greatly increase the
|
|
2998 quality at the expense of encoding time. There is little reason to leave
|
|
2999 these options out when the primary goal is quality. The options
|
|
3000 <option>cmp=3:subcmp=3</option> select a comparison function that
|
|
3001 yields higher quality than the defaults. You might try experimenting with
|
|
3002 this parameter (refer to the man page for the possible values) as
|
|
3003 different functions can have a large impact on quality depending on the
|
|
3004 source material. For example, if you find
|
|
3005 <systemitem class="library">libavcodec</systemitem> produces too much
|
|
3006 blocky artifacting, you could try selecting the experimental NSSE as
|
|
3007 comparison function via <option>*cmp=10</option>.
|
|
3008 </para>
|
|
3009
|
|
3010 <para>
|
|
3011 For this movie, the resulting AVI will be 138 minutes long and nearly
|
|
3012 3GB. And because you said that file size does not matter, this is a
|
|
3013 perfectly acceptable size. However, if you had wanted it smaller, you
|
|
3014 could try a lower bitrate. Increasing bitrates have diminishing
|
|
3015 returns, so while we might clearly see an improvement from 1800Kbit to
|
|
3016 2000Kbit, it might not be so noticeable above 2000Kbit. Feel
|
|
3017 free to experiment until you are happy.
|
|
3018 </para>
|
|
3019
|
|
3020 <para>
|
|
3021 Because we passed the source video through a denoise filter, you may want
|
|
3022 to add some of it back during playback. This, along with the
|
|
3023 <option>spp</option> post-processing filter, drastically improves the
|
|
3024 perception of quality and helps eliminate blocky artifacts in the video.
|
|
3025 With <application>MPlayer</application>'s <option>autoq</option> option,
|
|
3026 you can vary the amount of post-processing done by the spp filter
|
|
3027 depending on available CPU. Also, at this point, you may want to apply
|
|
3028 gamma and/or color correction to best suit your display. For example:
|
|
3029 <screen>
|
|
3030 mplayer <replaceable>Harry_Potter_2.avi</replaceable> -vf spp,noise=9ah:5ah,eq2=1.2 -autoq 3
|
|
3031 </screen>
|
|
3032 </para>
|
|
3033 </sect2>
|
|
3034 </sect1>
|
|
3035
|
|
3036
|
|
3037 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
3038
|
|
3039
|
|
3040 <sect1 id="menc-feat-xvid">
|
|
3041 <title>Encoding with the <systemitem class="library">Xvid</systemitem>
|
|
3042 codec</title>
|
|
3043
|
|
3044 <para>
|
|
3045 <systemitem class="library">Xvid</systemitem> is a free library for
|
|
3046 encoding MPEG-4 ASP video streams.
|
|
3047 Before starting to encode, you need to <link linkend="xvid">
|
|
3048 set up <application>MEncoder</application> to support it</link>.
|
|
3049 </para>
|
|
3050
|
|
3051 <para>
|
|
3052 This guide mainly aims at featuring the same kind of information
|
|
3053 as x264's encoding guide.
|
|
3054 Therefore, please begin by reading
|
|
3055 <link linkend="menc-feat-x264-encoding-options-intro">the first part</link>
|
|
3056 of that guide.
|
|
3057 </para>
|
|
3058
|
|
3059 <!-- ********** -->
|
|
3060
|
|
3061 <sect2 id="menc-feat-xvid-intro">
|
|
3062 <title>What options should I use to get the best results?</title>
|
|
3063
|
|
3064 <para>
|
|
3065 Please begin by reviewing the
|
|
3066 <systemitem class="library">Xvid</systemitem> section of
|
|
3067 <application>MPlayer</application>'s man page.
|
|
3068 This section is intended to be a supplement to the man page.
|
|
3069 </para>
|
|
3070
|
|
3071 <para>
|
|
3072 The Xvid default settings are already a good tradeoff between
|
|
3073 speed and quality, therefore you can safely stick to them if
|
|
3074 the following section puzzles you.
|
|
3075 </para>
|
|
3076 </sect2>
|
|
3077
|
|
3078 <!-- ********** -->
|
|
3079
|
|
3080 <sect2 id="menc-feat-xvid-encoding-options">
|
|
3081 <title>Encoding options of <systemitem class="library">Xvid</systemitem></title>
|
|
3082
|
|
3083 <itemizedlist>
|
|
3084 <listitem><para>
|
|
3085 <emphasis role="bold">vhq</emphasis>
|
|
3086 This setting affects the macroblock decision algorithm, where the
|
|
3087 higher the setting, the wiser the decision.
|
|
3088 The default setting may be safely used for every encode, while
|
|
3089 higher settings always help PSNR but are significantly slower.
|
|
3090 Please note that a better PSNR does not necessarily mean
|
|
3091 that the picture will look better, but tells you that it is
|
|
3092 closer to the original.
|
|
3093 Turning it off will noticeably speed up encoding; if speed is
|
|
3094 critical for you, the tradeoff may be worth it.
|
|
3095 </para></listitem>
|
|
3096 <listitem><para>
|
|
3097 <emphasis role="bold">bvhq</emphasis>
|
|
3098 This does the same job as vhq, but does it on B-frames.
|
|
3099 It has a negligible impact on speed, and slightly improves quality
|
|
3100 (around +0.1dB PSNR).
|
|
3101 </para></listitem>
|
|
3102 <listitem><para>
|
|
3103 <emphasis role="bold">max_bframes</emphasis>
|
|
3104 A higher number of consecutive allowed B-frames usually improves
|
|
3105 compressibility, although it may also lead to more blocking artifacts.
|
|
3106 The default setting is a good tradeoff between compressibility and
|
|
3107 quality, but you may increase it up to 3 if you are bitrate-starved.
|
|
3108 You may also decrease it to 1 or 0 if you are aiming at perfect
|
|
3109 quality, though in that case you should make sure your
|
|
3110 target bitrate is high enough to ensure that the encoder does not
|
|
3111 have to increase quantizers to reach it.
|
|
3112 </para></listitem>
|
|
3113 <listitem><para>
|
|
3114 <emphasis role="bold">bf_threshold</emphasis>
|
|
3115 This controls the B-frame sensitivity of the encoder, where a higher
|
|
3116 value leads to more B-frames being used (and vice versa).
|
|
3117 This setting is to be used together with <option>max_bframes</option>;
|
|
3118 if you are bitrate-starved, you should increase both
|
|
3119 <option>max_bframes</option> and <option>bf_threshold</option>,
|
|
3120 while you may increase <option>max_bframes</option> and reduce
|
|
3121 <option>bf_threshold</option> so that the encoder may use more
|
|
3122 B-frames in places that only <emphasis role="bold">really</emphasis>
|
|
3123 need them.
|
|
3124 A low number of <option>max_bframes</option> and a high value of
|
|
3125 <option>bf_threshold</option> is probably not a wise choice as it
|
|
3126 will force the encoder to put B-frames in places that would not
|
|
3127 benefit from them, therefore reducing visual quality.
|
|
3128 However, if you need to be compatible with standalone players that
|
|
3129 only support old DivX profiles (which only supports up to 1
|
|
3130 consecutive B-frame), this would be your only way to
|
|
3131 increase compressibility through using B-frames.
|
|
3132 </para></listitem>
|
|
3133 <listitem><para>
|
|
3134 <emphasis role="bold">trellis</emphasis>
|
|
3135 Optimizes the quantization process to get an optimal tradeoff
|
|
3136 between PSNR and bitrate, which allows significant bit saving.
|
|
3137 These bits will in return be spent elsewhere on the video,
|
|
3138 raising overall visual quality.
|
|
3139 You should always leave it on as its impact on quality is huge.
|
|
3140 Even if you are looking for speed, do not disable it until you
|
|
3141 have turned down <option>vhq</option> and all other more
|
|
3142 CPU-hungry options to the minimum.
|
|
3143 </para></listitem>
|
|
3144 <listitem><para>
|
|
3145 <emphasis role="bold">hq_ac</emphasis>
|
|
3146 Activates a better coefficient cost estimation method, which slightly
|
|
3147 reduces filesize by around 0.15 to 0.19% (which corresponds to less
|
|
3148 than 0.01dB PSNR increase), while having a negligible impact on speed.
|
|
3149 It is therefore recommended to always leave it on.
|
|
3150 </para></listitem>
|
|
3151 <listitem><para>
|
|
3152 <emphasis role="bold">cartoon</emphasis>
|
|
3153 Designed to better encode cartoon content, and has no impact on
|
|
3154 speed as it just tunes the mode decision heuristics for this type
|
|
3155 of content.
|
|
3156 </para></listitem>
|
|
3157 <listitem>
|
|
3158 <para>
|
|
3159 <emphasis role="bold">me_quality</emphasis>
|
|
3160 This setting is to control the precision of the motion estimation.
|
|
3161 The higher <option>me_quality</option>, the more
|
|
3162 precise the estimation of the original motion will be, and the
|
|
3163 better the resulting clip will capture the original motion.
|
|
3164 </para>
|
|
3165 <para>
|
|
3166 The default setting is best in all cases;
|
|
3167 thus it is not recommended to turn it down unless you are
|
|
3168 really looking for speed, as all the bits saved by a good motion
|
|
3169 estimation would be spent elsewhere, raising overall quality.
|
|
3170 Therefore, do not go any lower than 5, and even that only as a last
|
|
3171 resort.
|
|
3172 </para>
|
|
3173 </listitem>
|
|
3174 <listitem><para>
|
|
3175 <emphasis role="bold">chroma_me</emphasis>
|
|
3176 Improves motion estimation by also taking the chroma (color)
|
|
3177 information into account, whereas <option>me_quality</option>
|
|
3178 alone only uses luma (grayscale).
|
|
3179 This slows down encoding by 5-10% but improves visual quality
|
|
3180 quite a bit by reducing blocking effects and reduces filesize by
|
|
3181 around 1.3%.
|
|
3182 If you are looking for speed, you should disable this option before
|
|
3183 starting to consider reducing <option>me_quality</option>.
|
|
3184 </para></listitem>
|
|
3185 <listitem><para>
|
|
3186 <emphasis role="bold">chroma_opt</emphasis>
|
|
3187 Is intended to increase chroma image quality around pure
|
|
3188 white/black edges, rather than improving compression.
|
|
3189 This can help to reduce the "red stairs" effect.
|
|
3190 </para></listitem>
|
|
3191 <listitem><para>
|
|
3192 <emphasis role="bold">lumi_mask</emphasis>
|
|
3193 Tries to give less bitrate to part of the picture that the
|
|
3194 human eye cannot see very well, which should allow the encoder
|
|
3195 to spend the saved bits on more important parts of the picture.
|
|
3196 The quality of the encode yielded by this option highly depends
|
|
3197 on personal preferences and on the type and monitor settings
|
|
3198 used to watch it (typically, it will not look as good if it is
|
|
3199 bright or if it is a TFT monitor).
|
|
3200 </para></listitem>
|
|
3201 <listitem>
|
|
3202 <para>
|
|
3203 <emphasis role="bold">qpel</emphasis>
|
|
3204 Raise the number of candidate motion vectors by increasing
|
|
3205 the precision of the motion estimation from halfpel to
|
|
3206 quarterpel.
|
|
3207 The idea is to find better motion vectors which will in return
|
|
3208 reduce bitrate (hence increasing quality).
|
|
3209 However, motion vectors with quarterpel precision require a
|
|
3210 few extra bits to code, but the candidate vectors do not always
|
|
3211 give (much) better results.
|
|
3212 Quite often, the codec still spends bits on the extra precision,
|
|
3213 but little or no extra quality is gained in return.
|
|
3214 Unfortunately, there is no way to foresee the possible gains of
|
|
3215 <option>qpel</option>, so you need to actually encode with and
|
|
3216 without it to know for sure.
|
|
3217 </para>
|
|
3218 <para>
|
|
3219 <option>qpel</option> can be almost double encoding time, and
|
|
3220 requires as much as 25% more processing power to decode.
|
|
3221 It is not supported by all standalone players.
|
|
3222 </para>
|
|
3223 </listitem>
|
|
3224 <listitem><para>
|
|
3225 <emphasis role="bold">gmc</emphasis>
|
|
3226 Tries to save bits on panning scenes by using a single motion
|
|
3227 vector for the whole frame.
|
|
3228 This almost always raises PSNR, but significantly slows down
|
|
3229 encoding (as well as decoding).
|
|
3230 Therefore, you should only use it when you have turned
|
|
3231 <option>vhq</option> to the maximum.
|
|
3232 <systemitem class="library">Xvid</systemitem>'s GMC is more
|
|
3233 sophisticated than DivX's, but is only supported by few
|
|
3234 standalone players.
|
|
3235 </para></listitem>
|
|
3236 </itemizedlist>
|
|
3237 </sect2>
|
|
3238
|
|
3239 <!-- ********** -->
|
|
3240
|
|
3241 <sect2 id="menc-feat-xvid-encoding-profiles">
|
|
3242 <title>Encoding profiles</title>
|
|
3243
|
|
3244 <para>
|
|
3245 Xvid supports encoding profiles through the <option>profile</option> option,
|
|
3246 which are used to impose restrictions on the properties of the Xvid video
|
|
3247 stream such that it will be playable on anything which supports the
|
|
3248 chosen profile.
|
|
3249 The restrictions relate to resolutions, bitrates and certain MPEG-4
|
|
3250 features.
|
|
3251 The following table shows what each profile supports.
|
|
3252 </para>
|
|
3253
|
|
3254 <informaltable>
|
|
3255 <tgroup cols="16" align="center">
|
|
3256 <colspec colnum="1" colname="col1"/>
|
|
3257 <colspec colnum="2" colname="col2"/>
|
|
3258 <colspec colnum="3" colname="col3"/>
|
|
3259 <colspec colnum="4" colname="col4"/>
|
|
3260 <colspec colnum="5" colname="col5"/>
|
|
3261 <colspec colnum="6" colname="col6"/>
|
|
3262 <colspec colnum="7" colname="col7"/>
|
|
3263 <colspec colnum="8" colname="col8"/>
|
|
3264 <colspec colnum="9" colname="col9"/>
|
|
3265 <colspec colnum="10" colname="col10"/>
|
|
3266 <colspec colnum="11" colname="col11"/>
|
|
3267 <colspec colnum="12" colname="col12"/>
|
|
3268 <colspec colnum="13" colname="col13"/>
|
|
3269 <colspec colnum="14" colname="col14"/>
|
|
3270 <colspec colnum="15" colname="col15"/>
|
|
3271 <colspec colnum="16" colname="col16"/>
|
|
3272 <colspec colnum="17" colname="col17"/>
|
|
3273 <spanspec spanname="spa2-5" namest="col2" nameend="col5"/>
|
|
3274 <spanspec spanname="spa6-11" namest="col6" nameend="col11"/>
|
|
3275 <spanspec spanname="spa12-17" namest="col12" nameend="col17"/>
|
|
3276 <tbody>
|
|
3277 <row>
|
|
3278 <entry></entry>
|
|
3279 <entry spanname="spa2-5">Simple</entry>
|
|
3280 <entry spanname="spa6-11">Advanced Simple</entry>
|
|
3281 <entry spanname="spa12-17">DivX</entry>
|
|
3282 </row>
|
|
3283 <row>
|
|
3284 <entry>Profile name</entry>
|
|
3285 <entry>0</entry>
|
|
3286 <entry>1</entry>
|
|
3287 <entry>2</entry>
|
|
3288 <entry>3</entry>
|
|
3289 <entry>0</entry>
|
|
3290 <entry>1</entry>
|
|
3291 <entry>2</entry>
|
|
3292 <entry>3</entry>
|
|
3293 <entry>4</entry>
|
|
3294 <entry>5</entry>
|
|
3295 <entry>Handheld</entry>
|
|
3296 <entry>Portable NTSC</entry>
|
|
3297 <entry>Portable PAL</entry>
|
|
3298 <entry>Home Theater NTSC</entry>
|
|
3299 <entry>Home Theater PAL</entry>
|
|
3300 <entry>HDTV</entry>
|
|
3301 </row>
|
|
3302 <row>
|
|
3303 <entry>Width [pixels]</entry>
|
|
3304 <entry>176</entry>
|
|
3305 <entry>176</entry>
|
|
3306 <entry>352</entry>
|
|
3307 <entry>352</entry>
|
|
3308 <entry>176</entry>
|
|
3309 <entry>176</entry>
|
|
3310 <entry>352</entry>
|
|
3311 <entry>352</entry>
|
|
3312 <entry>352</entry>
|
|
3313 <entry>720</entry>
|
|
3314 <entry>176</entry>
|
|
3315 <entry>352</entry>
|
|
3316 <entry>352</entry>
|
|
3317 <entry>720</entry>
|
|
3318 <entry>720</entry>
|
|
3319 <entry>1280</entry>
|
|
3320 </row>
|
|
3321 <row>
|
|
3322 <entry>Height [pixels]</entry>
|
|
3323 <entry>144</entry>
|
|
3324 <entry>144</entry>
|
|
3325 <entry>288</entry>
|
|
3326 <entry>288</entry>
|
|
3327 <entry>144</entry>
|
|
3328 <entry>144</entry>
|
|
3329 <entry>288</entry>
|
|
3330 <entry>288</entry>
|
|
3331 <entry>576</entry>
|
|
3332 <entry>576</entry>
|
|
3333 <entry>144</entry>
|
|
3334 <entry>240</entry>
|
|
3335 <entry>288</entry>
|
|
3336 <entry>480</entry>
|
|
3337 <entry>576</entry>
|
|
3338 <entry>720</entry>
|
|
3339 </row>
|
|
3340 <row>
|
|
3341 <entry>Frame rate [fps]</entry>
|
|
3342 <entry>15</entry>
|
|
3343 <entry>15</entry>
|
|
3344 <entry>15</entry>
|
|
3345 <entry>15</entry>
|
|
3346 <entry>30</entry>
|
|
3347 <entry>30</entry>
|
|
3348 <entry>15</entry>
|
|
3349 <entry>30</entry>
|
|
3350 <entry>30</entry>
|
|
3351 <entry>30</entry>
|
|
3352 <entry>15</entry>
|
|
3353 <entry>30</entry>
|
|
3354 <entry>25</entry>
|
|
3355 <entry>30</entry>
|
|
3356 <entry>25</entry>
|
|
3357 <entry>30</entry>
|
|
3358 </row>
|
|
3359 <row>
|
|
3360 <entry>Max average bitrate [kbps]</entry>
|
|
3361 <entry>64</entry>
|
|
3362 <entry>64</entry>
|
|
3363 <entry>128</entry>
|
|
3364 <entry>384</entry>
|
|
3365 <entry>128</entry>
|
|
3366 <entry>128</entry>
|
|
3367 <entry>384</entry>
|
|
3368 <entry>768</entry>
|
|
3369 <entry>3000</entry>
|
|
3370 <entry>8000</entry>
|
|
3371 <entry>537.6</entry>
|
|
3372 <entry>4854</entry>
|
|
3373 <entry>4854</entry>
|
|
3374 <entry>4854</entry>
|
|
3375 <entry>4854</entry>
|
|
3376 <entry>9708.4</entry>
|
|
3377 </row>
|
|
3378 <row>
|
|
3379 <entry>Peak average bitrate over 3 secs [kbps]</entry>
|
|
3380 <entry></entry>
|
|
3381 <entry></entry>
|
|
3382 <entry></entry>
|
|
3383 <entry></entry>
|
|
3384 <entry></entry>
|
|
3385 <entry></entry>
|
|
3386 <entry></entry>
|
|
3387 <entry></entry>
|
|
3388 <entry></entry>
|
|
3389 <entry></entry>
|
|
3390 <entry>800</entry>
|
|
3391 <entry>8000</entry>
|
|
3392 <entry>8000</entry>
|
|
3393 <entry>8000</entry>
|
|
3394 <entry>8000</entry>
|
|
3395 <entry>16000</entry>
|
|
3396 </row>
|
|
3397 <row>
|
|
3398 <entry>Max. B-frames</entry>
|
|
3399 <entry>0</entry>
|
|
3400 <entry>0</entry>
|
|
3401 <entry>0</entry>
|
|
3402 <entry>0</entry>
|
|
3403 <entry></entry>
|
|
3404 <entry></entry>
|
|
3405 <entry></entry>
|
|
3406 <entry></entry>
|
|
3407 <entry></entry>
|
|
3408 <entry></entry>
|
|
3409 <entry>0</entry>
|
|
3410 <entry>1</entry>
|
|
3411 <entry>1</entry>
|
|
3412 <entry>1</entry>
|
|
3413 <entry>1</entry>
|
|
3414 <entry>2</entry>
|
|
3415 </row>
|
|
3416 <row>
|
|
3417 <entry>MPEG quantization</entry>
|
|
3418 <entry></entry>
|
|
3419 <entry></entry>
|
|
3420 <entry></entry>
|
|
3421 <entry></entry>
|
|
3422 <entry>X</entry>
|
|
3423 <entry>X</entry>
|
|
3424 <entry>X</entry>
|
|
3425 <entry>X</entry>
|
|
3426 <entry>X</entry>
|
|
3427 <entry>X</entry>
|
|
3428 <entry></entry>
|
|
3429 <entry></entry>
|
|
3430 <entry></entry>
|
|
3431 <entry></entry>
|
|
3432 <entry></entry>
|
|
3433 <entry></entry>
|
|
3434 </row>
|
|
3435 <row>
|
|
3436 <entry>Adaptive quantization</entry>
|
|
3437 <entry></entry>
|
|
3438 <entry></entry>
|
|
3439 <entry></entry>
|
|
3440 <entry></entry>
|
|
3441 <entry>X</entry>
|
|
3442 <entry>X</entry>
|
|
3443 <entry>X</entry>
|
|
3444 <entry>X</entry>
|
|
3445 <entry>X</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 </row>
|
|
3454 <row>
|
|
3455 <entry>Interlaced encoding</entry>
|
|
3456 <entry></entry>
|
|
3457 <entry></entry>
|
|
3458 <entry></entry>
|
|
3459 <entry></entry>
|
|
3460 <entry>X</entry>
|
|
3461 <entry>X</entry>
|
|
3462 <entry>X</entry>
|
|
3463 <entry>X</entry>
|
|
3464 <entry>X</entry>
|
|
3465 <entry>X</entry>
|
|
3466 <entry></entry>
|
|
3467 <entry></entry>
|
|
3468 <entry></entry>
|
|
3469 <entry>X</entry>
|
|
3470 <entry>X</entry>
|
|
3471 <entry>X</entry>
|
|
3472 </row>
|
|
3473 <row>
|
|
3474 <entry>Quaterpixel</entry>
|
|
3475 <entry></entry>
|
|
3476 <entry></entry>
|
|
3477 <entry></entry>
|
|
3478 <entry></entry>
|
|
3479 <entry>X</entry>
|
|
3480 <entry>X</entry>
|
|
3481 <entry>X</entry>
|
|
3482 <entry>X</entry>
|
|
3483 <entry>X</entry>
|
|
3484 <entry>X</entry>
|
|
3485 <entry></entry>
|
|
3486 <entry></entry>
|
|
3487 <entry></entry>
|
|
3488 <entry></entry>
|
|
3489 <entry></entry>
|
|
3490 <entry></entry>
|
|
3491 </row>
|
|
3492 <row>
|
|
3493 <entry>Global motion compensation</entry>
|
|
3494 <entry></entry>
|
|
3495 <entry></entry>
|
|
3496 <entry></entry>
|
|
3497 <entry></entry>
|
|
3498 <entry>X</entry>
|
|
3499 <entry>X</entry>
|
|
3500 <entry>X</entry>
|
|
3501 <entry>X</entry>
|
|
3502 <entry>X</entry>
|
|
3503 <entry>X</entry>
|
|
3504 <entry></entry>
|
|
3505 <entry></entry>
|
|
3506 <entry></entry>
|
|
3507 <entry></entry>
|
|
3508 <entry></entry>
|
|
3509 <entry></entry>
|
|
3510 </row>
|
|
3511 </tbody>
|
|
3512 </tgroup>
|
|
3513 </informaltable>
|
|
3514 </sect2>
|
|
3515
|
|
3516 <!-- ********** -->
|
|
3517
|
|
3518 <sect2 id="menc-feat-xvid-example-settings">
|
|
3519 <title>Encoding setting examples</title>
|
|
3520
|
|
3521 <para>
|
|
3522 The following settings are examples of different encoding
|
|
3523 option combinations that affect the speed vs quality tradeoff
|
|
3524 at the same target bitrate.
|
|
3525 </para>
|
|
3526
|
|
3527 <para>
|
|
3528 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
3529 video sample, the target bitrate was 900kbps, and the machine was an
|
|
3530 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
3531 Each encoding setting features the measured encoding speed (in
|
|
3532 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
3533 high quality" setting.
|
|
3534 Please understand that depending on your source, your machine type
|
|
3535 and development advancements, you may get very different results.
|
|
3536 </para>
|
|
3537
|
|
3538 <informaltable frame="all">
|
|
3539 <tgroup cols="4">
|
|
3540 <thead>
|
|
3541 <row><entry>Description</entry><entry>Encoding options</entry><entry>speed (in fps)</entry><entry>Relative PSNR loss (in dB)</entry></row>
|
|
3542 </thead>
|
|
3543 <tbody>
|
|
3544 <row>
|
|
3545 <entry>Very high quality</entry>
|
|
3546 <entry><option>chroma_opt:vhq=4:bvhq=1:quant_type=mpeg</option></entry>
|
|
3547 <entry>16fps</entry>
|
|
3548 <entry>0dB</entry>
|
|
3549 </row>
|
|
3550 <row>
|
|
3551 <entry>High quality</entry>
|
|
3552 <entry><option>vhq=2:bvhq=1:chroma_opt:quant_type=mpeg</option></entry>
|
|
3553 <entry>18fps</entry>
|
|
3554 <entry>-0.1dB</entry>
|
|
3555 </row>
|
|
3556 <row>
|
|
3557 <entry>Fast</entry>
|
|
3558 <entry><option>turbo:vhq=0</option></entry>
|
|
3559 <entry>28fps</entry>
|
|
3560 <entry>-0.69dB</entry>
|
|
3561 </row>
|
|
3562 <row>
|
|
3563 <entry>Realtime</entry>
|
|
3564 <entry><option>turbo:nochroma_me:notrellis:max_bframes=0:vhq=0</option></entry>
|
|
3565 <entry>38fps</entry>
|
|
3566 <entry>-1.48dB</entry>
|
|
3567 </row>
|
|
3568 </tbody>
|
|
3569 </tgroup>
|
|
3570 </informaltable>
|
|
3571 </sect2>
|
|
3572 </sect1>
|
|
3573
|
|
3574
|
|
3575 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
3576
|
|
3577
|
|
3578 <sect1 id="menc-feat-x264">
|
|
3579 <title>Encoding with the
|
|
3580 <systemitem class="library">x264</systemitem> codec</title>
|
|
3581
|
|
3582 <para>
|
|
3583 <systemitem class="library">x264</systemitem> is a free library for
|
|
3584 encoding H.264/AVC video streams.
|
|
3585 Before starting to encode, you need to
|
27821
|
3586 <link linkend="codec-x264">set up <application>MEncoder</application> to support it</link>.
|
25279
|
3587 </para>
|
|
3588
|
|
3589 <!-- ********** -->
|
|
3590
|
|
3591 <sect2 id="menc-feat-x264-encoding-options">
|
|
3592 <title>Encoding options of x264</title>
|
|
3593
|
|
3594 <para>
|
|
3595 Please begin by reviewing the
|
|
3596 <systemitem class="library">x264</systemitem> section of
|
|
3597 <application>MPlayer</application>'s man page.
|
|
3598 This section is intended to be a supplement to the man page.
|
|
3599 Here you will find quick hints about which options are most
|
|
3600 likely to interest most people. The man page is more terse,
|
|
3601 but also more exhaustive, and it sometimes offers much better
|
|
3602 technical detail.
|
|
3603 </para>
|
|
3604
|
|
3605
|
|
3606 <sect3 id="menc-feat-x264-encoding-options-intro">
|
|
3607 <title>Introduction</title>
|
|
3608
|
|
3609 <para>
|
|
3610 This guide considers two major categories of encoding options:
|
|
3611 </para>
|
|
3612
|
|
3613 <orderedlist>
|
|
3614 <listitem><para>
|
|
3615 Options which mainly trade off encoding time vs. quality
|
|
3616 </para></listitem>
|
|
3617 <listitem><para>
|
|
3618 Options which may be useful for fulfilling various personal
|
|
3619 preferences and special requirements
|
|
3620 </para></listitem>
|
|
3621 </orderedlist>
|
|
3622
|
|
3623 <para>
|
|
3624 Ultimately, only you can decide which options are best for your
|
|
3625 purposes. The decision for the first class of options is the simplest:
|
|
3626 you only have to decide whether you think the quality differences
|
|
3627 justify the speed differences. For the second class of options,
|
|
3628 preferences may be far more subjective, and more factors may be
|
|
3629 involved. Note that some of the "personal preferences and special
|
|
3630 requirements" options can still have large impacts on speed or quality,
|
|
3631 but that is not what they are primarily useful for. A couple of the
|
|
3632 "personal preference" options may even cause changes that look better
|
|
3633 to some people, but look worse to others.
|
|
3634 </para>
|
|
3635
|
|
3636 <para>
|
|
3637 Before continuing, you need to understand that this guide uses only one
|
|
3638 quality metric: global PSNR.
|
|
3639 For a brief explanation of what PSNR is, see
|
|
3640 <ulink url="http://en.wikipedia.org/wiki/PSNR">the Wikipedia article on PSNR</ulink>.
|
|
3641 Global PSNR is the last PSNR number reported when you include
|
|
3642 the <option>psnr</option> option in <option>x264encopts</option>.
|
|
3643 Any time you read a claim about PSNR, one of the assumptions
|
|
3644 behind the claim is that equal bitrates are used.
|
|
3645 </para>
|
|
3646
|
|
3647 <para>
|
|
3648 Nearly all of this guide's comments assume you are using two pass.
|
|
3649 When comparing options, there are two major reasons for using
|
|
3650 two pass encoding.
|
|
3651 First, using two pass often gains around 1dB PSNR, which is a
|
|
3652 very big difference.
|
|
3653 Secondly, testing options by doing direct quality comparisons
|
|
3654 with one pass encodes introduces a major confounding
|
|
3655 factor: bitrate often varies significantly with each encode.
|
|
3656 It is not always easy to tell whether quality changes are due
|
|
3657 mainly to changed options, or if they mostly reflect essentially
|
|
3658 random differences in the achieved bitrate.
|
|
3659 </para>
|
|
3660 </sect3>
|
|
3661
|
|
3662
|
|
3663 <sect3 id="menc-feat-x264-encoding-options-speedvquality">
|
|
3664 <title>Options which primarily affect speed and quality</title>
|
|
3665
|
|
3666 <itemizedlist>
|
|
3667 <listitem>
|
|
3668 <para>
|
|
3669 <emphasis role="bold">subq</emphasis>:
|
|
3670 Of the options which allow you to trade off speed for quality,
|
|
3671 <option>subq</option> and <option>frameref</option> (see below) are usually
|
|
3672 by far the most important.
|
|
3673 If you are interested in tweaking either speed or quality, these
|
|
3674 are the first options you should consider.
|
|
3675 On the speed dimension, the <option>frameref</option> and
|
|
3676 <option>subq</option> options interact with each other fairly
|
|
3677 strongly.
|
|
3678 Experience shows that, with one reference frame,
|
|
3679 <option>subq=5</option> (the default setting) takes about 35% more time than
|
|
3680 <option>subq=1</option>.
|
|
3681 With 6 reference frames, the penalty grows to over 60%.
|
|
3682 <option>subq</option>'s effect on PSNR seems fairly constant
|
|
3683 regardless of the number of reference frames.
|
|
3684 Typically, <option>subq=5</option> achieves 0.2-0.5 dB higher global
|
|
3685 PSNR in comparison <option>subq=1</option>.
|
|
3686 This is usually enough to be visible.
|
|
3687 </para>
|
|
3688 <para>
|
|
3689 <option>subq=6</option> is slower and yields better quality at a reasonable
|
|
3690 cost.
|
|
3691 In comparison to <option>subq=5</option>, it usually gains 0.1-0.4 dB
|
|
3692 global PSNR with speed costs varying from 25%-100%.
|
|
3693 Unlike other levels of <option>subq</option>, the behavior of
|
|
3694 <option>subq=6</option> does not depend much on <option>frameref</option>
|
|
3695 and <option>me</option>. Instead, the effectiveness of <option>subq=6
|
|
3696 </option> depends mostly upon the number of B-frames used. In normal
|
|
3697 usage, this means <option>subq=6</option> has a large impact on both speed
|
|
3698 and quality in complex, high motion scenes, but it may not have much effect
|
|
3699 in low-motion scenes. Note that it is still recommended to always set
|
|
3700 <option>bframes</option> to something other than zero (see below).
|
|
3701 </para>
|
|
3702 <para>
|
|
3703 <option>subq=7</option> is the slowest, highest quality mode.
|
|
3704 In comparison to <option>subq=6</option>, it usually gains 0.01-0.05 dB
|
|
3705 global PSNR with speed costs varying from 15%-33%.
|
|
3706 Since the tradeoff encoding time vs. quality is quite low, you should
|
|
3707 only use it if you are after every bit saving and if encoding time is
|
|
3708 not an issue.
|
|
3709 </para>
|
|
3710 </listitem>
|
|
3711 <listitem>
|
|
3712 <para>
|
|
3713 <emphasis role="bold">frameref</emphasis>:
|
|
3714 <option>frameref</option> is set to 1 by default, but this
|
|
3715 should not be taken to imply that it is reasonable to set it to 1.
|
|
3716 Merely raising <option>frameref</option> to 2 gains around
|
|
3717 0.15dB PSNR with a 5-10% speed penalty; this seems like a good tradeoff.
|
|
3718 <option>frameref=3</option> gains around 0.25dB PSNR over
|
|
3719 <option>frameref=1</option>, which should be a visible difference.
|
|
3720 <option>frameref=3</option> is around 15% slower than
|
|
3721 <option>frameref=1</option>.
|
|
3722 Unfortunately, diminishing returns set in rapidly.
|
|
3723 <option>frameref=6</option> can be expected to gain only
|
|
3724 0.05-0.1 dB over <option>frameref=3</option> at an additional
|
|
3725 15% speed penalty.
|
|
3726 Above <option>frameref=6</option>, the quality gains are
|
|
3727 usually very small (although you should keep in mind throughout
|
|
3728 this whole discussion that it can vary quite a lot depending on your source).
|
|
3729 In a fairly typical case, <option>frameref=12</option>
|
|
3730 will improve global PSNR by a tiny 0.02dB over
|
|
3731 <option>frameref=6</option>, at a speed cost of 15%-20%.
|
|
3732 At such high <option>frameref</option> values, the only really
|
|
3733 good thing that can be said is that increasing it even further will
|
|
3734 almost certainly never <emphasis role="bold">harm</emphasis>
|
|
3735 PSNR, but the additional quality benefits are barely even
|
|
3736 measurable, let alone perceptible.
|
|
3737 </para>
|
|
3738 <note><title>Note:</title>
|
|
3739 <para>
|
|
3740 Raising <option>frameref</option> to unnecessarily high values
|
|
3741 <emphasis role="bold">can</emphasis> and
|
|
3742 <emphasis role="bold">usually does</emphasis>
|
|
3743 hurt coding efficiency if you turn CABAC off.
|
|
3744 With CABAC on (the default behavior), the possibility of setting
|
|
3745 <option>frameref</option> "too high" currently seems too remote
|
|
3746 to even worry about, and in the future, optimizations may remove
|
|
3747 the possibility altogether.
|
|
3748 </para></note>
|
|
3749 <para>
|
|
3750 If you care about speed, a reasonable compromise is to use low
|
|
3751 <option>subq</option> and <option>frameref</option> values on
|
|
3752 the first pass, and then raise them on the second pass.
|
|
3753 Typically, this has a negligible negative effect on the final
|
|
3754 quality: You will probably lose well under 0.1dB PSNR, which
|
|
3755 should be much too small of a difference to see.
|
|
3756 However, different values of <option>frameref</option> can
|
|
3757 occasionally affect frametype decision.
|
|
3758 Most likely, these are rare outlying cases, but if you want to
|
|
3759 be pretty sure, consider whether your video has either
|
|
3760 fullscreen repetitive flashing patterns or very large temporary
|
|
3761 occlusions which might force an I-frame.
|
|
3762 Adjust the first-pass <option>frameref</option> so it is large
|
|
3763 enough to contain the duration of the flashing cycle (or occlusion).
|
|
3764 For example, if the scene flashes back and forth between two images
|
|
3765 over a duration of three frames, set the first pass
|
|
3766 <option>frameref</option> to 3 or higher.
|
|
3767 This issue is probably extremely rare in live action video material,
|
|
3768 but it does sometimes come up in video game captures.
|
|
3769 </para>
|
|
3770 </listitem>
|
|
3771 <listitem>
|
|
3772 <para>
|
|
3773 <emphasis role="bold">me</emphasis>:
|
|
3774 This option is for choosing the motion estimation search method.
|
|
3775 Altering this option provides a straightforward quality-vs-speed
|
|
3776 tradeoff. <option>me=dia</option> is only a few percent faster than
|
|
3777 the default search, at a cost of under 0.1dB global PSNR. The
|
|
3778 default setting (<option>me=hex</option>) is a reasonable tradeoff
|
|
3779 between speed and quality. <option>me=umh</option> gains a little under
|
|
3780 0.1dB global PSNR, with a speed penalty that varies depending on
|
|
3781 <option>frameref</option>. At high values of
|
|
3782 <option>frameref</option> (e.g. 12 or so), <option>me=umh</option>
|
|
3783 is about 40% slower than the default <option> me=hex</option>. With
|
|
3784 <option>frameref=3</option>, the speed penalty incurred drops to
|
|
3785 25%-30%.
|
|
3786 </para>
|
|
3787 <para>
|
|
3788 <option>me=esa</option> uses an exhaustive search that is too slow for
|
|
3789 practical use.
|
|
3790 </para>
|
|
3791 </listitem>
|
|
3792 <listitem><para>
|
|
3793 <emphasis role="bold">partitions=all</emphasis>:
|
|
3794 This option enables the use of 8x4, 4x8 and 4x4 subpartitions in
|
|
3795 predicted macroblocks (in addition to the default partitions).
|
|
3796 Enabling it results in a fairly consistent
|
|
3797 10%-15% loss of speed. This option is rather useless in source
|
|
3798 containing only low motion, however in some high-motion source,
|
|
3799 particularly source with lots of small moving objects, gains of
|
|
3800 about 0.1dB can be expected.
|
|
3801 </para></listitem>
|
|
3802 <listitem>
|
|
3803 <para>
|
|
3804 <emphasis role="bold">bframes</emphasis>:
|
|
3805 If you are used to encoding with other codecs, you may have found
|
|
3806 that B-frames are not always useful.
|
|
3807 In H.264, this has changed: there are new techniques and block
|
|
3808 types that are possible in B-frames.
|
|
3809 Usually, even a naive B-frame choice algorithm can have a
|
|
3810 significant PSNR benefit.
|
|
3811 It is interesting to note that using B-frames usually speeds up
|
|
3812 the second pass somewhat, and may also speed up a single
|
|
3813 pass encode if adaptive B-frame decision is turned off.
|
|
3814 </para>
|
|
3815 <para>
|
|
3816 With adaptive B-frame decision turned off
|
|
3817 (<option>x264encopts</option>'s <option>nob_adapt</option>),
|
|
3818 the optimal value for this setting is usually no more than
|
|
3819 <option>bframes=1</option>, or else high-motion scenes can suffer.
|
|
3820 With adaptive B-frame decision on (the default behavior), it is
|
|
3821 safe to use higher values; the encoder will reduce the use of
|
|
3822 B-frames in scenes where they would hurt compression.
|
|
3823 The encoder rarely chooses to use more than 3 or 4 B-frames;
|
|
3824 setting this option any higher will have little effect.
|
|
3825 </para>
|
|
3826 </listitem>
|
|
3827 <listitem>
|
|
3828 <para>
|
|
3829 <emphasis role="bold">b_adapt</emphasis>:
|
|
3830 Note: This is on by default.
|
|
3831 </para>
|
|
3832 <para>
|
|
3833 With this option enabled, the encoder will use a reasonably fast
|
|
3834 decision process to reduce the number of B-frames used in scenes that
|
|
3835 might not benefit from them as much.
|
|
3836 You can use <option>b_bias</option> to tweak how B-frame-happy
|
|
3837 the encoder is.
|
|
3838 The speed penalty of adaptive B-frames is currently rather modest,
|
|
3839 but so is the potential quality gain.
|
|
3840 It usually does not hurt, however.
|
|
3841 Note that this only affects speed and frametype decision on the
|
|
3842 first pass.
|
|
3843 <option>b_adapt</option> and <option>b_bias</option> have no
|
|
3844 effect on subsequent passes.
|
|
3845 </para>
|
|
3846 </listitem>
|
|
3847 <listitem><para>
|
|
3848 <emphasis role="bold">b_pyramid</emphasis>:
|
|
3849 You might as well enable this option if you are using >=2 B-frames;
|
|
3850 as the man page says, you get a little quality improvement at no
|
|
3851 speed cost.
|
|
3852 Note that these videos cannot be read by libavcodec-based decoders
|
|
3853 older than about March 5, 2005.
|
|
3854 </para></listitem>
|
|
3855 <listitem>
|
|
3856 <para>
|
|
3857 <emphasis role="bold">weight_b</emphasis>:
|
|
3858 In typical cases, there is not much gain with this option.
|
|
3859 However, in crossfades or fade-to-black scenes, weighted
|
|
3860 prediction gives rather large bitrate savings.
|
|
3861 In MPEG-4 ASP, a fade-to-black is usually best coded as a series
|
|
3862 of expensive I-frames; using weighted prediction in B-frames
|
|
3863 makes it possible to turn at least some of these into much smaller
|
|
3864 B-frames.
|
|
3865 Encoding time cost is minimal, as no extra decisions need to be made.
|
|
3866 Also, contrary to what some people seem to guess, the decoder
|
|
3867 CPU requirements are not much affected by weighted prediction,
|
|
3868 all else being equal.
|
|
3869 </para>
|
|
3870 <para>
|
|
3871 Unfortunately, the current adaptive B-frame decision algorithm
|
|
3872 has a strong tendency to avoid B-frames during fades.
|
|
3873 Until this changes, it may be a good idea to add
|
|
3874 <option>nob_adapt</option> to your x264encopts, if you expect
|
|
3875 fades to have a large effect in your particular video
|
|
3876 clip.
|
|
3877 </para>
|
|
3878 </listitem>
|
|
3879 <listitem id="menc-feat-x264-encoding-options-speedvquality-threads">
|
|
3880 <para>
|
|
3881 <emphasis role="bold">threads</emphasis>:
|
|
3882 This option allows to spawn threads to encode in parallel on multiple CPUs.
|
|
3883 You can manually select the number of threads to be created or, better, set
|
|
3884 <option>threads=auto</option> and let
|
|
3885 <systemitem class="library">x264</systemitem> detect how many CPUs are
|
|
3886 available and pick an appropriate number of threads.
|
|
3887 If you have a multi-processor machine, you should really consider using it
|
|
3888 as it can to increase encoding speed linearly with the number of CPU cores
|
|
3889 (about 94% per CPU core), with very little quality reduction (about 0.005dB
|
|
3890 for dual processor, about 0.01dB for a quad processor machine).
|
|
3891 </para>
|
|
3892 </listitem>
|
|
3893 </itemizedlist>
|
|
3894 </sect3>
|
|
3895
|
|
3896
|
|
3897 <sect3 id="menc-feat-x264-encoding-options-misc-preferences">
|
|
3898 <title>Options pertaining to miscellaneous preferences</title>
|
|
3899
|
|
3900 <itemizedlist>
|
|
3901 <listitem>
|
|
3902 <para>
|
|
3903 <emphasis role="bold">Two pass encoding</emphasis>:
|
|
3904 Above, it was suggested to always use two pass encoding, but there
|
|
3905 are still reasons for not using it. For instance, if you are capturing
|
|
3906 live TV and encoding in realtime, you are forced to use single-pass.
|
|
3907 Also, one pass is obviously faster than two passes; if you use the
|
|
3908 exact same set of options on both passes, two pass encoding is almost
|
|
3909 twice as slow.
|
|
3910 </para>
|
|
3911 <para>
|
|
3912 Still, there are very good reasons for using two pass encoding. For
|
|
3913 one thing, single pass ratecontrol is not psychic, and it often makes
|
|
3914 unreasonable choices because it cannot see the big picture. For example,
|
|
3915 suppose you have a two minute long video consisting of two distinct
|
|
3916 halves. The first half is a very high-motion scene lasting 60 seconds
|
|
3917 which, in isolation, requires about 2500kbps in order to look decent.
|
|
3918 Immediately following it is a much less demanding 60-second scene
|
|
3919 that looks good at 300kbps. Suppose you ask for 1400kbps on the theory
|
|
3920 that this is enough to accomodate both scenes. Single pass ratecontrol
|
|
3921 will make a couple of "mistakes" in such a case. First of all, it
|
|
3922 will target 1400kbps in both segments. The first segment may end up
|
|
3923 heavily overquantized, causing it to look unacceptably and unreasonably
|
|
3924 blocky. The second segment will be heavily underquantized; it may look
|
|
3925 perfect, but the bitrate cost of that perfection will be completely
|
|
3926 unreasonable. What is even harder to avoid is the problem at the
|
|
3927 transition between the two scenes. The first seconds of the low motion
|
|
3928 half will be hugely over-quantized, because the ratecontrol is still
|
|
3929 expecting the kind of bitrate requirements it met in the first half
|
|
3930 of the video. This "error period" of heavily over-quantized low motion
|
|
3931 will look jarringly bad, and will actually use less than the 300kbps
|
|
3932 it would have taken to make it look decent. There are ways to
|
|
3933 mitigate the pitfalls of single-pass encoding, but they may tend to
|
|
3934 increase bitrate misprediction.
|
|
3935 </para>
|
|
3936 <para>
|
|
3937 Multipass ratecontrol can offer huge advantages over a single pass.
|
|
3938 Using the statistics gathered from the first pass encode, the encoder
|
|
3939 can estimate, with reasonable accuracy, the "cost" (in bits) of
|
|
3940 encoding any given frame, at any given quantizer. This allows for
|
|
3941 a much more rational, better planned allocation of bits between the
|
|
3942 expensive (high-motion) and cheap (low-motion) scenes. See
|
|
3943 <option>qcomp</option> below for some ideas on how to tweak this
|
|
3944 allocation to your liking.
|
|
3945 </para>
|
|
3946 <para>
|
|
3947 Moreover, two passes need not take twice as long as one pass. You can
|
|
3948 tweak the options in the first pass for higher speed and lower quality.
|
|
3949 If you choose your options well, you can get a very fast first pass.
|
|
3950 The resulting quality in the second pass will be slightly lower because size
|
|
3951 prediction is less accurate, but the quality difference is normally much
|
|
3952 too small to be visible. Try, for example, adding
|
|
3953 <option>subq=1:frameref=1</option> to the first pass
|
|
3954 <option>x264encopts</option>. Then, on the second pass, use slower,
|
|
3955 higher-quality options:
|
|
3956 <option>subq=6:frameref=15:partitions=all:me=umh</option>
|
|
3957 </para>
|
|
3958 </listitem>
|
|
3959 <listitem><para>
|
|
3960 <emphasis role="bold">Three pass encoding</emphasis>?
|
|
3961 x264 offers the ability to make an arbitrary number of consecutive
|
|
3962 passes. If you specify <option>pass=1</option> on the first pass,
|
|
3963 then use <option>pass=3</option> on a subsequent pass, the subsequent
|
|
3964 pass will both read the statistics from the previous pass, and write
|
|
3965 its own statistics. An additional pass following this one will have
|
|
3966 a very good base from which to make highly accurate predictions of
|
|
3967 framesizes at a chosen quantizer. In practice, the overall quality
|
|
3968 gain from this is usually close to zero, and quite possibly a third
|
|
3969 pass will result in slightly worse global PSNR than the pass before
|
|
3970 it. In typical usage, three passes help if you get either bad bitrate
|
|
3971 prediction or bad looking scene transitions when using only two passes.
|
|
3972 This is somewhat likely to happen on extremely short clips. There are
|
|
3973 also a few special cases in which three (or more) passes are handy
|
|
3974 for advanced users, but for brevity, this guide omits discussing those
|
|
3975 special cases.
|
|
3976 </para></listitem>
|
|
3977 <listitem><para>
|
|
3978 <emphasis role="bold">qcomp</emphasis>:
|
|
3979 <option>qcomp</option> trades off the number of bits allocated
|
|
3980 to "expensive" high-motion versus "cheap" low-motion frames. At
|
|
3981 one extreme, <option>qcomp=0</option> aims for true constant
|
|
3982 bitrate. Typically this would make high-motion scenes look completely
|
|
3983 awful, while low-motion scenes would probably look absolutely
|
|
3984 perfect, but would also use many times more bitrate than they
|
|
3985 would need in order to look merely excellent. At the other extreme,
|
|
3986 <option>qcomp=1</option> achieves nearly constant quantization parameter
|
|
3987 (QP). Constant QP does not look bad, but most people think it is more
|
|
3988 reasonable to shave some bitrate off of the extremely expensive scenes
|
|
3989 (where the loss of quality is not as noticeable) and reallocate it to
|
|
3990 the scenes that are easier to encode at excellent quality.
|
|
3991 <option>qcomp</option> is set to 0.6 by default, which may be slightly
|
|
3992 low for many peoples' taste (0.7-0.8 are also commonly used).
|
|
3993 </para></listitem>
|
|
3994 <listitem><para>
|
|
3995 <emphasis role="bold">keyint</emphasis>:
|
|
3996 <option>keyint</option> is solely for trading off file seekability against
|
|
3997 coding efficiency. By default, <option>keyint</option> is set to 250. In
|
|
3998 25fps material, this guarantees the ability to seek to within 10 seconds
|
|
3999 precision. If you think it would be important and useful to be able to
|
|
4000 seek within 5 seconds of precision, set <option>keyint=125</option>;
|
|
4001 this will hurt quality/bitrate slightly. If you care only about quality
|
|
4002 and not about seekability, you can set it to much higher values
|
|
4003 (understanding that there are diminishing returns which may become
|
|
4004 vanishingly low, or even zero). The video stream will still have seekable
|
|
4005 points as long as there are some scene changes.
|
|
4006 </para></listitem>
|
|
4007 <listitem>
|
|
4008 <para>
|
|
4009 <emphasis role="bold">deblock</emphasis>:
|
|
4010 This topic is going to be a bit controversial.
|
|
4011 </para>
|
|
4012 <para>
|
|
4013 H.264 defines a simple deblocking procedure on I-blocks that uses
|
|
4014 pre-set strengths and thresholds depending on the QP of the block
|
|
4015 in question.
|
|
4016 By default, high QP blocks are filtered heavily, and low QP blocks
|
|
4017 are not deblocked at all.
|
|
4018 The pre-set strengths defined by the standard are well-chosen and
|
|
4019 the odds are very good that they are PSNR-optimal for whatever
|
|
4020 video you are trying to encode.
|
|
4021 The <option>deblock</option> allow you to specify offsets to the preset
|
|
4022 deblocking thresholds.
|
|
4023 </para>
|
|
4024 <para>
|
|
4025 Many people seem to think it is a good idea to lower the deblocking
|
|
4026 filter strength by large amounts (say, -3).
|
|
4027 This is however almost never a good idea, and in most cases,
|
|
4028 people who are doing this do not understand very well how
|
|
4029 deblocking works by default.
|
|
4030 </para>
|
|
4031 <para>
|
|
4032 The first and most important thing to know about the in-loop
|
|
4033 deblocking filter is that the default thresholds are almost always
|
|
4034 PSNR-optimal.
|
|
4035 In the rare cases that they are not optimal, the ideal offset is
|
|
4036 plus or minus 1.
|
|
4037 Adjusting deblocking parameters by a larger amount is almost
|
|
4038 guaranteed to hurt PSNR.
|
|
4039 Strengthening the filter will smear more details; weakening the
|
|
4040 filter will increase the appearance of blockiness.
|
|
4041 </para>
|
|
4042 <para>
|
|
4043 It is definitely a bad idea to lower the deblocking thresholds if
|
|
4044 your source is mainly low in spacial complexity (i.e., not a lot
|
|
4045 of detail or noise).
|
|
4046 The in-loop filter does a rather excellent job of concealing
|
|
4047 the artifacts that occur.
|
|
4048 If the source is high in spacial complexity, however, artifacts
|
|
4049 are less noticeable.
|
|
4050 This is because the ringing tends to look like detail or noise.
|
|
4051 Human visual perception easily notices when detail is removed,
|
|
4052 but it does not so easily notice when the noise is wrongly
|
|
4053 represented.
|
|
4054 When it comes to subjective quality, noise and detail are somewhat
|
|
4055 interchangeable.
|
|
4056 By lowering the deblocking filter strength, you are most likely
|
|
4057 increasing error by adding ringing artifacts, but the eye does
|
|
4058 not notice because it confuses the artifacts with detail.
|
|
4059 </para>
|
|
4060 <para>
|
|
4061 This <emphasis role="bold">still</emphasis> does not justify
|
|
4062 lowering the deblocking filter strength, however.
|
|
4063 You can generally get better quality noise from postprocessing.
|
|
4064 If your H.264 encodes look too blurry or smeared, try playing with
|
|
4065 <option>-vf noise</option> when you play your encoded movie.
|
|
4066 <option>-vf noise=8a:4a</option> should conceal most mild
|
|
4067 artifacting.
|
|
4068 It will almost certainly look better than the results you
|
|
4069 would have gotten just by fiddling with the deblocking filter.
|
|
4070 </para>
|
|
4071 </listitem>
|
|
4072 </itemizedlist>
|
|
4073 </sect3>
|
|
4074 </sect2>
|
|
4075
|
|
4076 <!-- ********** -->
|
|
4077
|
|
4078 <sect2 id="menc-feat-x264-example-settings">
|
|
4079 <title>Encoding setting examples</title>
|
|
4080
|
|
4081 <para>
|
|
4082 The following settings are examples of different encoding
|
|
4083 option combinations that affect the speed vs quality tradeoff
|
|
4084 at the same target bitrate.
|
|
4085 </para>
|
|
4086
|
|
4087 <para>
|
|
4088 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
4089 video sample, the target bitrate was 900kbps, and the machine was an
|
|
4090 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
4091 Each encoding setting features the measured encoding speed (in
|
|
4092 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
4093 high quality" setting.
|
|
4094 Please understand that depending on your source, your machine type
|
|
4095 and development advancements, you may get very different results.
|
|
4096 </para>
|
|
4097
|
|
4098 <informaltable frame="all">
|
|
4099 <tgroup cols="4">
|
|
4100 <thead>
|
|
4101 <row>
|
|
4102 <entry>Description</entry>
|
|
4103 <entry>Encoding options</entry>
|
|
4104 <entry>speed (in fps)</entry>
|
|
4105 <entry>Relative PSNR loss (in dB)</entry>
|
|
4106 </row>
|
|
4107 </thead>
|
|
4108 <tbody>
|
|
4109 <row>
|
|
4110 <entry>Very high quality</entry>
|
|
4111 <entry><option>subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4112 <entry>6fps</entry>
|
|
4113 <entry>0dB</entry>
|
|
4114 </row>
|
|
4115 <row>
|
|
4116 <entry>High quality</entry>
|
|
4117 <entry><option>subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4118 <entry>13fps</entry>
|
|
4119 <entry>-0.89dB</entry>
|
|
4120 </row>
|
|
4121 <row>
|
|
4122 <entry>Fast</entry>
|
|
4123 <entry><option>subq=4:bframes=2:b_pyramid:weight_b</option></entry>
|
|
4124 <entry>17fps</entry>
|
|
4125 <entry>-1.48dB</entry>
|
|
4126 </row>
|
|
4127 </tbody>
|
|
4128 </tgroup>
|
|
4129 </informaltable>
|
|
4130 </sect2>
|
|
4131 </sect1>
|
|
4132
|
|
4133
|
|
4134 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4135
|
|
4136
|
|
4137 <sect1 id="menc-feat-video-for-windows">
|
|
4138 <title>
|
|
4139 Encoding with the <systemitem class="library">Video For Windows</systemitem>
|
|
4140 codec family
|
|
4141 </title>
|
|
4142
|
|
4143 <para>
|
|
4144 Video for Windows provides simple encoding by means of binary video codecs.
|
|
4145 You can encode with the following codecs (if you have more, please tell us!)
|
|
4146 </para>
|
|
4147
|
|
4148 <para>
|
|
4149 Note that support for this is very experimental and some codecs may not work
|
|
4150 correctly. Some codecs will only work in certain colorspaces, try
|
|
4151 <option>-vf format=bgr24</option> and <option>-vf format=yuy2</option>
|
|
4152 if a codec fails or gives wrong output.
|
|
4153 </para>
|
|
4154
|
|
4155 <!-- ********** -->
|
|
4156
|
|
4157 <sect2 id="menc-feat-enc-vfw-video-codecs">
|
|
4158 <title>Video for Windows supported codecs</title>
|
|
4159
|
|
4160 <para>
|
|
4161 <informaltable frame="all">
|
|
4162 <tgroup cols="4">
|
|
4163 <thead>
|
|
4164 <row>
|
|
4165 <entry>Video codec file name</entry>
|
|
4166 <entry>Description (FourCC)</entry>
|
|
4167 <entry>md5sum</entry>
|
|
4168 <entry>Comment</entry>
|
|
4169 </row>
|
|
4170 </thead>
|
|
4171 <tbody>
|
|
4172 <row>
|
|
4173 <entry>aslcodec_vfw.dll</entry>
|
|
4174 <entry>Alparysoft lossless codec vfw (ASLC)</entry>
|
|
4175 <entry>608af234a6ea4d90cdc7246af5f3f29a</entry>
|
|
4176 <entry></entry>
|
|
4177 </row>
|
|
4178 <row>
|
|
4179 <entry>avimszh.dll</entry>
|
|
4180 <entry>AVImszh (MSZH)</entry>
|
|
4181 <entry>253118fe1eedea04a95ed6e5f4c28878</entry>
|
|
4182 <entry>needs <option>-vf format</option></entry>
|
|
4183 </row>
|
|
4184 <row>
|
|
4185 <entry>avizlib.dll</entry>
|
|
4186 <entry>AVIzlib (ZLIB)</entry>
|
|
4187 <entry>2f1cc76bbcf6d77d40d0e23392fa8eda</entry>
|
|
4188 <entry></entry>
|
|
4189 </row>
|
|
4190 <row>
|
|
4191 <entry>divx.dll</entry>
|
|
4192 <entry>DivX4Windows-VFW</entry>
|
|
4193 <entry>acf35b2fc004a89c829531555d73f1e6</entry>
|
|
4194 <entry></entry>
|
|
4195 </row>
|
|
4196 <row>
|
|
4197 <entry>huffyuv.dll</entry>
|
|
4198 <entry>HuffYUV (lossless) (HFYU)</entry>
|
|
4199 <entry>b74695b50230be4a6ef2c4293a58ac3b</entry>
|
|
4200 <entry></entry>
|
|
4201 </row>
|
|
4202 <row>
|
|
4203 <entry>iccvid.dll</entry>
|
|
4204 <entry>Cinepak Video (cvid)</entry>
|
|
4205 <entry>cb3b7ee47ba7dbb3d23d34e274895133</entry>
|
|
4206 <entry></entry>
|
|
4207 </row>
|
|
4208 <row>
|
|
4209 <entry>icmw_32.dll</entry>
|
|
4210 <entry>Motion Wavelets (MWV1)</entry>
|
|
4211 <entry>c9618a8fc73ce219ba918e3e09e227f2</entry>
|
|
4212 <entry></entry>
|
|
4213 </row>
|
|
4214 <row>
|
|
4215 <entry>jp2avi.dll</entry>
|
|
4216 <entry>ImagePower MJPEG2000 (IPJ2)</entry>
|
|
4217 <entry>d860a11766da0d0ea064672c6833768b</entry>
|
|
4218 <entry><option>-vf flip</option></entry>
|
|
4219 </row>
|
|
4220 <row>
|
|
4221 <entry>m3jp2k32.dll</entry>
|
|
4222 <entry>Morgan MJPEG2000 (MJ2C)</entry>
|
|
4223 <entry>f3c174edcbaef7cb947d6357cdfde7ff</entry>
|
|
4224 <entry></entry>
|
|
4225 </row>
|
|
4226 <row>
|
|
4227 <entry>m3jpeg32.dll</entry>
|
|
4228 <entry>Morgan Motion JPEG Codec (MJPG)</entry>
|
|
4229 <entry>1cd13fff5960aa2aae43790242c323b1</entry>
|
|
4230 <entry></entry>
|
|
4231 </row>
|
|
4232 <row>
|
|
4233 <entry>mpg4c32.dll</entry>
|
|
4234 <entry>Microsoft MPEG-4 v1/v2</entry>
|
|
4235 <entry>b5791ea23f33010d37ab8314681f1256</entry>
|
|
4236 <entry></entry>
|
|
4237 </row>
|
|
4238 <row>
|
|
4239 <entry>tsccvid.dll</entry>
|
|
4240 <entry>TechSmith Camtasia Screen Codec (TSCC)</entry>
|
|
4241 <entry>8230d8560c41d444f249802a2700d1d5</entry>
|
|
4242 <entry>shareware error on windows</entry>
|
|
4243 </row>
|
|
4244 <row>
|
|
4245 <entry>vp31vfw.dll</entry>
|
|
4246 <entry>On2 Open Source VP3 Codec (VP31)</entry>
|
|
4247 <entry>845f3590ea489e2e45e876ab107ee7d2</entry>
|
|
4248 <entry></entry>
|
|
4249 </row>
|
|
4250 <row>
|
|
4251 <entry>vp4vfw.dll</entry>
|
|
4252 <entry>On2 VP4 Personal Codec (VP40)</entry>
|
|
4253 <entry>fc5480a482ccc594c2898dcc4188b58f</entry>
|
|
4254 <entry></entry>
|
|
4255 </row>
|
|
4256 <row>
|
|
4257 <entry>vp6vfw.dll</entry>
|
|
4258 <entry>On2 VP6 Personal Codec (VP60)</entry>
|
|
4259 <entry>04d635a364243013898fd09484f913fb</entry>
|
|
4260 <entry></entry>
|
|
4261 </row>
|
|
4262 <row>
|
|
4263 <entry>vp7vfw.dll</entry>
|
|
4264 <entry>On2 VP7 Personal Codec (VP70)</entry>
|
|
4265 <entry>cb4cc3d4ea7c94a35f1d81c3d750bc8d</entry>
|
|
4266 <entry>wrong FourCC?</entry>
|
|
4267 </row>
|
|
4268 <row>
|
|
4269 <entry>ViVD2.dll</entry>
|
|
4270 <entry>SoftMedia ViVD V2 codec VfW (GXVE)</entry>
|
|
4271 <entry>a7b4bf5cac630bb9262c3f80d8a773a1</entry>
|
|
4272 <entry></entry>
|
|
4273 </row>
|
|
4274 <row>
|
|
4275 <entry>msulvc06.DLL</entry>
|
|
4276 <entry>MSU Lossless codec (MSUD)</entry>
|
|
4277 <entry>294bf9288f2f127bb86f00bfcc9ccdda</entry>
|
|
4278 <entry>
|
|
4279 Decodable by <application>Window Media Player</application>,
|
|
4280 not <application>MPlayer</application> (yet).
|
|
4281 </entry>
|
|
4282 </row>
|
|
4283 <row>
|
|
4284 <entry>camcodec.dll</entry>
|
|
4285 <entry>CamStudio lossless video codec (CSCD)</entry>
|
|
4286 <entry>0efe97ce08bb0e40162ab15ef3b45615</entry>
|
|
4287 <entry>sf.net/projects/camstudio</entry>
|
|
4288 </row>
|
|
4289 </tbody>
|
|
4290 </tgroup>
|
|
4291 </informaltable>
|
|
4292
|
|
4293 The first column contains the codec names that should be passed after the
|
|
4294 <literal>codec</literal> parameter,
|
|
4295 like: <option>-xvfwopts codec=divx.dll</option>
|
|
4296 The FourCC code used by each codec is given in the parentheses.
|
|
4297 </para>
|
|
4298
|
|
4299 <informalexample>
|
|
4300 <para>
|
|
4301 An example to convert an ISO DVD trailer to a VP6 flash video file
|
|
4302 using compdata bitrate settings:
|
|
4303 <screen>
|
|
4304 mencoder -dvd-device <replaceable>zeiram.iso</replaceable> dvd://7 -o <replaceable>trailer.flv</replaceable> \
|
|
4305 -ovc vfw -xvfwopts codec=vp6vfw.dll:compdata=onepass.mcf -oac mp3lame \
|
|
4306 -lameopts cbr:br=64 -af lavcresample=22050 -vf yadif,scale=320:240,flip \
|
|
4307 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
|
|
4308 </screen>
|
|
4309 </para>
|
|
4310 </informalexample>
|
|
4311 </sect2>
|
|
4312
|
|
4313 <sect2 id="menc-feat-video-for-windows-bitrate-settings">
|
|
4314 <title>Using vfw2menc to create a codec settings file.</title>
|
|
4315
|
|
4316 <para>
|
|
4317 To encode with the Video for Windows codecs, you will need to set bitrate
|
|
4318 and other options. This is known to work on x86 on both *NIX and Windows.
|
|
4319 </para>
|
|
4320 <para>
|
|
4321 First you must build the <application>vfw2menc</application> program.
|
|
4322 It is located in the <filename class="directory">TOOLS</filename> subdirectory
|
|
4323 of the MPlayer source tree.
|
|
4324 To build on Linux, this can be done using <application>Wine</application>:
|
|
4325 <screen>winegcc vfw2menc.c -o vfw2menc -lwinmm -lole32</screen>
|
|
4326
|
|
4327 To build on Windows in <application>MinGW</application> or
|
|
4328 <application>Cygwin</application> use:
|
|
4329 <screen>gcc vfw2menc.c -o vfw2menc.exe -lwinmm -lole32</screen>
|
|
4330
|
|
4331 To build on <application>MSVC</application> you will need getopt.
|
|
4332 Getopt can be found in the original <application>vfw2menc</application>
|
|
4333 archive available at:
|
|
4334 The <ulink url="http://oss.netfarm.it/mplayer-win32.php">MPlayer on win32</ulink> project.
|
|
4335 </para>
|
|
4336 <informalexample>
|
|
4337 <para>
|
|
4338 Below is an example with the VP6 codec.
|
|
4339 <screen>
|
|
4340 vfw2menc -f VP62 -d vp6vfw.dll -s firstpass.mcf
|
|
4341 </screen>
|
|
4342 This will open the VP6 codec dialog window.
|
|
4343 Repeat this step for the second pass
|
|
4344 and use <option>-s <replaceable>secondpass.mcf</replaceable></option>.
|
|
4345 </para>
|
|
4346 </informalexample>
|
|
4347 <para>
|
|
4348 Windows users can use
|
|
4349 <option>-xvfwopts codec=vp6vfw.dll:compdata=dialog</option> to have
|
|
4350 the codec dialog display before encoding starts.
|
|
4351 </para>
|
|
4352 </sect2>
|
|
4353 </sect1>
|
|
4354
|
|
4355
|
|
4356 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4357
|
|
4358
|
|
4359 <sect1 id="menc-feat-quicktime-7">
|
|
4360 <title>Using <application>MEncoder</application> to create
|
|
4361 <application>QuickTime</application>-compatible files</title>
|
|
4362
|
|
4363
|
|
4364 <sect2 id="menc-feat-quicktime-7-why-use-it">
|
|
4365 <title>Why would one want to produce <application>QuickTime</application>-compatible Files?</title>
|
|
4366
|
|
4367 <para>
|
|
4368 There are several reasons why producing
|
|
4369 <application>QuickTime</application>-compatible files can be desirable.
|
|
4370 </para>
|
|
4371 <itemizedlist>
|
|
4372 <listitem><para>
|
|
4373 You want any computer illiterate to be able to watch your encode on
|
|
4374 any major platform (Windows, Mac OS X, Unices …).
|
|
4375 </para></listitem>
|
|
4376 <listitem><para>
|
|
4377 <application>QuickTime</application> is able to take advantage of more
|
|
4378 hardware and software acceleration features of Mac OS X than
|
|
4379 platform-independent players like <application>MPlayer</application>
|
|
4380 or <application>VLC</application>.
|
|
4381 That means that your encodes have a chance to be played smoothly by older
|
|
4382 G4-powered machines.
|
|
4383 </para></listitem>
|
|
4384 <listitem><para>
|
|
4385 <application>QuickTime</application> 7 supports the next-generation codec H.264,
|
|
4386 which yields significantly better picture quality than previous codec
|
|
4387 generations (MPEG-2, MPEG-4 …).
|
|
4388 </para></listitem>
|
|
4389 </itemizedlist>
|
|
4390 </sect2>
|
|
4391
|
|
4392 <sect2 id="menc-feat-quicktime-7-constraints">
|
|
4393 <title><application>QuickTime</application> 7 limitations</title>
|
|
4394
|
|
4395 <para>
|
|
4396 <application>QuickTime</application> 7 supports H.264 video and AAC audio,
|
|
4397 but it does not support them muxed in the AVI container format.
|
|
4398 However, you can use <application>MEncoder</application> to encode
|
|
4399 the video and audio, and then use an external program such as
|
|
4400 <application>mp4creator</application> (part of the
|
|
4401 <ulink url="http://mpeg4ip.sourceforge.net/">MPEG4IP suite</ulink>)
|
|
4402 to remux the video and audio tracks into an MP4 container.
|
|
4403 </para>
|
|
4404
|
|
4405 <para>
|
|
4406 <application>QuickTime</application>'s support for H.264 is limited,
|
|
4407 so you will need to drop some advanced features.
|
|
4408 If you encode your video with features that
|
|
4409 <application>QuickTime</application> 7 does not support,
|
|
4410 <application>QuickTime</application>-based players will show you a pretty
|
|
4411 white screen instead of your expected video.
|
|
4412 </para>
|
|
4413
|
|
4414 <itemizedlist>
|
|
4415 <listitem><para>
|
|
4416 <emphasis role="bold">B-frames</emphasis>:
|
|
4417 <application>QuickTime</application> 7 supports a maximum of 1 B-frame, i.e.
|
|
4418 <option>-x264encopts bframes=1</option>. This means that
|
|
4419 <option>b_pyramid</option> and <option>weight_b</option> will have no
|
|
4420 effect, since they require <option>bframes</option> to be greater than 1.
|
|
4421 </para></listitem>
|
|
4422 <listitem><para>
|
|
4423 <emphasis role="bold">Macroblocks</emphasis>:
|
|
4424 <application>QuickTime</application> 7 does not support 8x8 DCT macroblocks.
|
|
4425 This option (<option>8x8dct</option>) is off by default, so just be sure
|
|
4426 not to explicitly enable it. This also means that the <option>i8x8</option>
|
|
4427 option will have no effect, since it requires <option>8x8dct</option>.
|
|
4428 </para></listitem>
|
|
4429 <listitem><para>
|
|
4430 <emphasis role="bold">Aspect ratio</emphasis>:
|
|
4431 <application>QuickTime</application> 7 does not support SAR (sample
|
|
4432 aspect ratio) information in MPEG-4 files; it assumes that SAR=1. Read
|
|
4433 <link linkend="menc-feat-quicktime-7-scale">the section on scaling</link>
|
|
4434 for a workaround.
|
|
4435 </para></listitem>
|
|
4436 </itemizedlist>
|
|
4437
|
|
4438 </sect2>
|
|
4439
|
|
4440 <sect2 id="menc-feat-quicktime-7-crop">
|
|
4441 <title>Cropping</title>
|
|
4442 <para>
|
|
4443 Suppose you want to rip your freshly bought copy of "The Chronicles of
|
|
4444 Narnia". Your DVD is region 1,
|
|
4445 which means it is NTSC. The example below would still apply to PAL,
|
|
4446 except you would omit <option>-ofps 24000/1001</option> and use slightly
|
|
4447 different <option>crop</option> and <option>scale</option> dimensions.
|
|
4448 </para>
|
|
4449
|
|
4450 <para>
|
|
4451 After running <option>mplayer dvd://1</option>, you follow the process
|
|
4452 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
4453 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
4454 24000/1001 fps progressive video. This simplifies the process somewhat,
|
|
4455 since you do not need to use an inverse telecine filter such as
|
|
4456 <option>pullup</option> or a deinterlacing filter such as
|
|
4457 <option>yadif</option>.
|
|
4458 </para>
|
|
4459
|
|
4460 <para>
|
|
4461 Next, you need to crop out the black bars from the top and bottom of the
|
|
4462 video, as detailed in <link linkend="menc-feat-dvd-mpeg4-example-crop">this</link>
|
|
4463 previous section.
|
|
4464 </para>
|
|
4465
|
|
4466 </sect2>
|
|
4467
|
|
4468 <sect2 id="menc-feat-quicktime-7-scale">
|
|
4469 <title>Scaling</title>
|
|
4470
|
|
4471 <para>
|
|
4472 The next step is truly heartbreaking.
|
|
4473 <application>QuickTime</application> 7 does not support MPEG-4 videos
|
|
4474 with a sample aspect ratio other than 1, so you will need to upscale
|
|
4475 (which wastes a lot of disk space) or downscale (which loses some
|
|
4476 details of the source) the video to square pixels.
|
|
4477 Either way you do it, this is highly inefficient, but simply cannot
|
|
4478 be avoided if you want your video to be playable by
|
|
4479 <application>QuickTime</application> 7.
|
|
4480 <application>MEncoder</application> can apply the appropriate upscaling
|
|
4481 or downscaling by specifying respectively <option>-vf scale=-10:-1</option>
|
|
4482 or <option>-vf scale=-1:-10</option>.
|
|
4483 This will scale your video to the correct width for the cropped height,
|
|
4484 rounded to the closest multiple of 16 for optimal compression.
|
|
4485 Remember that if you are cropping, you should crop first, then scale:
|
|
4486
|
|
4487 <screen>-vf crop=720:352:0:62,scale=-10:-1</screen>
|
|
4488 </para>
|
|
4489
|
|
4490 </sect2>
|
|
4491
|
|
4492 <sect2 id="menc-feat-quicktime-7-avsync">
|
|
4493 <title>A/V sync</title>
|
|
4494
|
|
4495 <para>
|
|
4496 Because you will be remuxing into a different container, you should
|
|
4497 always use the <option>harddup</option> option to ensure that duplicated
|
|
4498 frames are actually duplicated in the video output. Without this option,
|
|
4499 <application>MEncoder</application> will simply put a marker in the video
|
|
4500 stream that a frame was duplicated, and rely on the client software to
|
|
4501 show the same frame twice. Unfortunately, this "soft duplication" does
|
|
4502 not survive remuxing, so the audio would slowly lose sync with the video.
|
|
4503 </para>
|
|
4504
|
|
4505 <para>
|
|
4506 The final filter chain looks like this:
|
|
4507 <screen>-vf crop=720:352:0:62,scale=-10:-1,harddup</screen>
|
|
4508 </para>
|
|
4509
|
|
4510 </sect2>
|
|
4511
|
|
4512 <sect2 id="menc-feat-quicktime-7-bitrate">
|
|
4513 <title>Bitrate</title>
|
|
4514
|
|
4515 <para>
|
|
4516 As always, the selection of bitrate is a matter of the technical properties
|
|
4517 of the source, as explained
|
|
4518 <link linkend="menc-feat-dvd-mpeg4-resolution-bitrate">here</link>, as
|
|
4519 well as a matter of taste.
|
|
4520 This movie has a fair bit of action and lots of detail, but H.264 video
|
|
4521 looks good at much lower bitrates than XviD or other MPEG-4 codecs.
|
|
4522 After much experimentation, the author of this guide chose to encode
|
|
4523 this movie at 900kbps, and thought that it looked very good.
|
|
4524 You may decrease bitrate if you need to save more space, or increase
|
|
4525 it if you need to improve quality.
|
|
4526 </para>
|
|
4527
|
|
4528 </sect2>
|
|
4529
|
|
4530 <sect2 id="menc-feat-quicktime-7-example">
|
|
4531 <title>Encoding example</title>
|
|
4532
|
|
4533 <para>
|
|
4534 You are now ready to encode the video. Since you care about
|
|
4535 quality, of course you will be doing a two-pass encode. To shave off
|
|
4536 some encoding time, you can specify the <option>turbo</option> option
|
|
4537 on the first pass; this reduces <option>subq</option> and
|
|
4538 <option>frameref</option> to 1. To save some disk space, you can
|
|
4539 use the <option>ss</option> option to strip off the first few seconds
|
|
4540 of the video. (I found that this particular movie has 32 seconds of
|
|
4541 credits and logos.) <option>bframes</option> can be 0 or 1.
|
|
4542 The other options are documented in <link
|
|
4543 linkend="menc-feat-x264-encoding-options-speedvquality">Encoding with
|
|
4544 the <systemitem class="library">x264</systemitem> codec</link> and
|
|
4545 the man page.
|
|
4546
|
|
4547 <screen>mencoder dvd://1 -o /dev/null -ss 32 -ovc x264 \
|
|
4548 -x264encopts pass=1:turbo:bitrate=900:bframes=1:\
|
|
4549 me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
|
|
4550 -vf crop=720:352:0:62,scale=-10:-1,harddup \
|
|
4551 -oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
|
|
4552 -ofps 24000/1001</screen>
|
|
4553
|
|
4554 If you have a multi-processor machine, don't miss the opportunity to
|
|
4555 dramatically speed-up encoding by enabling
|
|
4556 <link linkend="menc-feat-x264-encoding-options-speedvquality-threads">
|
|
4557 <systemitem class="library">x264</systemitem>'s multi-threading mode</link>
|
|
4558 by adding <option>threads=auto</option> to your <option>x264encopts</option>
|
|
4559 command-line.
|
|
4560 </para>
|
|
4561
|
|
4562 <para>
|
|
4563 The second pass is the same, except that you specify the output file
|
|
4564 and set <option>pass=2</option>.
|
|
4565
|
|
4566 <screen>mencoder dvd://1 <emphasis role="bold">-o narnia.avi</emphasis> -ss 32 -ovc x264 \
|
|
4567 -x264encopts <emphasis role="bold">pass=2</emphasis>:turbo:bitrate=900:frameref=5:bframes=1:\
|
|
4568 me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
|
|
4569 -vf crop=720:352:0:62,scale=-10:-1,harddup \
|
|
4570 -oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
|
|
4571 -ofps 24000/1001</screen>
|
|
4572 </para>
|
|
4573
|
|
4574 <para>
|
|
4575 The resulting AVI should play perfectly in
|
|
4576 <application>MPlayer</application>, but of course
|
|
4577 <application>QuickTime</application> can not play it because it does
|
|
4578 not support H.264 muxed in AVI.
|
|
4579 So the next step is to remux the video into an MP4 container.
|
|
4580 </para>
|
|
4581 </sect2>
|
|
4582
|
|
4583 <sect2 id="menc-feat-quicktime-7-remux">
|
|
4584 <title>Remuxing as MP4</title>
|
|
4585
|
|
4586 <para>
|
|
4587 There are several ways to remux AVI files to MP4. You can use
|
|
4588 <application>mp4creator</application>, which is part of the
|
|
4589 <ulink url="http://mpeg4ip.sourceforge.net/">MPEG4IP suite</ulink>.
|
|
4590 </para>
|
|
4591
|
|
4592 <para>
|
|
4593 First, demux the AVI into separate audio and video streams using
|
|
4594 <application>MPlayer</application>.
|
|
4595
|
|
4596 <screen>mplayer narnia.avi -dumpaudio -dumpfile narnia.aac
|
|
4597 mplayer narnia.avi -dumpvideo -dumpfile narnia.h264</screen>
|
|
4598
|
|
4599 The filenames are important; <application>mp4creator</application>
|
|
4600 requires that AAC audio streams be named <systemitem>.aac</systemitem>
|
|
4601 and H.264 video streams be named <systemitem>.h264</systemitem>.
|
|
4602 </para>
|
|
4603
|
|
4604 <para>
|
|
4605 Now use <application>mp4creator</application> to create a new
|
|
4606 MP4 file out of the audio and video streams.
|
|
4607
|
|
4608 <screen>mp4creator -create=narnia.aac narnia.mp4
|
|
4609 mp4creator -create=narnia.h264 -rate=23.976 narnia.mp4</screen>
|
|
4610
|
|
4611 Unlike the encoding step, you must specify the framerate as a
|
|
4612 decimal (such as 23.976), not a fraction (such as 24000/1001).
|
|
4613 </para>
|
|
4614
|
|
4615 <para>
|
|
4616 This <systemitem>narnia.mp4</systemitem> file should now be playable
|
|
4617 with any <application>QuickTime</application> 7 application, such as
|
|
4618 <application>QuickTime Player</application> or
|
|
4619 <application>iTunes</application>. If you are planning to view the
|
|
4620 video in a web browser with the <application>QuickTime</application>
|
|
4621 plugin, you should also hint the movie so that the
|
|
4622 <application>QuickTime</application> plugin can start playing it
|
|
4623 while it is still downloading. <application>mp4creator</application>
|
|
4624 can create these hint tracks:
|
|
4625
|
|
4626 <screen>mp4creator -hint=1 narnia.mp4
|
|
4627 mp4creator -hint=2 narnia.mp4
|
|
4628 mp4creator -optimize narnia.mp4</screen>
|
|
4629
|
|
4630 You can check the final result to ensure that the hint tracks were
|
|
4631 created successfully:
|
|
4632
|
|
4633 <screen>mp4creator -list narnia.mp4</screen>
|
|
4634
|
|
4635 You should see a list of tracks: 1 audio, 1 video, and 2 hint tracks.
|
|
4636
|
|
4637 <screen>Track Type Info
|
|
4638 1 audio MPEG-4 AAC LC, 8548.714 secs, 190 kbps, 48000 Hz
|
|
4639 2 video H264 Main@5.1, 8549.132 secs, 899 kbps, 848x352 @ 23.976001 fps
|
|
4640 3 hint Payload mpeg4-generic for track 1
|
|
4641 4 hint Payload H264 for track 2
|
|
4642 </screen>
|
|
4643 </para>
|
|
4644
|
|
4645 </sect2>
|
|
4646
|
|
4647 <sect2 id="menc-feat-quicktime-7-metadata">
|
|
4648 <title>Adding metadata tags</title>
|
|
4649
|
|
4650 <para>
|
|
4651 If you want to add tags to your video that show up in iTunes, you can use
|
|
4652 <ulink url="http://atomicparsley.sourceforge.net/">AtomicParsley</ulink>.
|
|
4653
|
|
4654 <screen>AtomicParsley narnia.mp4 --metaEnema --title "The Chronicles of Narnia" --year 2005 --stik Movie --freefree --overWrite</screen>
|
|
4655
|
|
4656 The <option>--metaEnema</option> option removes any existing metadata
|
|
4657 (<application>mp4creator</application> inserts its name in the
|
|
4658 "encoding tool" tag), and <option>--freefree</option> reclaims the
|
|
4659 space from the deleted metadata.
|
|
4660 The <option>--stik</option> option sets the type of video (such as Movie
|
|
4661 or TV Show), which iTunes uses to group related video files.
|
|
4662 The <option>--overWrite</option> option overwrites the original file;
|
|
4663 without it, <application>AtomicParsley</application> creates a new
|
|
4664 auto-named file in the same directory and leaves the original file
|
|
4665 untouched.
|
|
4666 </para>
|
|
4667
|
|
4668 </sect2>
|
|
4669
|
|
4670 </sect1>
|
|
4671
|
|
4672
|
|
4673 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4674
|
|
4675
|
|
4676 <sect1 id="menc-feat-vcd-dvd">
|
|
4677 <title>Using <application>MEncoder</application>
|
|
4678 to create VCD/SVCD/DVD-compliant files</title>
|
|
4679
|
|
4680 <sect2 id="menc-feat-vcd-dvd-constraints">
|
|
4681 <title>Format Constraints</title>
|
|
4682
|
|
4683 <para>
|
|
4684 <application>MEncoder</application> is capable of creating VCD, SCVD
|
|
4685 and DVD format MPEG files using the
|
|
4686 <systemitem class="library">libavcodec</systemitem> library.
|
|
4687 These files can then be used in conjunction with
|
|
4688 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>
|
|
4689 or
|
|
4690 <ulink url="http://dvdauthor.sourceforge.net/">dvdauthor</ulink>
|
|
4691 to create discs that will play on a standard set-top player.
|
|
4692 </para>
|
|
4693
|
|
4694 <para>
|
|
4695 The DVD, SVCD, and VCD formats are subject to heavy constraints.
|
|
4696 Only a small selection of encoded picture sizes and aspect ratios are
|
|
4697 available.
|
|
4698 If your movie does not already meet these requirements, you may have
|
|
4699 to scale, crop or add black borders to the picture to make it
|
|
4700 compliant.
|
|
4701 </para>
|
|
4702
|
|
4703
|
|
4704 <sect3 id="menc-feat-vcd-dvd-constraints-resolution">
|
|
4705 <title>Format Constraints</title>
|
|
4706
|
|
4707 <informaltable frame="all">
|
|
4708 <tgroup cols="9">
|
|
4709 <thead>
|
|
4710 <row>
|
|
4711 <entry>Format</entry>
|
|
4712 <entry>Resolution</entry>
|
|
4713 <entry>V. Codec</entry>
|
|
4714 <entry>V. Bitrate</entry>
|
|
4715 <entry>Sample Rate</entry>
|
|
4716 <entry>A. Codec</entry>
|
|
4717 <entry>A. Bitrate</entry>
|
|
4718 <entry>FPS</entry>
|
|
4719 <entry>Aspect</entry>
|
|
4720 </row>
|
|
4721 </thead>
|
|
4722 <tbody>
|
|
4723 <row>
|
|
4724 <entry>NTSC DVD</entry>
|
|
4725 <entry>720x480, 704x480, 352x480, 352x240</entry>
|
|
4726 <entry>MPEG-2</entry>
|
|
4727 <entry>9800 kbps</entry>
|
|
4728 <entry>48000 Hz</entry>
|
|
4729 <entry>AC-3,PCM</entry>
|
|
4730 <entry>1536 kbps (max)</entry>
|
|
4731 <entry>30000/1001, 24000/1001</entry>
|
|
4732 <entry>4:3, 16:9 (only for 720x480)</entry>
|
|
4733 </row>
|
|
4734 <row>
|
|
4735 <entry>NTSC DVD</entry>
|
|
4736 <entry>352x240<footnote id='fn-rare-resolutions'><para>
|
|
4737 These resolutions are rarely used for DVDs because
|
|
4738 they are fairly low quality.</para></footnote></entry>
|
|
4739 <entry>MPEG-1</entry>
|
|
4740 <entry>1856 kbps</entry>
|
|
4741 <entry>48000 Hz</entry>
|
|
4742 <entry>AC-3,PCM</entry>
|
|
4743 <entry>1536 kbps (max)</entry>
|
|
4744 <entry>30000/1001, 24000/1001</entry>
|
|
4745 <entry>4:3, 16:9</entry>
|
|
4746 </row>
|
|
4747 <row>
|
|
4748 <entry>NTSC SVCD</entry>
|
|
4749 <entry>480x480</entry>
|
|
4750 <entry>MPEG-2</entry>
|
|
4751 <entry>2600 kbps</entry>
|
|
4752 <entry>44100 Hz</entry>
|
|
4753 <entry>MP2</entry>
|
|
4754 <entry>384 kbps (max)</entry>
|
|
4755 <entry>30000/1001</entry>
|
|
4756 <entry>4:3</entry>
|
|
4757 </row>
|
|
4758 <row>
|
|
4759 <entry>NTSC VCD</entry>
|
|
4760 <entry>352x240</entry>
|
|
4761 <entry>MPEG-1</entry>
|
|
4762 <entry>1150 kbps</entry>
|
|
4763 <entry>44100 Hz</entry>
|
|
4764 <entry>MP2</entry>
|
|
4765 <entry>224 kbps</entry>
|
|
4766 <entry>24000/1001, 30000/1001</entry>
|
|
4767 <entry>4:3</entry>
|
|
4768 </row>
|
|
4769 <row>
|
|
4770 <entry>PAL DVD</entry>
|
|
4771 <entry>720x576, 704x576, 352x576, 352x288</entry>
|
|
4772 <entry>MPEG-2</entry>
|
|
4773 <entry>9800 kbps</entry>
|
|
4774 <entry>48000 Hz</entry>
|
|
4775 <entry>MP2,AC-3,PCM</entry>
|
|
4776 <entry>1536 kbps (max)</entry>
|
|
4777 <entry>25</entry>
|
|
4778 <entry>4:3, 16:9 (only for 720x576)</entry>
|
|
4779 </row>
|
|
4780 <row>
|
|
4781 <entry>PAL DVD</entry>
|
|
4782 <entry>352x288<footnoteref linkend='fn-rare-resolutions'/></entry>
|
|
4783 <entry>MPEG-1</entry>
|
|
4784 <entry>1856 kbps</entry>
|
|
4785 <entry>48000 Hz</entry>
|
|
4786 <entry>MP2,AC-3,PCM</entry>
|
|
4787 <entry>1536 kbps (max)</entry>
|
|
4788 <entry>25</entry>
|
|
4789 <entry>4:3, 16:9</entry>
|
|
4790 </row>
|
|
4791 <row>
|
|
4792 <entry>PAL SVCD</entry>
|
|
4793 <entry>480x576</entry>
|
|
4794 <entry>MPEG-2</entry>
|
|
4795 <entry>2600 kbps</entry>
|
|
4796 <entry>44100 Hz</entry>
|
|
4797 <entry>MP2</entry>
|
|
4798 <entry>384 kbps (max)</entry>
|
|
4799 <entry>25</entry>
|
|
4800 <entry>4:3</entry>
|
|
4801 </row>
|
|
4802 <row>
|
|
4803 <entry>PAL VCD</entry>
|
|
4804 <entry>352x288</entry>
|
|
4805 <entry>MPEG-1</entry>
|
|
4806 <entry>1152 kbps</entry>
|
|
4807 <entry>44100 Hz</entry>
|
|
4808 <entry>MP2</entry>
|
|
4809 <entry>224 kbps</entry>
|
|
4810 <entry>25</entry>
|
|
4811 <entry>4:3</entry>
|
|
4812 </row>
|
|
4813 </tbody>
|
|
4814 </tgroup>
|
|
4815 </informaltable>
|
|
4816
|
|
4817 <para>
|
|
4818 If your movie has 2.35:1 aspect (most recent action movies), you will
|
|
4819 have to add black borders or crop the movie down to 16:9 to make a DVD or VCD.
|
|
4820 If you add black borders, try to align them at 16-pixel boundaries in
|
|
4821 order to minimize the impact on encoding performance.
|
|
4822 Thankfully DVD has sufficiently excessive bitrate that you do not have
|
|
4823 to worry too much about encoding efficiency, but SVCD and VCD are
|
|
4824 highly bitrate-starved and require effort to obtain acceptable quality.
|
|
4825 </para>
|
|
4826 </sect3>
|
|
4827
|
|
4828
|
|
4829 <sect3 id="menc-feat-vcd-dvd-constraints-gop">
|
|
4830 <title>GOP Size Constraints</title>
|
|
4831
|
|
4832 <para>
|
|
4833 DVD, VCD, and SVCD also constrain you to relatively low
|
|
4834 GOP (Group of Pictures) sizes.
|
|
4835 For 30 fps material the largest allowed GOP size is 18.
|
|
4836 For 25 or 24 fps, the maximum is 15.
|
|
4837 The GOP size is set using the <option>keyint</option> option.
|
|
4838 </para>
|
|
4839 </sect3>
|
|
4840
|
|
4841
|
|
4842 <sect3 id="menc-feat-vcd-dvd-constraints-bitrate">
|
|
4843 <title>Bitrate Constraints</title>
|
|
4844
|
|
4845 <para>
|
|
4846 VCD video is required to be CBR at 1152 kbps.
|
|
4847 This highly limiting constraint also comes along with an extremly low vbv
|
|
4848 buffer size of 327 kilobits.
|
|
4849 SVCD allows varying video bitrates up to 2500 kbps, and a somewhat less
|
|
4850 restrictive vbv buffer size of 917 kilobits is allowed.
|
|
4851 DVD video bitrates may range anywhere up to 9800 kbps (though typical
|
|
4852 bitrates are about half that), and the vbv buffer size is 1835 kilobits.
|
|
4853 </para>
|
|
4854 </sect3>
|
|
4855 </sect2>
|
|
4856
|
|
4857 <!-- ********** -->
|
|
4858
|
|
4859 <sect2 id="menc-feat-vcd-dvd-output">
|
|
4860 <title>Output Options</title>
|
|
4861
|
|
4862 <para>
|
|
4863 <application>MEncoder</application> has options to control the output
|
|
4864 format.
|
|
4865 Using these options we can instruct it to create the correct type of
|
|
4866 file.
|
|
4867 </para>
|
|
4868
|
|
4869 <para>
|
|
4870 The options for VCD and SVCD are called xvcd and xsvcd, because they
|
|
4871 are extended formats.
|
|
4872 They are not strictly compliant, mainly because the output does not
|
|
4873 contain scan offsets.
|
|
4874 If you need to generate an SVCD image, you should pass the output file to
|
|
4875 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>.
|
|
4876 </para>
|
|
4877
|
|
4878 <para>
|
|
4879 VCD:
|
|
4880 <screen>-of mpeg -mpegopts format=xvcd</screen>
|
|
4881 </para>
|
|
4882
|
|
4883 <para>
|
|
4884 SVCD:
|
|
4885 <screen>-of mpeg -mpegopts format=xsvcd</screen>
|
|
4886 </para>
|
|
4887
|
|
4888 <para>
|
|
4889 DVD (with timestamps on every frame, if possible):
|
|
4890 <screen>-of mpeg -mpegopts format=dvd:tsaf</screen>
|
|
4891 </para>
|
|
4892
|
|
4893 <para>
|
|
4894 DVD with NTSC Pullup:
|
|
4895 <screen>-of mpeg -mpegopts format=dvd:tsaf:telecine -ofps 24000/1001</screen>
|
|
4896 This allows 24000/1001 fps progressive content to be encoded at 30000/1001
|
|
4897 fps whilst maintaing DVD-compliance.
|
|
4898 </para>
|
|
4899
|
|
4900
|
|
4901 <sect3 id="menc-feat-vcd-dvd-output-aspect">
|
|
4902 <title>Aspect Ratio</title>
|
|
4903
|
|
4904 <para>
|
|
4905 The aspect argument of <option>-lavcopts</option> is used to encode
|
|
4906 the aspect ratio of the file.
|
|
4907 During playback the aspect ratio is used to restore the video to the
|
|
4908 correct size.
|
|
4909 </para>
|
|
4910
|
|
4911 <para>
|
|
4912 16:9 or "Widescreen"
|
|
4913 <screen>-lavcopts aspect=16/9</screen>
|
|
4914 </para>
|
|
4915
|
|
4916 <para>
|
|
4917 4:3 or "Fullscreen"
|
|
4918 <screen>-lavcopts aspect=4/3</screen>
|
|
4919 </para>
|
|
4920
|
|
4921 <para>
|
|
4922 2.35:1 or "Cinemascope" NTSC
|
|
4923 <screen>-vf scale=720:368,expand=720:480 -lavcopts aspect=16/9</screen>
|
|
4924 To calculate the correct scaling size, use the expanded NTSC width of
|
|
4925 854/2.35 = 368
|
|
4926 </para>
|
|
4927
|
|
4928 <para>
|
|
4929 2.35:1 or "Cinemascope" PAL
|
|
4930 <screen>-vf scale=720:432,expand=720:576 -lavcopts aspect=16/9</screen>
|
|
4931 To calculate the correct scaling size, use the expanded PAL width of
|
|
4932 1024/2.35 = 432
|
|
4933 </para>
|
|
4934 </sect3>
|
|
4935
|
|
4936
|
|
4937 <sect3 id="menc-feat-vcd-dvd-a-v-sync">
|
|
4938 <title>Maintaining A/V sync</title>
|
|
4939
|
|
4940 <para>
|
|
4941 In order to maintain audio/video synchronization throughout the encode,
|
|
4942 <application>MEncoder</application> has to drop or duplicate frames.
|
|
4943 This works rather well when muxing into an AVI file, but is almost
|
|
4944 guaranteed to fail to maintain A/V sync with other muxers such as MPEG.
|
|
4945 This is why it is necessary to append the
|
|
4946 <option>harddup</option> video filter at the end of the filter chain
|
|
4947 to avoid this kind of problem.
|
|
4948 You can find more technical information about <option>harddup</option>
|
|
4949 in the section
|
|
4950 <link linkend="menc-feat-dvd-mpeg4-muxing-filter-issues">Improving muxing and A/V sync reliability</link>
|
|
4951 or in the manual page.
|
|
4952 </para>
|
|
4953 </sect3>
|
|
4954
|
|
4955
|
|
4956 <sect3 id="menc-feat-vcd-dvd-output-srate">
|
|
4957 <title>Sample Rate Conversion</title>
|
|
4958
|
|
4959 <para>
|
|
4960 If the audio sample rate in the original file is not the same as
|
|
4961 required by the target format, sample rate conversion is required.
|
|
4962 This is achieved using the <option>-srate</option> option and
|
|
4963 the <option>-af lavcresample</option> audio filter together.
|
|
4964 </para>
|
|
4965
|
|
4966 <para>
|
|
4967 DVD:
|
|
4968 <screen>-srate 48000 -af lavcresample=48000</screen>
|
|
4969 </para>
|
|
4970
|
|
4971 <para>
|
|
4972 VCD and SVCD:
|
|
4973 <screen>-srate 44100 -af lavcresample=44100</screen>
|
|
4974 </para>
|
|
4975 </sect3>
|
|
4976 </sect2>
|
|
4977
|
|
4978 <!-- ********** -->
|
|
4979
|
|
4980 <sect2 id="menc-feat-vcd-dvd-lavc">
|
|
4981 <title>Using libavcodec for VCD/SVCD/DVD Encoding</title>
|
|
4982
|
|
4983 <sect3 id="menc-feat-vcd-dvd-lavc-intro">
|
|
4984 <title>Introduction</title>
|
|
4985
|
|
4986 <para>
|
|
4987 <systemitem class="library">libavcodec</systemitem> can be used to
|
|
4988 create VCD/SVCD/DVD compliant video by using the appropriate options.
|
|
4989 </para>
|
|
4990 </sect3>
|
|
4991
|
|
4992
|
|
4993 <sect3 id="menc-feat-vcd-dvd-lavc-options">
|
|
4994 <title>lavcopts</title>
|
|
4995
|
|
4996 <para>
|
|
4997 This is a list of fields in <option>-lavcopts</option> that you may
|
|
4998 be required to change in order to make a complaint movie for VCD, SVCD,
|
|
4999 or DVD:
|
|
5000 </para>
|
|
5001
|
|
5002 <itemizedlist>
|
|
5003 <listitem><para>
|
|
5004 <emphasis role="bold">acodec</emphasis>:
|
|
5005 <option>mp2</option> for VCD, SVCD, or PAL DVD;
|
|
5006 <option>ac3</option> is most commonly used for DVD.
|
|
5007 PCM audio may also be used for DVD, but this is mostly a big waste of
|
|
5008 space.
|
|
5009 Note that MP3 audio is not compliant for any of these formats, but
|
|
5010 players often have no problem playing it anyway.
|
|
5011 </para></listitem>
|
|
5012 <listitem><para>
|
|
5013 <emphasis role="bold">abitrate</emphasis>:
|
|
5014 224 for VCD; up to 384 for SVCD; up to 1536 for DVD, but commonly
|
|
5015 used values range from 192 kbps for stereo to 384 kbps for 5.1 channel
|
|
5016 sound.
|
|
5017 </para></listitem>
|
|
5018 <listitem><para>
|
|
5019 <emphasis role="bold">vcodec</emphasis>:
|
|
5020 <option>mpeg1video</option> for VCD;
|
|
5021 <option>mpeg2video</option> for SVCD;
|
|
5022 <option>mpeg2video</option> is usually used for DVD but you may also use
|
|
5023 <option>mpeg1video</option> for CIF resolutions.
|
|
5024 </para></listitem>
|
|
5025 <listitem><para>
|
|
5026 <emphasis role="bold">keyint</emphasis>:
|
|
5027 Used to set the GOP size.
|
|
5028 18 for 30fps material, or 15 for 25/24 fps material.
|
|
5029 Commercial producers seem to prefer keyframe intervals of 12.
|
|
5030 It is possible to make this much larger and still retain compatibility
|
|
5031 with most players.
|
|
5032 A <option>keyint</option> of 25 should never cause any problems.
|
|
5033 </para></listitem>
|
|
5034 <listitem><para>
|
|
5035 <emphasis role="bold">vrc_buf_size</emphasis>:
|
|
5036 327 for VCD, 917 for SVCD, and 1835 for DVD.
|
|
5037 </para></listitem>
|
|
5038 <listitem><para>
|
|
5039 <emphasis role="bold">vrc_minrate</emphasis>:
|
|
5040 1152, for VCD. May be left alone for SVCD and DVD.
|
|
5041 </para></listitem>
|
|
5042 <listitem><para>
|
|
5043 <emphasis role="bold">vrc_maxrate</emphasis>:
|
|
5044 1152 for VCD; 2500 for SVCD; 9800 for DVD.
|
|
5045 For SVCD and DVD, you might wish to use lower values depending on your
|
|
5046 own personal preferences and requirements.
|
|
5047 </para></listitem>
|
|
5048 <listitem><para>
|
|
5049 <emphasis role="bold">vbitrate</emphasis>:
|
|
5050 1152 for VCD;
|
|
5051 up to 2500 for SVCD;
|
|
5052 up to 9800 for DVD.
|
|
5053 For the latter two formats, vbitrate should be set based on personal
|
|
5054 preference.
|
|
5055 For instance, if you insist on fitting 20 or so hours on a DVD, you
|
|
5056 could use vbitrate=400.
|
|
5057 The resulting video quality would probably be quite bad.
|
|
5058 If you are trying to squeeze out the maximum possible quality on a DVD,
|
|
5059 use vbitrate=9800, but be warned that this could constrain you to less
|
|
5060 than an hour of video on a single-layer DVD.
|
|
5061 </para></listitem>
|
|
5062 <listitem><para>
|
|
5063 <emphasis role="bold">vstrict</emphasis>:
|
|
5064 <option>vstrict</option>=0 should be used to create DVDs.
|
|
5065 Without this option, <application>MEncoder</application> creates a
|
|
5066 stream that cannot be correctly decoded by some standalone DVD
|
|
5067 players.
|
|
5068 </para></listitem>
|
|
5069 </itemizedlist>
|
|
5070 </sect3>
|
|
5071
|
|
5072
|
|
5073 <sect3 id="menc-feat-vcd-dvd-lavc-examples">
|
|
5074 <title>Examples</title>
|
|
5075
|
|
5076 <para>
|
|
5077 This is a typical minimum set of <option>-lavcopts</option> for
|
|
5078 encoding video:
|
|
5079 </para>
|
|
5080 <para>
|
|
5081 VCD:
|
|
5082 <screen>
|
|
5083 -lavcopts vcodec=mpeg1video:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5084 vrc_maxrate=1152:vbitrate=1152:keyint=15:acodec=mp2
|
|
5085 </screen>
|
|
5086 </para>
|
|
5087
|
|
5088 <para>
|
|
5089 SVCD:
|
|
5090 <screen>
|
|
5091 -lavcopts vcodec=mpeg2video:vrc_buf_size=917:vrc_maxrate=2500:vbitrate=1800:\
|
|
5092 keyint=15:acodec=mp2
|
|
5093 </screen>
|
|
5094 </para>
|
|
5095
|
|
5096 <para>
|
|
5097 DVD:
|
|
5098 <screen>
|
|
5099 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5100 keyint=15:vstrict=0:acodec=ac3
|
|
5101 </screen>
|
|
5102 </para>
|
|
5103 </sect3>
|
|
5104
|
|
5105
|
|
5106 <sect3 id="menc-feat-vcd-dvd-lavc-advanced">
|
|
5107 <title>Advanced Options</title>
|
|
5108
|
|
5109 <para>
|
|
5110 For higher quality encoding, you may also wish to add quality-enhancing
|
|
5111 options to lavcopts, such as <option>trell</option>,
|
|
5112 <option>mbd=2</option>, and others.
|
|
5113 Note that <option>qpel</option> and <option>v4mv</option>, while often
|
|
5114 useful with MPEG-4, are not usable with MPEG-1 or MPEG-2.
|
|
5115 Also, if you are trying to make a very high quality DVD encode, it may
|
|
5116 be useful to add <option>dc=10</option> to lavcopts.
|
|
5117 Doing so may help reduce the appearance of blocks in flat-colored areas.
|
|
5118 Putting it all together, this is an example of a set of lavcopts for a
|
|
5119 higher quality DVD:
|
|
5120 </para>
|
|
5121
|
|
5122 <para>
|
|
5123 <screen>
|
|
5124 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:\
|
|
5125 keyint=15:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:\
|
|
5126 vqmin=1:lmin=1:dc=10:vstrict=0
|
|
5127 </screen>
|
|
5128 </para>
|
|
5129 </sect3>
|
|
5130 </sect2>
|
|
5131
|
|
5132 <!-- ********** -->
|
|
5133
|
|
5134 <sect2 id="menc-feat-vcd-dvd-audio">
|
|
5135 <title>Encoding Audio</title>
|
|
5136
|
|
5137 <para>
|
|
5138 VCD and SVCD support MPEG-1 layer II audio, using one of
|
|
5139 <systemitem class="library">toolame</systemitem>,
|
|
5140 <systemitem class="library">twolame</systemitem>,
|
|
5141 or <systemitem class="library">libavcodec</systemitem>'s MP2 encoder.
|
|
5142 The libavcodec MP2 is far from being as good as the other two libraries,
|
|
5143 however it should always be available to use.
|
|
5144 VCD only supports constant bitrate audio (CBR) whereas SVCD supports
|
|
5145 variable bitrate (VBR), too.
|
|
5146 Be careful when using VBR because some bad standalone players might not
|
|
5147 support it too well.
|
|
5148 </para>
|
|
5149
|
|
5150 <para>
|
|
5151 For DVD audio, <systemitem class="library">libavcodec</systemitem>'s
|
|
5152 AC-3 codec is used.
|
|
5153 </para>
|
|
5154
|
|
5155
|
|
5156 <sect3 id="menc-feat-vcd-dvd-audio-toolame">
|
|
5157 <title>toolame</title>
|
|
5158
|
|
5159 <para>
|
|
5160 For VCD and SVCD:
|
|
5161 <screen>-oac toolame -toolameopts br=224</screen>
|
|
5162 </para>
|
|
5163 </sect3>
|
|
5164
|
|
5165
|
|
5166 <sect3 id="menc-feat-vcd-dvd-audio-twolame">
|
|
5167 <title>twolame</title>
|
|
5168
|
|
5169 <para>
|
|
5170 For VCD and SVCD:
|
|
5171 <screen>-oac twolame -twolameopts br=224</screen>
|
|
5172 </para>
|
|
5173 </sect3>
|
|
5174
|
|
5175
|
|
5176 <sect3 id="menc-feat-vcd-dvd-audio-lavc">
|
|
5177 <title>libavcodec</title>
|
|
5178
|
|
5179 <para>
|
|
5180 For DVD with 2 channel sound:
|
|
5181 <screen>-oac lavc -lavcopts acodec=ac3:abitrate=192</screen>
|
|
5182 </para>
|
|
5183
|
|
5184 <para>
|
|
5185 For DVD with 5.1 channel sound:
|
|
5186 <screen>-channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=384</screen>
|
|
5187 </para>
|
|
5188
|
|
5189 <para>
|
|
5190 For VCD and SVCD:
|
|
5191 <screen>-oac lavc -lavcopts acodec=mp2:abitrate=224</screen>
|
|
5192 </para>
|
|
5193 </sect3>
|
|
5194 </sect2>
|
|
5195
|
|
5196 <!-- ********** -->
|
|
5197
|
|
5198 <sect2 id="menc-feat-vcd-dvd-all">
|
|
5199 <title>Putting it all Together</title>
|
|
5200
|
|
5201 <para>
|
|
5202 This section shows some complete commands for creating VCD/SVCD/DVD
|
|
5203 compliant videos.
|
|
5204 </para>
|
|
5205
|
|
5206
|
|
5207 <sect3 id="menc-feat-vcd-dvd-all-pal-dvd">
|
|
5208 <title>PAL DVD</title>
|
|
5209
|
|
5210 <para>
|
|
5211 <screen>
|
|
5212 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5213 -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 \
|
|
5214 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5215 keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 \
|
|
5216 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5217 </screen>
|
|
5218 </para>
|
|
5219 </sect3>
|
|
5220
|
|
5221
|
|
5222 <sect3 id="menc-feat-vcd-dvd-all-ntsc-dvd">
|
|
5223 <title>NTSC DVD</title>
|
|
5224
|
|
5225 <para>
|
|
5226 <screen>
|
|
5227 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5228 -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \
|
|
5229 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5230 keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 30000/1001 \
|
|
5231 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5232 </screen>
|
|
5233 </para>
|
|
5234 </sect3>
|
|
5235
|
|
5236
|
|
5237 <sect3 id="menc-feat-vcd-dvd-all-pal-ac3-copy">
|
|
5238 <title>PAL AVI Containing AC-3 Audio to DVD</title>
|
|
5239
|
|
5240 <para>
|
|
5241 If the source already has AC-3 audio, use -oac copy instead of re-encoding it.
|
|
5242 <screen>
|
|
5243 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5244 -vf scale=720:576,harddup -ofps 25 \
|
|
5245 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5246 keyint=15:vstrict=0:aspect=16/9 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5247 </screen>
|
|
5248 </para>
|
|
5249 </sect3>
|
|
5250
|
|
5251
|
|
5252 <sect3 id="menc-feat-vcd-dvd-all-ntsc-ac3-copy">
|
|
5253 <title>NTSC AVI Containing AC-3 Audio to DVD</title>
|
|
5254
|
|
5255 <para>
|
|
5256 If the source already has AC-3 audio, and is NTSC @ 24000/1001 fps:
|
|
5257 <screen>
|
|
5258 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf:telecine \
|
|
5259 -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:\
|
|
5260 vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:aspect=16/9 -ofps 24000/1001 \
|
|
5261 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5262 </screen>
|
|
5263 </para>
|
|
5264 </sect3>
|
|
5265
|
|
5266
|
|
5267 <sect3 id="menc-feat-vcd-dvd-all-pal-svcd">
|
|
5268 <title>PAL SVCD</title>
|
|
5269
|
|
5270 <para>
|
|
5271 <screen>
|
|
5272 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
5273 scale=480:576,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5274 vcodec=mpeg2video:mbd=2:keyint=15:vrc_buf_size=917:vrc_minrate=600:\
|
|
5275 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 25 \
|
|
5276 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5277 </screen>
|
|
5278 </para>
|
|
5279 </sect3>
|
|
5280
|
|
5281
|
|
5282 <sect3 id="menc-feat-vcd-dvd-all-ntsc-svcd">
|
|
5283 <title>NTSC SVCD</title>
|
|
5284
|
|
5285 <para>
|
|
5286 <screen>
|
|
5287 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
5288 scale=480:480,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5289 vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:\
|
|
5290 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
5291 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5292 </screen>
|
|
5293 </para>
|
|
5294 </sect3>
|
|
5295
|
|
5296
|
|
5297 <sect3 id="menc-feat-vcd-dvd-all-pal-vcd">
|
|
5298 <title>PAL VCD</title>
|
|
5299
|
|
5300 <para>
|
|
5301 <screen>
|
|
5302 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
5303 scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5304 vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5305 vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
|
|
5306 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5307 </screen>
|
|
5308 </para>
|
|
5309 </sect3>
|
|
5310
|
|
5311
|
|
5312 <sect3 id="menc-feat-vcd-dvd-all-ntsc-vcd">
|
|
5313 <title>NTSC VCD</title>
|
|
5314
|
|
5315 <para>
|
|
5316 <screen>
|
|
5317 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
5318 scale=352:240,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5319 vcodec=mpeg1video:keyint=18:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5320 vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
5321 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5322 </screen>
|
|
5323 </para>
|
|
5324 </sect3>
|
|
5325 </sect2>
|
|
5326 </sect1>
|
|
5327 </chapter>
|