25279
|
1 <?xml version="1.0" encoding="utf-8"?>
|
27851
|
2 <!-- 44% synced with r22753 (row 2361) -->
|
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">
|
27851
|
2026 <title>Progressivo e telecine mescolati</title>
|
|
2027
|
|
2028 <para>
|
|
2029 Tutto il contenuto di un video "progressivo e telecine mescolati" è stato
|
26253
|
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">
|
27851
|
2049 <title>Progressivo e interlacciato mescolati</title>
|
|
2050
|
|
2051 <para>
|
|
2052 Nei contenuti con video "progressivo e interlacciato mescolati", il video
|
26253
|
2053 progressivo e interlacciato sono mescolati tra loro.
|
|
2054 </para>
|
|
2055
|
|
2056 <para>
|
27851
|
2057 Questa categoria è decisamente simile a "progressivo e telecine mescolati",
|
26253
|
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
|
27851
|
2091 alcune brevi parti di telecine mescolate. A meno che tu non sia sicuro,
|
26811
|
2092 conviene trattare il video come
|
27851
|
2093 <link linkend="menc-feat-telecine-encode-mixedpt">progressivo e telecine mescolati</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
|
27851
|
2109 mescolati</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">
|
27851
|
2196 <title>Progressivo e telecine mescolati</title>
|
|
2197
|
|
2198 <para>
|
|
2199 Per poter portare un video progressivo e telecine mescolati in un video
|
26811
|
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>
|
27851
|
2212 <option>-vf pullup</option> è studiata per togliere il telecine da materiale
|
|
2213 in telecine lasciando stare le parti in progressivo. Per poter funzionare
|
|
2214 correttamente, <option>pullup</option> <emphasis role="bold">deve</emphasis>
|
|
2215 essere seguita dal filtro <option>softskip</option> altrimenti
|
|
2216 <application>MEncoder</application> andrà in crash.
|
|
2217 <option>pullup</option> è tuttavia il modo migliore e più preciso disponibile
|
|
2218 per codificare sia telecine che "progressivo e telecine mescolati".
|
25279
|
2219 <screen>
|
|
2220 mencoder dvd://1 -oac copy -vf pullup,softskip
|
|
2221 -ovc lavc -ofps 24000/1001<!--
|
|
2222 --></screen>
|
|
2223 </para></listitem>
|
|
2224 <listitem><para>
|
27851
|
2225 Un metodo più vecchio, invece di togliere il telecine dove c'è, è portare
|
|
2226 in telecine le parti che non lo sono e dopo invertire il telecine su tutto il
|
|
2227 video. Sembra incasinato? softpulldown è un filtro che prende tutto il video
|
|
2228 e lo porta in telecine. Se facciamo seguire a softpulldown
|
|
2229 <option>detc</option> oppure <option>ivtc</option>, il risultato finale sarà
|
|
2230 completamente progressivo. Serve <option>-ofps 24000/1001</option>.
|
25279
|
2231 <screen>
|
|
2232 mencoder dvd://1 -oac copy -vf softpulldown,ivtc=1 -ovc lavc -ofps 24000/1001
|
|
2233 </screen>
|
|
2234 </para></listitem>
|
|
2235
|
|
2236 <listitem><para>
|
27851
|
2237 Non ho usato <option>-vf filmdint</option>, ma questa è l'opinione che ne ha
|
|
2238 D Richard Felker III:
|
|
2239
|
|
2240 <blockquote><para>E' OK, ma IMO cerca troppo spesso di deinterlacciare
|
|
2241 piuttosto che invertire il telecine (come molti lettori DVD da tavolo &
|
|
2242 televisioni progressive), il che porta orrendi sfarfallii e altri
|
|
2243 artefatti. Se vuoi utilizzarlo devi perlomeno spendere un po' di tempo ad
|
|
2244 impostare le opzioni e controllare i risultati prima di esser certo che non
|
|
2245 faccia danni.
|
25279
|
2246 </para></blockquote>
|
|
2247 </para></listitem>
|
|
2248 </itemizedlist>
|
|
2249 </sect3>
|
|
2250
|
|
2251
|
|
2252 <sect3 id="menc-feat-telecine-encode-mixedpi">
|
27851
|
2253 <title>Progressivo e interlacciato mescolati</title>
|
|
2254
|
|
2255 <para>
|
|
2256 Ci sono due opzioni per gestire questa categoria, ognuna delle quali è un
|
|
2257 compromesso. Dovresti decidere basandoti sulla lunghezza/durata di uno dei due
|
|
2258 tipi.
|
25279
|
2259 </para>
|
|
2260
|
|
2261 <itemizedlist>
|
|
2262 <listitem>
|
|
2263 <para>
|
27851
|
2264 Trattarlo come progressivo. Le parti interlacciate sembreranno interlacciate,
|
|
2265 e alcuni dei campi interlacciati dovranno essere scartati, apportando un
|
|
2266 pelino di saltellamenti impari. Se vuoi puoi utilizzare un filtro di
|
|
2267 postelaborazione, ma potrebbe leggermente inficiare le parti progressive.
|
25279
|
2268 </para>
|
|
2269
|
|
2270 <para>
|
27851
|
2271 Questa opzione non sarebbe decisamente da usare se casomai ti interessi
|
|
2272 riprodurre il video su un dispositivo interlacciato (con una sche da TV, per
|
|
2273 esempio). Se hai fotogrammi interlacciati in un video a 24000/1001 fotogrammi
|
|
2274 al secondo, verranno messi in telecine con i fotogrammi progressivi.
|
|
2275 Metà dei "fotogrammi" interlacciati saranno mostrati per la durata di tre
|
|
2276 campi (3/(60000/1001) secondi), risultando in un effetto alla "salto indietro
|
|
2277 nel tempo" che è bruttino. Se solo provi a far in questo modo,
|
|
2278 <emphasis role="bold">devi</emphasis> usare in filtro di deinterlacciamento
|
|
2279 come <option>lb</option> o <option>l5</option>.
|
25279
|
2280 </para>
|
|
2281
|
|
2282 <para>
|
27851
|
2283 Può anche essere una brutta idea per un display progressivo. Scarterà coppie
|
|
2284 di campi interlacciati consecutivi, dando una discontinuità che si vede
|
|
2285 maggiormente con il secondo metodo, che mostra per due volte alcuni
|
|
2286 fotogrammi progressivi. Il video interlacciato a 30000/1001 fotogrammi per
|
|
2287 secondo è di suo un pochino zoppo dato che sarebbe da mostrare a 60000/1001
|
|
2288 campi al secondo, quindi i fotogrammi duplicati non si notano così tanto.
|
25279
|
2289 </para>
|
|
2290
|
|
2291 <para>
|
27851
|
2292 In ogni modo è meglio tenere in considerazione il tuo contenuto e come
|
|
2293 intendi riprodurlo. Se il tuo video è al 90% progressivo e non pensi di
|
|
2294 riprodurlo mai su una TV, dovresti propendere per l'approccio progressivo.
|
|
2295 Se è progressivo solo per metà, probabilmente ti converrà codificarlo come
|
|
2296 se fosse interlacciato.
|
25279
|
2297 </para>
|
|
2298 </listitem>
|
|
2299
|
|
2300 <listitem><para>
|
27851
|
2301 Trattarlo come interlacciato. Alcuni fotogrammi delle parti progressive
|
|
2302 verranno duplicati, portando saltelli impari. Ancora, i filtri di
|
|
2303 deinterlacciamento potrebbero inficiare le parti progressive.
|
25279
|
2304 </para></listitem>
|
|
2305 </itemizedlist>
|
|
2306 </sect3>
|
|
2307 </sect2>
|
|
2308
|
|
2309 <!-- ********** -->
|
|
2310
|
|
2311 <sect2 id="menc-feat-telecine-footnotes">
|
27851
|
2312 <title>Note a pie' pagina</title>
|
25279
|
2313
|
|
2314 <orderedlist>
|
|
2315 <listitem>
|
|
2316 <formalpara>
|
27851
|
2317 <title>Riguardo il taglio (crop):</title>
|
25279
|
2318 <para>
|
27851
|
2319 I dati video sui DVD sono memorizzati in un formato conosciuto come YUV 4:2:0.
|
|
2320 In un video YUV, la luminosità ("luma") e il colore ("chroma") vengono
|
|
2321 salvati separatamente. Dato che l'occhio umano è in qualche modo meno
|
|
2322 sensibile al colore che alla luminosità, in un'immagine YUV 4:2:0 c'è solo
|
|
2323 un pixel chroma ogni quattro pixel luma. In un'immagine progressiva, ogni
|
|
2324 quadrato di quattro pixel luma (due per lato) ha in comune un pixel chroma.
|
|
2325 Devi prima ridimensionare lo YUV 4:2:0 progressivo a una risoluzione pari, e
|
|
2326 anche utilizzare lo scostamento. Per esempio,
|
|
2327 <option>crop=716:380:2:26</option> è OK ma
|
|
2328 <option>crop=716:380:3:26 </option> non lo è.
|
25279
|
2329 </para>
|
|
2330 </formalpara>
|
|
2331
|
|
2332 <para>
|
27851
|
2333 Quando gestisci YUV 4:2:0 interlacciato, la situazione è un pelo più
|
|
2334 complessa. Invece di avere quattro pixel luma nel
|
|
2335 <emphasis>fotogramma</emphasis> che condividono un pixel chroma, quattro
|
|
2336 pixel in ogni <emphasis>campo</emphasis> condividono un pixel chroma.
|
|
2337 Quando i campi vengono interlacciati per formare un fotogramma, ogni
|
|
2338 "scanline" è alta un pixel. Ora, invece di avere tutti i quattro pixel luma
|
|
2339 in un quadrato, ci sono due pixel affiancati, e gli altri due pixel sono
|
|
2340 affiancati due scanline più sotto. I due pixel luma nella scanline di mezzo
|
|
2341 sono di un altro campo, e quindi condividono un pixel chroma differente con
|
|
2342 due pixel due scanline dopo. Tutta questa confusione rende necessario avere
|
|
2343 dimensione verticale pari e lo scostamento deve essere un multiplo di quattro.
|
|
2344 La dimensione orizzontale può rimanere dispari.
|
25279
|
2345 </para>
|
|
2346
|
|
2347 <para>
|
27851
|
2348 Per video in telecine, si consiglia di effettuare il taglio dopo l'inversione
|
|
2349 del telecine. Una volta che il video è progressivo ti serve solo tagliare di
|
|
2350 numeri dispari. Se davvero vuoi ottenere il piccolo aumento di velocità che
|
|
2351 puoi avere tagliando prima, devi prima tagliare in verticale di multipli di
|
|
2352 quattro, altrimenti il filtro di telecine inverso non riceverà dati corretti.
|
25279
|
2353 </para>
|
|
2354
|
|
2355 <para>
|
27851
|
2356 Per video interlacciato (non in telecine), devi sempre tagliare
|
|
2357 verticalmente di multipli di quattro a meno che tu non stia usando
|
|
2358 <option>-vf field</option> prima del taglio.
|
25279
|
2359 </para>
|
|
2360 </listitem>
|
|
2361
|
|
2362 <listitem><formalpara>
|
|
2363 <title>About encoding parameters and quality:</title>
|
|
2364 <para>
|
|
2365 Just because I recommend <option>mbd=2</option> here does not mean it
|
|
2366 should not be used elsewhere. Along with <option>trell</option>,
|
|
2367 <option>mbd=2</option> is one of the two
|
|
2368 <systemitem class="library">libavcodec</systemitem> options that
|
|
2369 increases quality the most, and you should always use at least those
|
|
2370 two unless the drop in encoding speed is prohibitive (e.g. realtime
|
|
2371 encoding). There are many other options to
|
|
2372 <systemitem class="library">libavcodec</systemitem> that increase
|
|
2373 encoding quality (and decrease encoding speed) but that is beyond
|
|
2374 the scope of this document.
|
|
2375 </para>
|
|
2376 </formalpara></listitem>
|
|
2377
|
|
2378 <listitem><formalpara>
|
|
2379 <title>About the performance of pullup:</title>
|
|
2380 <para>
|
|
2381 It is safe to use <option>pullup</option> (along with <option>softskip
|
|
2382 </option>) on progressive video, and is usually a good idea unless
|
|
2383 the source has been definitively verified to be entirely progressive.
|
|
2384 The performace loss is small for most cases. On a bare-minimum encode,
|
|
2385 <option>pullup</option> causes <application>MEncoder</application> to
|
|
2386 be 50% slower. Adding sound processing and advanced <option>lavcopts
|
|
2387 </option> overshadows that difference, bringing the performance
|
|
2388 decrease of using <option>pullup</option> down to 2%.
|
|
2389 </para>
|
|
2390 </formalpara></listitem>
|
|
2391 </orderedlist>
|
|
2392 </sect2>
|
|
2393 </sect1>
|
|
2394
|
|
2395
|
|
2396 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
2397
|
|
2398
|
|
2399 <sect1 id="menc-feat-enc-libavcodec">
|
|
2400 <title>Encoding with the <systemitem class="library">libavcodec</systemitem>
|
|
2401 codec family</title>
|
|
2402
|
|
2403 <para>
|
27831
|
2404 <systemitem class="library">libavcodec</systemitem>
|
25279
|
2405 provides simple encoding to a lot of interesting video and audio formats.
|
|
2406 You can encode to the following codecs (more or less up to date):
|
|
2407 </para>
|
|
2408
|
|
2409 <!-- ********** -->
|
|
2410
|
|
2411 <sect2 id="menc-feat-enc-libavcodec-video-codecs">
|
|
2412 <title><systemitem class="library">libavcodec</systemitem>'s
|
|
2413 video codecs</title>
|
|
2414
|
|
2415 <para>
|
|
2416 <informaltable frame="all">
|
|
2417 <tgroup cols="2">
|
|
2418 <thead>
|
|
2419 <row><entry>Video codec name</entry><entry>Description</entry></row>
|
|
2420 </thead>
|
|
2421 <tbody>
|
|
2422 <row>
|
|
2423 <entry>mjpeg</entry>
|
|
2424 <entry>Motion JPEG</entry>
|
|
2425 </row>
|
|
2426 <row>
|
|
2427 <entry>ljpeg</entry>
|
|
2428 <entry>lossless JPEG</entry>
|
|
2429 </row>
|
|
2430 <row>
|
|
2431 <entry>jpegls</entry>
|
|
2432 <entry>JPEG LS</entry>
|
|
2433 </row>
|
|
2434 <row>
|
|
2435 <entry>targa</entry>
|
|
2436 <entry>Targa image</entry>
|
|
2437 </row>
|
|
2438 <row>
|
|
2439 <entry>gif</entry>
|
|
2440 <entry>GIF image</entry>
|
|
2441 </row>
|
|
2442 <row>
|
|
2443 <entry>bmp</entry>
|
|
2444 <entry>BMP image</entry>
|
|
2445 </row>
|
|
2446 <row>
|
|
2447 <entry>png</entry>
|
|
2448 <entry>PNG image</entry>
|
|
2449 </row>
|
|
2450 <row>
|
|
2451 <entry>h261</entry>
|
|
2452 <entry>H.261</entry>
|
|
2453 </row>
|
|
2454 <row>
|
|
2455 <entry>h263</entry>
|
|
2456 <entry>H.263 </entry>
|
|
2457 </row>
|
|
2458 <row>
|
|
2459 <entry>h263p</entry>
|
|
2460 <entry>H.263+</entry>
|
|
2461 </row>
|
|
2462 <row>
|
|
2463 <entry>mpeg4</entry>
|
|
2464 <entry>ISO standard MPEG-4 (DivX, Xvid compatible)</entry>
|
|
2465 </row>
|
|
2466 <row>
|
|
2467 <entry>msmpeg4</entry>
|
|
2468 <entry>pre-standard MPEG-4 variant by MS, v3 (AKA DivX3)</entry>
|
|
2469 </row>
|
|
2470 <row>
|
|
2471 <entry>msmpeg4v2</entry>
|
|
2472 <entry>pre-standard MPEG-4 by MS, v2 (used in old ASF files)</entry>
|
|
2473 </row>
|
|
2474 <row>
|
|
2475 <entry>wmv1</entry>
|
|
2476 <entry>Windows Media Video, version 1 (AKA WMV7)</entry>
|
|
2477 </row>
|
|
2478 <row>
|
|
2479 <entry>wmv2</entry>
|
|
2480 <entry>Windows Media Video, version 2 (AKA WMV8)</entry>
|
|
2481 </row>
|
|
2482 <row>
|
|
2483 <entry>rv10</entry>
|
|
2484 <entry>RealVideo 1.0</entry>
|
|
2485 </row>
|
|
2486 <row>
|
|
2487 <entry>rv20</entry>
|
|
2488 <entry>RealVideo 2.0</entry>
|
|
2489 </row>
|
|
2490 <row>
|
|
2491 <entry>mpeg1video</entry>
|
|
2492 <entry>MPEG-1 video</entry>
|
|
2493 </row>
|
|
2494 <row>
|
|
2495 <entry>mpeg2video</entry>
|
|
2496 <entry>MPEG-2 video</entry>
|
|
2497 </row>
|
|
2498 <row>
|
|
2499 <entry>huffyuv</entry>
|
|
2500 <entry>lossless compression</entry>
|
|
2501 </row>
|
|
2502 <row>
|
|
2503 <entry>ffvhuff</entry>
|
|
2504 <entry>FFmpeg modified huffyuv lossless</entry>
|
|
2505 </row>
|
|
2506 <row>
|
|
2507 <entry>asv1</entry>
|
|
2508 <entry>ASUS Video v1</entry>
|
|
2509 </row>
|
|
2510 <row>
|
|
2511 <entry>asv2</entry>
|
|
2512 <entry>ASUS Video v2</entry>
|
|
2513 </row>
|
|
2514 <row>
|
|
2515 <entry>ffv1</entry>
|
|
2516 <entry>FFmpeg's lossless video codec</entry>
|
|
2517 </row>
|
|
2518 <row>
|
|
2519 <entry>svq1</entry>
|
|
2520 <entry>Sorenson video 1</entry>
|
|
2521 </row>
|
|
2522 <row>
|
|
2523 <entry>flv</entry>
|
|
2524 <entry>Sorenson H.263 used in Flash Video</entry>
|
|
2525 </row>
|
|
2526 <row>
|
|
2527 <entry>flashsv</entry>
|
|
2528 <entry>Flash Screen Video</entry>
|
|
2529 </row>
|
|
2530 <row>
|
|
2531 <entry>dvvideo</entry>
|
|
2532 <entry>Sony Digital Video</entry>
|
|
2533 </row>
|
|
2534 <row>
|
|
2535 <entry>snow</entry>
|
|
2536 <entry>FFmpeg's experimental wavelet-based codec</entry>
|
|
2537 </row>
|
|
2538 <row>
|
|
2539 <entry>zbmv</entry>
|
|
2540 <entry>Zip Blocks Motion Video</entry>
|
|
2541 </row>
|
|
2542 </tbody>
|
|
2543 </tgroup>
|
|
2544 </informaltable>
|
|
2545
|
|
2546 The first column contains the codec names that should be passed after the
|
|
2547 <literal>vcodec</literal> config,
|
|
2548 like: <option>-lavcopts vcodec=msmpeg4</option>
|
|
2549 </para>
|
|
2550
|
|
2551 <informalexample><para>
|
|
2552 An example with MJPEG compression:
|
|
2553 <screen>
|
|
2554 mencoder dvd://2 -o <replaceable>title2.avi</replaceable> -ovc lavc -lavcopts vcodec=mjpeg -oac copy
|
|
2555 </screen>
|
|
2556 </para></informalexample>
|
|
2557 </sect2>
|
|
2558
|
|
2559 <!-- ********** -->
|
|
2560
|
|
2561 <sect2 id="menc-feat-enc-libavcodec-audio-codecs">
|
|
2562 <title><systemitem class="library">libavcodec</systemitem>'s
|
|
2563 audio codecs</title>
|
|
2564
|
|
2565 <para>
|
|
2566 <informaltable frame="all">
|
|
2567 <tgroup cols="2">
|
|
2568 <thead>
|
|
2569 <row><entry>Audio codec name</entry><entry>Description</entry></row>
|
|
2570 </thead>
|
|
2571 <tbody>
|
|
2572 <row>
|
|
2573 <entry>mp2</entry>
|
|
2574 <entry>MPEG Layer 2</entry>
|
|
2575 </row>
|
|
2576 <row>
|
|
2577 <entry>ac3</entry>
|
|
2578 <entry>AC-3, AKA Dolby Digital</entry>
|
|
2579 </row>
|
|
2580 <row>
|
|
2581 <entry>adpcm_ima_wav</entry>
|
|
2582 <entry>IMA adaptive PCM (4 bits per sample, 4:1 compression)</entry>
|
|
2583 </row>
|
|
2584 <row>
|
|
2585 <entry>sonic</entry>
|
|
2586 <entry>experimental FFmpeg lossy codec</entry>
|
|
2587 </row>
|
|
2588 <row>
|
|
2589 <entry>sonicls</entry>
|
|
2590 <entry>experimental FFmpeg lossless codec</entry>
|
|
2591 </row>
|
|
2592 <row>
|
|
2593 <entry>vorbis</entry>
|
|
2594 <entry>Xiph Ogg Vorbis codec</entry>
|
|
2595 </row>
|
|
2596 <row>
|
|
2597 <entry>wmav1</entry>
|
|
2598 <entry>Windows Media Audio v1 codec</entry>
|
|
2599 </row>
|
|
2600 <row>
|
|
2601 <entry>wmav2</entry>
|
|
2602 <entry>Windows Media Audio v2 codec</entry>
|
|
2603 </row>
|
|
2604 </tbody>
|
|
2605 </tgroup>
|
|
2606 </informaltable>
|
|
2607
|
|
2608 The first column contains the codec names that should be passed after the
|
|
2609 <literal>acodec</literal> option, like: <option>-lavcopts acodec=ac3</option>
|
|
2610 </para>
|
|
2611
|
|
2612 <informalexample><para>
|
|
2613 An example with AC-3 compression:
|
|
2614 <screen>
|
|
2615 mencoder dvd://2 -o <replaceable>title2.avi</replaceable> -oac lavc -lavcopts acodec=ac3 -ovc copy
|
|
2616 </screen>
|
|
2617 </para></informalexample>
|
|
2618
|
|
2619 <para>
|
|
2620 Contrary to <systemitem class="library">libavcodec</systemitem>'s video
|
|
2621 codecs, its audio codecs do not make a wise usage of the bits they are
|
|
2622 given as they lack some minimal psychoacoustic model (if at all)
|
|
2623 which most other codec implementations feature.
|
|
2624 However, note that all these audio codecs are very fast and work
|
|
2625 out-of-the-box everywhere <application>MEncoder</application> has been
|
|
2626 compiled with <systemitem class="library">libavcodec</systemitem> (which
|
|
2627 is the case most of time), and do not depend on external libraries.
|
|
2628 </para>
|
|
2629 </sect2>
|
|
2630
|
|
2631 <!-- ********** -->
|
|
2632
|
|
2633 <sect2 id="menc-feat-dvd-mpeg4-lavc-encoding-options">
|
|
2634 <title>Encoding options of libavcodec</title>
|
|
2635
|
|
2636 <para>
|
|
2637 Ideally, you would probably want to be able to just tell the encoder to switch
|
|
2638 into "high quality" mode and move on.
|
|
2639 That would probably be nice, but unfortunately hard to implement as different
|
|
2640 encoding options yield different quality results depending on the source
|
|
2641 material. That is because compression depends on the visual properties of the
|
|
2642 video in question.
|
|
2643 For example, anime and live action have very different properties and
|
|
2644 thus require different options to obtain optimum encoding.
|
|
2645 The good news is that some options should never be left out, like
|
|
2646 <option>mbd=2</option>, <option>trell</option>, and <option>v4mv</option>.
|
|
2647 See below for a detailed description of common encoding options.
|
|
2648 </para>
|
|
2649
|
|
2650 <itemizedlist>
|
|
2651 <title>Options to adjust:</title>
|
|
2652 <listitem><para>
|
|
2653 <emphasis role="bold">vmax_b_frames</emphasis>: 1 or 2 is good, depending on
|
|
2654 the movie.
|
|
2655 Note that if you need to have your encode be decodable by DivX5, you
|
|
2656 need to activate closed GOP support, using
|
|
2657 <systemitem class="library">libavcodec</systemitem>'s <option>cgop</option>
|
|
2658 option, but you need to deactivate scene detection, which
|
|
2659 is not a good idea as it will hurt encode efficiency a bit.
|
|
2660 </para></listitem>
|
|
2661 <listitem><para>
|
|
2662 <emphasis role="bold">vb_strategy=1</emphasis>: helps in high-motion scenes.
|
|
2663 On some videos, vmax_b_frames may hurt quality, but vmax_b_frames=2 along
|
|
2664 with vb_strategy=1 helps.
|
|
2665 </para></listitem>
|
|
2666 <listitem><para>
|
|
2667 <emphasis role="bold">dia</emphasis>: motion search range. Bigger is better
|
|
2668 and slower.
|
|
2669 Negative values are a completely different scale.
|
|
2670 Good values are -1 for a fast encode, or 2-4 for slower.
|
|
2671 </para></listitem>
|
|
2672 <listitem><para>
|
|
2673 <emphasis role="bold">predia</emphasis>: motion search pre-pass.
|
|
2674 Not as important as dia. Good values are 1 (default) to 4. Requires preme=2
|
|
2675 to really be useful.
|
|
2676 </para></listitem>
|
|
2677 <listitem><para>
|
|
2678 <emphasis role="bold">cmp, subcmp, precmp</emphasis>: Comparison function for
|
|
2679 motion estimation.
|
|
2680 Experiment with values of 0 (default), 2 (hadamard), 3 (dct), and 6 (rate
|
|
2681 distortion).
|
|
2682 0 is fastest, and sufficient for precmp.
|
|
2683 For cmp and subcmp, 2 is good for anime, and 3 is good for live action.
|
|
2684 6 may or may not be slightly better, but is slow.
|
|
2685 </para></listitem>
|
|
2686 <listitem><para>
|
|
2687 <emphasis role="bold">last_pred</emphasis>: Number of motion predictors to
|
|
2688 take from the previous frame.
|
|
2689 1-3 or so help at little speed cost.
|
|
2690 Higher values are slow for no extra gain.
|
|
2691 </para></listitem>
|
|
2692 <listitem><para>
|
|
2693 <emphasis role="bold">cbp, mv0</emphasis>: Controls the selection of
|
|
2694 macroblocks. Small speed cost for small quality gain.
|
|
2695 </para></listitem>
|
|
2696 <listitem><para>
|
|
2697 <emphasis role="bold">qprd</emphasis>: adaptive quantization based on the
|
|
2698 macroblock's complexity.
|
|
2699 May help or hurt depending on the video and other options.
|
|
2700 This can cause artifacts unless you set vqmax to some reasonably small value
|
|
2701 (6 is good, maybe as low as 4); vqmin=1 should also help.
|
|
2702 </para></listitem>
|
|
2703 <listitem><para>
|
|
2704 <emphasis role="bold">qns</emphasis>: very slow, especially when combined
|
|
2705 with qprd.
|
|
2706 This option will make the encoder minimize noise due to compression
|
|
2707 artifacts instead of making the encoded video strictly match the source.
|
|
2708 Do not use this unless you have already tweaked everything else as far as it
|
|
2709 will go and the results still are not good enough.
|
|
2710 </para></listitem>
|
|
2711 <listitem><para>
|
|
2712 <emphasis role="bold">vqcomp</emphasis>: Tweak ratecontrol.
|
|
2713 What values are good depends on the movie.
|
|
2714 You can safely leave this alone if you want.
|
|
2715 Reducing vqcomp puts more bits on low-complexity scenes, increasing it puts
|
|
2716 them on high-complexity scenes (default: 0.5, range: 0-1. recommended range:
|
|
2717 0.5-0.7).
|
|
2718 </para></listitem>
|
|
2719 <listitem><para>
|
|
2720 <emphasis role="bold">vlelim, vcelim</emphasis>: Sets the single coefficient
|
|
2721 elimination threshold for luminance and chroma planes.
|
|
2722 These are encoded separately in all MPEG-like algorithms.
|
|
2723 The idea behind these options is to use some good heuristics to determine
|
|
2724 when the change in a block is less than the threshold you specify, and in
|
|
2725 such a case, to just encode the block as "no change".
|
|
2726 This saves bits and perhaps speeds up encoding. vlelim=-4 and vcelim=9
|
|
2727 seem to be good for live movies, but seem not to help with anime;
|
|
2728 when encoding animation, you should probably leave them unchanged.
|
|
2729 </para></listitem>
|
|
2730 <listitem><para>
|
|
2731 <emphasis role="bold">qpel</emphasis>: Quarter pixel motion estimation.
|
|
2732 MPEG-4 uses half pixel precision for its motion search by default,
|
|
2733 therefore this option comes with an overhead as more information will be
|
|
2734 stored in the encoded file.
|
|
2735 The compression gain/loss depends on the movie, but it is usually not very
|
|
2736 effective on anime.
|
|
2737 qpel always incurs a significant cost in CPU decode time (+25% in
|
|
2738 practice).
|
|
2739 </para></listitem>
|
|
2740 <listitem><para>
|
|
2741 <emphasis role="bold">psnr</emphasis>: does not affect the actual encoding,
|
|
2742 but writes a log file giving the type/size/quality of each frame, and
|
|
2743 prints a summary of PSNR (Peak Signal to Noise Ratio) at the end.
|
|
2744 </para></listitem>
|
|
2745 </itemizedlist>
|
|
2746
|
|
2747 <itemizedlist>
|
|
2748 <title>Options not recommended to play with:</title>
|
|
2749 <listitem><para>
|
|
2750 <emphasis role="bold">vme</emphasis>: The default is best.
|
|
2751 </para></listitem>
|
|
2752 <listitem><para>
|
|
2753 <emphasis role="bold">lumi_mask, dark_mask</emphasis>: Psychovisual adaptive
|
|
2754 quantization.
|
|
2755 You do not want to play with those options if you care about quality.
|
|
2756 Reasonable values may be effective in your case, but be warned this is very
|
|
2757 subjective.
|
|
2758 </para></listitem>
|
|
2759 <listitem><para>
|
|
2760 <emphasis role="bold">scplx_mask</emphasis>: Tries to prevent blocky
|
|
2761 artifacts, but postprocessing is better.
|
|
2762 </para></listitem>
|
|
2763 </itemizedlist>
|
|
2764 </sect2>
|
|
2765
|
|
2766 <!-- ********** -->
|
|
2767
|
|
2768 <sect2 id="menc-feat-mpeg4-lavc-example-settings">
|
|
2769 <title>Encoding setting examples</title>
|
|
2770
|
|
2771 <para>
|
|
2772 The following settings are examples of different encoding
|
|
2773 option combinations that affect the speed vs quality tradeoff
|
|
2774 at the same target bitrate.
|
|
2775 </para>
|
|
2776
|
|
2777 <para>
|
|
2778 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
2779 video sample, the target bitrate was 900kbps, and the machine was an
|
|
2780 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
2781 Each encoding setting features the measured encoding speed (in
|
|
2782 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
2783 high quality" setting.
|
|
2784 Please understand that depending on your source, your machine type
|
|
2785 and development advancements, you may get very different results.
|
|
2786 </para>
|
|
2787
|
|
2788 <para>
|
|
2789 <informaltable frame="all">
|
|
2790 <tgroup cols="4">
|
|
2791 <thead>
|
|
2792 <row>
|
|
2793 <entry>Description</entry>
|
|
2794 <entry>Encoding options</entry>
|
|
2795 <entry>speed (in fps)</entry>
|
|
2796 <entry>Relative PSNR loss (in dB)</entry>
|
|
2797 </row>
|
|
2798 </thead>
|
|
2799 <tbody>
|
|
2800 <row>
|
|
2801 <entry>Very high quality</entry>
|
|
2802 <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>
|
|
2803 <entry>6fps</entry>
|
|
2804 <entry>0dB</entry>
|
|
2805 </row>
|
|
2806 <row>
|
|
2807 <entry>High quality</entry>
|
|
2808 <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>
|
|
2809 <entry>15fps</entry>
|
|
2810 <entry>-0.5dB</entry>
|
|
2811 </row>
|
|
2812 <row>
|
|
2813 <entry>Fast</entry>
|
|
2814 <entry><option>vcodec=mpeg4:mbd=2:trell:v4mv:turbo</option></entry>
|
|
2815 <entry>42fps</entry>
|
|
2816 <entry>-0.74dB</entry>
|
|
2817 </row>
|
|
2818 <row>
|
|
2819 <entry>Realtime</entry>
|
|
2820 <entry><option>vcodec=mpeg4:mbd=2:turbo</option></entry>
|
|
2821 <entry>54fps</entry>
|
|
2822 <entry>-1.21dB</entry>
|
|
2823 </row>
|
|
2824 </tbody>
|
|
2825 </tgroup>
|
|
2826 </informaltable>
|
|
2827 </para>
|
|
2828 </sect2>
|
|
2829
|
|
2830 <!-- ********** -->
|
|
2831
|
|
2832 <sect2 id="custommatrices">
|
|
2833 <title>Custom inter/intra matrices</title>
|
|
2834
|
|
2835 <para>
|
|
2836 With this feature of
|
27831
|
2837 <systemitem class="library">libavcodec</systemitem>
|
25279
|
2838 you are able to set custom inter (I-frames/keyframes) and intra
|
|
2839 (P-frames/predicted frames) matrices. It is supported by many of the codecs:
|
|
2840 <systemitem>mpeg1video</systemitem> and <systemitem>mpeg2video</systemitem>
|
|
2841 are reported as working.
|
|
2842 </para>
|
|
2843
|
|
2844 <para>
|
|
2845 A typical usage of this feature is to set the matrices preferred by the
|
|
2846 <ulink url="http://www.kvcd.net/">KVCD</ulink> specifications.
|
|
2847 </para>
|
|
2848
|
|
2849 <para>
|
|
2850 The <emphasis role="bold">KVCD "Notch" Quantization Matrix:</emphasis>
|
|
2851 </para>
|
|
2852
|
|
2853 <para>
|
|
2854 Intra:
|
|
2855 <screen>
|
|
2856 8 9 12 22 26 27 29 34
|
|
2857 9 10 14 26 27 29 34 37
|
|
2858 12 14 18 27 29 34 37 38
|
|
2859 22 26 27 31 36 37 38 40
|
|
2860 26 27 29 36 39 38 40 48
|
|
2861 27 29 34 37 38 40 48 58
|
|
2862 29 34 37 38 40 48 58 69
|
|
2863 34 37 38 40 48 58 69 79
|
|
2864 </screen>
|
|
2865
|
|
2866 Inter:
|
|
2867 <screen>
|
|
2868 16 18 20 22 24 26 28 30
|
|
2869 18 20 22 24 26 28 30 32
|
|
2870 20 22 24 26 28 30 32 34
|
|
2871 22 24 26 30 32 32 34 36
|
|
2872 24 26 28 32 34 34 36 38
|
|
2873 26 28 30 32 34 36 38 40
|
|
2874 28 30 32 34 36 38 42 42
|
|
2875 30 32 34 36 38 40 42 44
|
|
2876 </screen>
|
|
2877 </para>
|
|
2878
|
|
2879 <para>
|
|
2880 Usage:
|
|
2881 <screen>
|
|
2882 mencoder <replaceable>input.avi</replaceable> -o <replaceable>output.avi</replaceable> -oac copy -ovc lavc \
|
|
2883 -lavcopts inter_matrix=...:intra_matrix=...
|
|
2884 </screen>
|
|
2885 </para>
|
|
2886
|
|
2887 <para>
|
|
2888 <screen>
|
|
2889 mencoder <replaceable>input.avi</replaceable> -ovc lavc -lavcopts \
|
|
2890 vcodec=mpeg2video:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,\
|
|
2891 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,\
|
|
2892 29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79\
|
|
2893 :inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,\
|
|
2894 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,\
|
|
2895 36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 -oac copy -o svcd.mpg
|
|
2896 </screen>
|
|
2897 </para>
|
|
2898 </sect2>
|
|
2899
|
|
2900 <!-- ********** -->
|
|
2901
|
|
2902 <sect2 id="menc-feat-dvd-mpeg4-example">
|
|
2903 <title>Example</title>
|
|
2904
|
|
2905 <para>
|
|
2906 So, you have just bought your shiny new copy of Harry Potter and the Chamber
|
|
2907 of Secrets (widescreen edition, of course), and you want to rip this DVD
|
|
2908 so that you can add it to your Home Theatre PC. This is a region 1 DVD,
|
|
2909 so it is NTSC. The example below will still apply to PAL, except you will
|
|
2910 omit <option>-ofps 24000/1001</option> (because the output framerate is the
|
|
2911 same as the input framerate), and of course the crop dimensions will be
|
|
2912 different.
|
|
2913 </para>
|
|
2914
|
|
2915 <para>
|
|
2916 After running <option>mplayer dvd://1</option>, we follow the process
|
|
2917 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
2918 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
2919 24000/1001 fps progressive video, which means that we need not use an inverse
|
|
2920 telecine filter, such as <option>pullup</option> or
|
|
2921 <option>filmdint</option>.
|
|
2922 </para>
|
|
2923
|
|
2924 <para id="menc-feat-dvd-mpeg4-example-crop">
|
|
2925 Next, we want to determine the appropriate crop rectangle, so we use the
|
|
2926 cropdetect filter:
|
|
2927 <screen>mplayer dvd://1 -vf cropdetect</screen>
|
|
2928 Make sure you seek to a fully filled frame (such as a bright scene,
|
|
2929 past the opening credits and logos), and
|
|
2930 you will see in <application>MPlayer</application>'s console output:
|
|
2931 <screen>crop area: X: 0..719 Y: 57..419 (-vf crop=720:362:0:58)</screen>
|
|
2932 We then play the movie back with this filter to test its correctness:
|
|
2933 <screen>mplayer dvd://1 -vf crop=720:362:0:58</screen>
|
|
2934 And we see that it looks perfectly fine. Next, we ensure the width and
|
|
2935 height are a multiple of 16. The width is fine, however the height is
|
|
2936 not. Since we did not fail 7th grade math, we know that the nearest
|
|
2937 multiple of 16 lower than 362 is 352.
|
|
2938 </para>
|
|
2939
|
|
2940 <para>
|
|
2941 We could just use <option>crop=720:352:0:58</option>, but it would be nice
|
|
2942 to take a little off the top and a little off the bottom so that we
|
|
2943 retain the center. We have shrunk the height by 10 pixels, but we do not
|
|
2944 want to increase the y-offset by 5-pixels since that is an odd number and
|
|
2945 will adversely affect quality. Instead, we will increase the y-offset by
|
|
2946 4 pixels:
|
|
2947 <screen>mplayer dvd://1 -vf crop=720:352:0:62</screen>
|
|
2948 Another reason to shave pixels from both the top and the bottom is that we
|
|
2949 ensure we have eliminated any half-black pixels if they exist. Note that if
|
|
2950 your video is telecined, make sure the <option>pullup</option> filter (or
|
|
2951 whichever inverse telecine filter you decide to use) appears in the filter
|
|
2952 chain before you crop. If it is interlaced, deinterlace before cropping.
|
|
2953 (If you choose to preserve the interlaced video, then make sure your
|
|
2954 vertical crop offset is a multiple of 4.)
|
|
2955 </para>
|
|
2956
|
|
2957 <para>
|
|
2958 If you are really concerned about losing those 10 pixels, you might
|
|
2959 prefer instead to scale the dimensions down to the nearest multiple of 16.
|
|
2960 The filter chain would look like:
|
|
2961 <screen>-vf crop=720:362:0:58,scale=720:352</screen>
|
|
2962 Scaling the video down like this will mean that some small amount of
|
|
2963 detail is lost, though it probably will not be perceptible. Scaling up will
|
|
2964 result in lower quality (unless you increase the bitrate). Cropping
|
|
2965 discards those pixels altogether. It is a tradeoff that you will want to
|
|
2966 consider for each circumstance. For example, if the DVD video was made
|
|
2967 for television, you might want to avoid vertical scaling, since the line
|
|
2968 sampling corresponds to the way the content was originally recorded.
|
|
2969 </para>
|
|
2970
|
|
2971 <para>
|
|
2972 On inspection, we see that our movie has a fair bit of action and high
|
|
2973 amounts of detail, so we pick 2400Kbit for our bitrate.
|
|
2974 </para>
|
|
2975
|
|
2976 <para>
|
|
2977 We are now ready to do the two pass encode. Pass one:
|
|
2978 <screen>
|
|
2979 mencoder dvd://1 -ofps 24000/1001 -oac copy -o <replaceable>Harry_Potter_2.avi</replaceable> -ovc lavc \
|
|
2980 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=1 \
|
|
2981 -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
|
|
2982 </screen>
|
|
2983 And pass two is the same, except that we specify <option>vpass=2</option>:
|
|
2984 <screen>
|
|
2985 mencoder dvd://1 -ofps 24000/1001 -oac copy -o <replaceable>Harry_Potter_2.avi</replaceable> -ovc lavc \
|
|
2986 -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=2 \
|
|
2987 -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
|
|
2988 </screen>
|
|
2989 </para>
|
|
2990
|
|
2991 <para>
|
|
2992 The options <option>v4mv:mbd=2:trell</option> will greatly increase the
|
|
2993 quality at the expense of encoding time. There is little reason to leave
|
|
2994 these options out when the primary goal is quality. The options
|
|
2995 <option>cmp=3:subcmp=3</option> select a comparison function that
|
|
2996 yields higher quality than the defaults. You might try experimenting with
|
|
2997 this parameter (refer to the man page for the possible values) as
|
|
2998 different functions can have a large impact on quality depending on the
|
|
2999 source material. For example, if you find
|
|
3000 <systemitem class="library">libavcodec</systemitem> produces too much
|
|
3001 blocky artifacting, you could try selecting the experimental NSSE as
|
|
3002 comparison function via <option>*cmp=10</option>.
|
|
3003 </para>
|
|
3004
|
|
3005 <para>
|
|
3006 For this movie, the resulting AVI will be 138 minutes long and nearly
|
|
3007 3GB. And because you said that file size does not matter, this is a
|
|
3008 perfectly acceptable size. However, if you had wanted it smaller, you
|
|
3009 could try a lower bitrate. Increasing bitrates have diminishing
|
|
3010 returns, so while we might clearly see an improvement from 1800Kbit to
|
|
3011 2000Kbit, it might not be so noticeable above 2000Kbit. Feel
|
|
3012 free to experiment until you are happy.
|
|
3013 </para>
|
|
3014
|
|
3015 <para>
|
|
3016 Because we passed the source video through a denoise filter, you may want
|
|
3017 to add some of it back during playback. This, along with the
|
|
3018 <option>spp</option> post-processing filter, drastically improves the
|
|
3019 perception of quality and helps eliminate blocky artifacts in the video.
|
|
3020 With <application>MPlayer</application>'s <option>autoq</option> option,
|
|
3021 you can vary the amount of post-processing done by the spp filter
|
|
3022 depending on available CPU. Also, at this point, you may want to apply
|
|
3023 gamma and/or color correction to best suit your display. For example:
|
|
3024 <screen>
|
|
3025 mplayer <replaceable>Harry_Potter_2.avi</replaceable> -vf spp,noise=9ah:5ah,eq2=1.2 -autoq 3
|
|
3026 </screen>
|
|
3027 </para>
|
|
3028 </sect2>
|
|
3029 </sect1>
|
|
3030
|
|
3031
|
|
3032 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
3033
|
|
3034
|
|
3035 <sect1 id="menc-feat-xvid">
|
|
3036 <title>Encoding with the <systemitem class="library">Xvid</systemitem>
|
|
3037 codec</title>
|
|
3038
|
|
3039 <para>
|
|
3040 <systemitem class="library">Xvid</systemitem> is a free library for
|
|
3041 encoding MPEG-4 ASP video streams.
|
|
3042 Before starting to encode, you need to <link linkend="xvid">
|
|
3043 set up <application>MEncoder</application> to support it</link>.
|
|
3044 </para>
|
|
3045
|
|
3046 <para>
|
|
3047 This guide mainly aims at featuring the same kind of information
|
|
3048 as x264's encoding guide.
|
|
3049 Therefore, please begin by reading
|
|
3050 <link linkend="menc-feat-x264-encoding-options-intro">the first part</link>
|
|
3051 of that guide.
|
|
3052 </para>
|
|
3053
|
|
3054 <!-- ********** -->
|
|
3055
|
|
3056 <sect2 id="menc-feat-xvid-intro">
|
|
3057 <title>What options should I use to get the best results?</title>
|
|
3058
|
|
3059 <para>
|
|
3060 Please begin by reviewing the
|
|
3061 <systemitem class="library">Xvid</systemitem> section of
|
|
3062 <application>MPlayer</application>'s man page.
|
|
3063 This section is intended to be a supplement to the man page.
|
|
3064 </para>
|
|
3065
|
|
3066 <para>
|
|
3067 The Xvid default settings are already a good tradeoff between
|
|
3068 speed and quality, therefore you can safely stick to them if
|
|
3069 the following section puzzles you.
|
|
3070 </para>
|
|
3071 </sect2>
|
|
3072
|
|
3073 <!-- ********** -->
|
|
3074
|
|
3075 <sect2 id="menc-feat-xvid-encoding-options">
|
|
3076 <title>Encoding options of <systemitem class="library">Xvid</systemitem></title>
|
|
3077
|
|
3078 <itemizedlist>
|
|
3079 <listitem><para>
|
|
3080 <emphasis role="bold">vhq</emphasis>
|
|
3081 This setting affects the macroblock decision algorithm, where the
|
|
3082 higher the setting, the wiser the decision.
|
|
3083 The default setting may be safely used for every encode, while
|
|
3084 higher settings always help PSNR but are significantly slower.
|
|
3085 Please note that a better PSNR does not necessarily mean
|
|
3086 that the picture will look better, but tells you that it is
|
|
3087 closer to the original.
|
|
3088 Turning it off will noticeably speed up encoding; if speed is
|
|
3089 critical for you, the tradeoff may be worth it.
|
|
3090 </para></listitem>
|
|
3091 <listitem><para>
|
|
3092 <emphasis role="bold">bvhq</emphasis>
|
|
3093 This does the same job as vhq, but does it on B-frames.
|
|
3094 It has a negligible impact on speed, and slightly improves quality
|
|
3095 (around +0.1dB PSNR).
|
|
3096 </para></listitem>
|
|
3097 <listitem><para>
|
|
3098 <emphasis role="bold">max_bframes</emphasis>
|
|
3099 A higher number of consecutive allowed B-frames usually improves
|
|
3100 compressibility, although it may also lead to more blocking artifacts.
|
|
3101 The default setting is a good tradeoff between compressibility and
|
|
3102 quality, but you may increase it up to 3 if you are bitrate-starved.
|
|
3103 You may also decrease it to 1 or 0 if you are aiming at perfect
|
|
3104 quality, though in that case you should make sure your
|
|
3105 target bitrate is high enough to ensure that the encoder does not
|
|
3106 have to increase quantizers to reach it.
|
|
3107 </para></listitem>
|
|
3108 <listitem><para>
|
|
3109 <emphasis role="bold">bf_threshold</emphasis>
|
|
3110 This controls the B-frame sensitivity of the encoder, where a higher
|
|
3111 value leads to more B-frames being used (and vice versa).
|
|
3112 This setting is to be used together with <option>max_bframes</option>;
|
|
3113 if you are bitrate-starved, you should increase both
|
|
3114 <option>max_bframes</option> and <option>bf_threshold</option>,
|
|
3115 while you may increase <option>max_bframes</option> and reduce
|
|
3116 <option>bf_threshold</option> so that the encoder may use more
|
|
3117 B-frames in places that only <emphasis role="bold">really</emphasis>
|
|
3118 need them.
|
|
3119 A low number of <option>max_bframes</option> and a high value of
|
|
3120 <option>bf_threshold</option> is probably not a wise choice as it
|
|
3121 will force the encoder to put B-frames in places that would not
|
|
3122 benefit from them, therefore reducing visual quality.
|
|
3123 However, if you need to be compatible with standalone players that
|
|
3124 only support old DivX profiles (which only supports up to 1
|
|
3125 consecutive B-frame), this would be your only way to
|
|
3126 increase compressibility through using B-frames.
|
|
3127 </para></listitem>
|
|
3128 <listitem><para>
|
|
3129 <emphasis role="bold">trellis</emphasis>
|
|
3130 Optimizes the quantization process to get an optimal tradeoff
|
|
3131 between PSNR and bitrate, which allows significant bit saving.
|
|
3132 These bits will in return be spent elsewhere on the video,
|
|
3133 raising overall visual quality.
|
|
3134 You should always leave it on as its impact on quality is huge.
|
|
3135 Even if you are looking for speed, do not disable it until you
|
|
3136 have turned down <option>vhq</option> and all other more
|
|
3137 CPU-hungry options to the minimum.
|
|
3138 </para></listitem>
|
|
3139 <listitem><para>
|
|
3140 <emphasis role="bold">hq_ac</emphasis>
|
|
3141 Activates a better coefficient cost estimation method, which slightly
|
|
3142 reduces filesize by around 0.15 to 0.19% (which corresponds to less
|
|
3143 than 0.01dB PSNR increase), while having a negligible impact on speed.
|
|
3144 It is therefore recommended to always leave it on.
|
|
3145 </para></listitem>
|
|
3146 <listitem><para>
|
|
3147 <emphasis role="bold">cartoon</emphasis>
|
|
3148 Designed to better encode cartoon content, and has no impact on
|
|
3149 speed as it just tunes the mode decision heuristics for this type
|
|
3150 of content.
|
|
3151 </para></listitem>
|
|
3152 <listitem>
|
|
3153 <para>
|
|
3154 <emphasis role="bold">me_quality</emphasis>
|
|
3155 This setting is to control the precision of the motion estimation.
|
|
3156 The higher <option>me_quality</option>, the more
|
|
3157 precise the estimation of the original motion will be, and the
|
|
3158 better the resulting clip will capture the original motion.
|
|
3159 </para>
|
|
3160 <para>
|
|
3161 The default setting is best in all cases;
|
|
3162 thus it is not recommended to turn it down unless you are
|
|
3163 really looking for speed, as all the bits saved by a good motion
|
|
3164 estimation would be spent elsewhere, raising overall quality.
|
|
3165 Therefore, do not go any lower than 5, and even that only as a last
|
|
3166 resort.
|
|
3167 </para>
|
|
3168 </listitem>
|
|
3169 <listitem><para>
|
|
3170 <emphasis role="bold">chroma_me</emphasis>
|
|
3171 Improves motion estimation by also taking the chroma (color)
|
|
3172 information into account, whereas <option>me_quality</option>
|
|
3173 alone only uses luma (grayscale).
|
|
3174 This slows down encoding by 5-10% but improves visual quality
|
|
3175 quite a bit by reducing blocking effects and reduces filesize by
|
|
3176 around 1.3%.
|
|
3177 If you are looking for speed, you should disable this option before
|
|
3178 starting to consider reducing <option>me_quality</option>.
|
|
3179 </para></listitem>
|
|
3180 <listitem><para>
|
|
3181 <emphasis role="bold">chroma_opt</emphasis>
|
|
3182 Is intended to increase chroma image quality around pure
|
|
3183 white/black edges, rather than improving compression.
|
|
3184 This can help to reduce the "red stairs" effect.
|
|
3185 </para></listitem>
|
|
3186 <listitem><para>
|
|
3187 <emphasis role="bold">lumi_mask</emphasis>
|
|
3188 Tries to give less bitrate to part of the picture that the
|
|
3189 human eye cannot see very well, which should allow the encoder
|
|
3190 to spend the saved bits on more important parts of the picture.
|
|
3191 The quality of the encode yielded by this option highly depends
|
|
3192 on personal preferences and on the type and monitor settings
|
|
3193 used to watch it (typically, it will not look as good if it is
|
|
3194 bright or if it is a TFT monitor).
|
|
3195 </para></listitem>
|
|
3196 <listitem>
|
|
3197 <para>
|
|
3198 <emphasis role="bold">qpel</emphasis>
|
|
3199 Raise the number of candidate motion vectors by increasing
|
|
3200 the precision of the motion estimation from halfpel to
|
|
3201 quarterpel.
|
|
3202 The idea is to find better motion vectors which will in return
|
|
3203 reduce bitrate (hence increasing quality).
|
|
3204 However, motion vectors with quarterpel precision require a
|
|
3205 few extra bits to code, but the candidate vectors do not always
|
|
3206 give (much) better results.
|
|
3207 Quite often, the codec still spends bits on the extra precision,
|
|
3208 but little or no extra quality is gained in return.
|
|
3209 Unfortunately, there is no way to foresee the possible gains of
|
|
3210 <option>qpel</option>, so you need to actually encode with and
|
|
3211 without it to know for sure.
|
|
3212 </para>
|
|
3213 <para>
|
|
3214 <option>qpel</option> can be almost double encoding time, and
|
|
3215 requires as much as 25% more processing power to decode.
|
|
3216 It is not supported by all standalone players.
|
|
3217 </para>
|
|
3218 </listitem>
|
|
3219 <listitem><para>
|
|
3220 <emphasis role="bold">gmc</emphasis>
|
|
3221 Tries to save bits on panning scenes by using a single motion
|
|
3222 vector for the whole frame.
|
|
3223 This almost always raises PSNR, but significantly slows down
|
|
3224 encoding (as well as decoding).
|
|
3225 Therefore, you should only use it when you have turned
|
|
3226 <option>vhq</option> to the maximum.
|
|
3227 <systemitem class="library">Xvid</systemitem>'s GMC is more
|
|
3228 sophisticated than DivX's, but is only supported by few
|
|
3229 standalone players.
|
|
3230 </para></listitem>
|
|
3231 </itemizedlist>
|
|
3232 </sect2>
|
|
3233
|
|
3234 <!-- ********** -->
|
|
3235
|
|
3236 <sect2 id="menc-feat-xvid-encoding-profiles">
|
|
3237 <title>Encoding profiles</title>
|
|
3238
|
|
3239 <para>
|
|
3240 Xvid supports encoding profiles through the <option>profile</option> option,
|
|
3241 which are used to impose restrictions on the properties of the Xvid video
|
|
3242 stream such that it will be playable on anything which supports the
|
|
3243 chosen profile.
|
|
3244 The restrictions relate to resolutions, bitrates and certain MPEG-4
|
|
3245 features.
|
|
3246 The following table shows what each profile supports.
|
|
3247 </para>
|
|
3248
|
|
3249 <informaltable>
|
|
3250 <tgroup cols="16" align="center">
|
|
3251 <colspec colnum="1" colname="col1"/>
|
|
3252 <colspec colnum="2" colname="col2"/>
|
|
3253 <colspec colnum="3" colname="col3"/>
|
|
3254 <colspec colnum="4" colname="col4"/>
|
|
3255 <colspec colnum="5" colname="col5"/>
|
|
3256 <colspec colnum="6" colname="col6"/>
|
|
3257 <colspec colnum="7" colname="col7"/>
|
|
3258 <colspec colnum="8" colname="col8"/>
|
|
3259 <colspec colnum="9" colname="col9"/>
|
|
3260 <colspec colnum="10" colname="col10"/>
|
|
3261 <colspec colnum="11" colname="col11"/>
|
|
3262 <colspec colnum="12" colname="col12"/>
|
|
3263 <colspec colnum="13" colname="col13"/>
|
|
3264 <colspec colnum="14" colname="col14"/>
|
|
3265 <colspec colnum="15" colname="col15"/>
|
|
3266 <colspec colnum="16" colname="col16"/>
|
|
3267 <colspec colnum="17" colname="col17"/>
|
|
3268 <spanspec spanname="spa2-5" namest="col2" nameend="col5"/>
|
|
3269 <spanspec spanname="spa6-11" namest="col6" nameend="col11"/>
|
|
3270 <spanspec spanname="spa12-17" namest="col12" nameend="col17"/>
|
|
3271 <tbody>
|
|
3272 <row>
|
|
3273 <entry></entry>
|
|
3274 <entry spanname="spa2-5">Simple</entry>
|
|
3275 <entry spanname="spa6-11">Advanced Simple</entry>
|
|
3276 <entry spanname="spa12-17">DivX</entry>
|
|
3277 </row>
|
|
3278 <row>
|
|
3279 <entry>Profile name</entry>
|
|
3280 <entry>0</entry>
|
|
3281 <entry>1</entry>
|
|
3282 <entry>2</entry>
|
|
3283 <entry>3</entry>
|
|
3284 <entry>0</entry>
|
|
3285 <entry>1</entry>
|
|
3286 <entry>2</entry>
|
|
3287 <entry>3</entry>
|
|
3288 <entry>4</entry>
|
|
3289 <entry>5</entry>
|
|
3290 <entry>Handheld</entry>
|
|
3291 <entry>Portable NTSC</entry>
|
|
3292 <entry>Portable PAL</entry>
|
|
3293 <entry>Home Theater NTSC</entry>
|
|
3294 <entry>Home Theater PAL</entry>
|
|
3295 <entry>HDTV</entry>
|
|
3296 </row>
|
|
3297 <row>
|
|
3298 <entry>Width [pixels]</entry>
|
|
3299 <entry>176</entry>
|
|
3300 <entry>176</entry>
|
|
3301 <entry>352</entry>
|
|
3302 <entry>352</entry>
|
|
3303 <entry>176</entry>
|
|
3304 <entry>176</entry>
|
|
3305 <entry>352</entry>
|
|
3306 <entry>352</entry>
|
|
3307 <entry>352</entry>
|
|
3308 <entry>720</entry>
|
|
3309 <entry>176</entry>
|
|
3310 <entry>352</entry>
|
|
3311 <entry>352</entry>
|
|
3312 <entry>720</entry>
|
|
3313 <entry>720</entry>
|
|
3314 <entry>1280</entry>
|
|
3315 </row>
|
|
3316 <row>
|
|
3317 <entry>Height [pixels]</entry>
|
|
3318 <entry>144</entry>
|
|
3319 <entry>144</entry>
|
|
3320 <entry>288</entry>
|
|
3321 <entry>288</entry>
|
|
3322 <entry>144</entry>
|
|
3323 <entry>144</entry>
|
|
3324 <entry>288</entry>
|
|
3325 <entry>288</entry>
|
|
3326 <entry>576</entry>
|
|
3327 <entry>576</entry>
|
|
3328 <entry>144</entry>
|
|
3329 <entry>240</entry>
|
|
3330 <entry>288</entry>
|
|
3331 <entry>480</entry>
|
|
3332 <entry>576</entry>
|
|
3333 <entry>720</entry>
|
|
3334 </row>
|
|
3335 <row>
|
|
3336 <entry>Frame rate [fps]</entry>
|
|
3337 <entry>15</entry>
|
|
3338 <entry>15</entry>
|
|
3339 <entry>15</entry>
|
|
3340 <entry>15</entry>
|
|
3341 <entry>30</entry>
|
|
3342 <entry>30</entry>
|
|
3343 <entry>15</entry>
|
|
3344 <entry>30</entry>
|
|
3345 <entry>30</entry>
|
|
3346 <entry>30</entry>
|
|
3347 <entry>15</entry>
|
|
3348 <entry>30</entry>
|
|
3349 <entry>25</entry>
|
|
3350 <entry>30</entry>
|
|
3351 <entry>25</entry>
|
|
3352 <entry>30</entry>
|
|
3353 </row>
|
|
3354 <row>
|
|
3355 <entry>Max average bitrate [kbps]</entry>
|
|
3356 <entry>64</entry>
|
|
3357 <entry>64</entry>
|
|
3358 <entry>128</entry>
|
|
3359 <entry>384</entry>
|
|
3360 <entry>128</entry>
|
|
3361 <entry>128</entry>
|
|
3362 <entry>384</entry>
|
|
3363 <entry>768</entry>
|
|
3364 <entry>3000</entry>
|
|
3365 <entry>8000</entry>
|
|
3366 <entry>537.6</entry>
|
|
3367 <entry>4854</entry>
|
|
3368 <entry>4854</entry>
|
|
3369 <entry>4854</entry>
|
|
3370 <entry>4854</entry>
|
|
3371 <entry>9708.4</entry>
|
|
3372 </row>
|
|
3373 <row>
|
|
3374 <entry>Peak average bitrate over 3 secs [kbps]</entry>
|
|
3375 <entry></entry>
|
|
3376 <entry></entry>
|
|
3377 <entry></entry>
|
|
3378 <entry></entry>
|
|
3379 <entry></entry>
|
|
3380 <entry></entry>
|
|
3381 <entry></entry>
|
|
3382 <entry></entry>
|
|
3383 <entry></entry>
|
|
3384 <entry></entry>
|
|
3385 <entry>800</entry>
|
|
3386 <entry>8000</entry>
|
|
3387 <entry>8000</entry>
|
|
3388 <entry>8000</entry>
|
|
3389 <entry>8000</entry>
|
|
3390 <entry>16000</entry>
|
|
3391 </row>
|
|
3392 <row>
|
|
3393 <entry>Max. B-frames</entry>
|
|
3394 <entry>0</entry>
|
|
3395 <entry>0</entry>
|
|
3396 <entry>0</entry>
|
|
3397 <entry>0</entry>
|
|
3398 <entry></entry>
|
|
3399 <entry></entry>
|
|
3400 <entry></entry>
|
|
3401 <entry></entry>
|
|
3402 <entry></entry>
|
|
3403 <entry></entry>
|
|
3404 <entry>0</entry>
|
|
3405 <entry>1</entry>
|
|
3406 <entry>1</entry>
|
|
3407 <entry>1</entry>
|
|
3408 <entry>1</entry>
|
|
3409 <entry>2</entry>
|
|
3410 </row>
|
|
3411 <row>
|
|
3412 <entry>MPEG quantization</entry>
|
|
3413 <entry></entry>
|
|
3414 <entry></entry>
|
|
3415 <entry></entry>
|
|
3416 <entry></entry>
|
|
3417 <entry>X</entry>
|
|
3418 <entry>X</entry>
|
|
3419 <entry>X</entry>
|
|
3420 <entry>X</entry>
|
|
3421 <entry>X</entry>
|
|
3422 <entry>X</entry>
|
|
3423 <entry></entry>
|
|
3424 <entry></entry>
|
|
3425 <entry></entry>
|
|
3426 <entry></entry>
|
|
3427 <entry></entry>
|
|
3428 <entry></entry>
|
|
3429 </row>
|
|
3430 <row>
|
|
3431 <entry>Adaptive quantization</entry>
|
|
3432 <entry></entry>
|
|
3433 <entry></entry>
|
|
3434 <entry></entry>
|
|
3435 <entry></entry>
|
|
3436 <entry>X</entry>
|
|
3437 <entry>X</entry>
|
|
3438 <entry>X</entry>
|
|
3439 <entry>X</entry>
|
|
3440 <entry>X</entry>
|
|
3441 <entry>X</entry>
|
|
3442 <entry>X</entry>
|
|
3443 <entry>X</entry>
|
|
3444 <entry>X</entry>
|
|
3445 <entry>X</entry>
|
|
3446 <entry>X</entry>
|
|
3447 <entry>X</entry>
|
|
3448 </row>
|
|
3449 <row>
|
|
3450 <entry>Interlaced encoding</entry>
|
|
3451 <entry></entry>
|
|
3452 <entry></entry>
|
|
3453 <entry></entry>
|
|
3454 <entry></entry>
|
|
3455 <entry>X</entry>
|
|
3456 <entry>X</entry>
|
|
3457 <entry>X</entry>
|
|
3458 <entry>X</entry>
|
|
3459 <entry>X</entry>
|
|
3460 <entry>X</entry>
|
|
3461 <entry></entry>
|
|
3462 <entry></entry>
|
|
3463 <entry></entry>
|
|
3464 <entry>X</entry>
|
|
3465 <entry>X</entry>
|
|
3466 <entry>X</entry>
|
|
3467 </row>
|
|
3468 <row>
|
|
3469 <entry>Quaterpixel</entry>
|
|
3470 <entry></entry>
|
|
3471 <entry></entry>
|
|
3472 <entry></entry>
|
|
3473 <entry></entry>
|
|
3474 <entry>X</entry>
|
|
3475 <entry>X</entry>
|
|
3476 <entry>X</entry>
|
|
3477 <entry>X</entry>
|
|
3478 <entry>X</entry>
|
|
3479 <entry>X</entry>
|
|
3480 <entry></entry>
|
|
3481 <entry></entry>
|
|
3482 <entry></entry>
|
|
3483 <entry></entry>
|
|
3484 <entry></entry>
|
|
3485 <entry></entry>
|
|
3486 </row>
|
|
3487 <row>
|
|
3488 <entry>Global motion compensation</entry>
|
|
3489 <entry></entry>
|
|
3490 <entry></entry>
|
|
3491 <entry></entry>
|
|
3492 <entry></entry>
|
|
3493 <entry>X</entry>
|
|
3494 <entry>X</entry>
|
|
3495 <entry>X</entry>
|
|
3496 <entry>X</entry>
|
|
3497 <entry>X</entry>
|
|
3498 <entry>X</entry>
|
|
3499 <entry></entry>
|
|
3500 <entry></entry>
|
|
3501 <entry></entry>
|
|
3502 <entry></entry>
|
|
3503 <entry></entry>
|
|
3504 <entry></entry>
|
|
3505 </row>
|
|
3506 </tbody>
|
|
3507 </tgroup>
|
|
3508 </informaltable>
|
|
3509 </sect2>
|
|
3510
|
|
3511 <!-- ********** -->
|
|
3512
|
|
3513 <sect2 id="menc-feat-xvid-example-settings">
|
|
3514 <title>Encoding setting examples</title>
|
|
3515
|
|
3516 <para>
|
|
3517 The following settings are examples of different encoding
|
|
3518 option combinations that affect the speed vs quality tradeoff
|
|
3519 at the same target bitrate.
|
|
3520 </para>
|
|
3521
|
|
3522 <para>
|
|
3523 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
3524 video sample, the target bitrate was 900kbps, and the machine was an
|
|
3525 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
3526 Each encoding setting features the measured encoding speed (in
|
|
3527 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
3528 high quality" setting.
|
|
3529 Please understand that depending on your source, your machine type
|
|
3530 and development advancements, you may get very different results.
|
|
3531 </para>
|
|
3532
|
|
3533 <informaltable frame="all">
|
|
3534 <tgroup cols="4">
|
|
3535 <thead>
|
|
3536 <row><entry>Description</entry><entry>Encoding options</entry><entry>speed (in fps)</entry><entry>Relative PSNR loss (in dB)</entry></row>
|
|
3537 </thead>
|
|
3538 <tbody>
|
|
3539 <row>
|
|
3540 <entry>Very high quality</entry>
|
|
3541 <entry><option>chroma_opt:vhq=4:bvhq=1:quant_type=mpeg</option></entry>
|
|
3542 <entry>16fps</entry>
|
|
3543 <entry>0dB</entry>
|
|
3544 </row>
|
|
3545 <row>
|
|
3546 <entry>High quality</entry>
|
|
3547 <entry><option>vhq=2:bvhq=1:chroma_opt:quant_type=mpeg</option></entry>
|
|
3548 <entry>18fps</entry>
|
|
3549 <entry>-0.1dB</entry>
|
|
3550 </row>
|
|
3551 <row>
|
|
3552 <entry>Fast</entry>
|
|
3553 <entry><option>turbo:vhq=0</option></entry>
|
|
3554 <entry>28fps</entry>
|
|
3555 <entry>-0.69dB</entry>
|
|
3556 </row>
|
|
3557 <row>
|
|
3558 <entry>Realtime</entry>
|
|
3559 <entry><option>turbo:nochroma_me:notrellis:max_bframes=0:vhq=0</option></entry>
|
|
3560 <entry>38fps</entry>
|
|
3561 <entry>-1.48dB</entry>
|
|
3562 </row>
|
|
3563 </tbody>
|
|
3564 </tgroup>
|
|
3565 </informaltable>
|
|
3566 </sect2>
|
|
3567 </sect1>
|
|
3568
|
|
3569
|
|
3570 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
3571
|
|
3572
|
|
3573 <sect1 id="menc-feat-x264">
|
|
3574 <title>Encoding with the
|
|
3575 <systemitem class="library">x264</systemitem> codec</title>
|
|
3576
|
|
3577 <para>
|
|
3578 <systemitem class="library">x264</systemitem> is a free library for
|
|
3579 encoding H.264/AVC video streams.
|
|
3580 Before starting to encode, you need to
|
28476
|
3581 <link linkend="x264">set up <application>MEncoder</application> to support it</link>.
|
25279
|
3582 </para>
|
|
3583
|
|
3584 <!-- ********** -->
|
|
3585
|
|
3586 <sect2 id="menc-feat-x264-encoding-options">
|
|
3587 <title>Encoding options of x264</title>
|
|
3588
|
|
3589 <para>
|
|
3590 Please begin by reviewing the
|
|
3591 <systemitem class="library">x264</systemitem> section of
|
|
3592 <application>MPlayer</application>'s man page.
|
|
3593 This section is intended to be a supplement to the man page.
|
|
3594 Here you will find quick hints about which options are most
|
|
3595 likely to interest most people. The man page is more terse,
|
|
3596 but also more exhaustive, and it sometimes offers much better
|
|
3597 technical detail.
|
|
3598 </para>
|
|
3599
|
|
3600
|
|
3601 <sect3 id="menc-feat-x264-encoding-options-intro">
|
|
3602 <title>Introduction</title>
|
|
3603
|
|
3604 <para>
|
|
3605 This guide considers two major categories of encoding options:
|
|
3606 </para>
|
|
3607
|
|
3608 <orderedlist>
|
|
3609 <listitem><para>
|
|
3610 Options which mainly trade off encoding time vs. quality
|
|
3611 </para></listitem>
|
|
3612 <listitem><para>
|
|
3613 Options which may be useful for fulfilling various personal
|
|
3614 preferences and special requirements
|
|
3615 </para></listitem>
|
|
3616 </orderedlist>
|
|
3617
|
|
3618 <para>
|
|
3619 Ultimately, only you can decide which options are best for your
|
|
3620 purposes. The decision for the first class of options is the simplest:
|
|
3621 you only have to decide whether you think the quality differences
|
|
3622 justify the speed differences. For the second class of options,
|
|
3623 preferences may be far more subjective, and more factors may be
|
|
3624 involved. Note that some of the "personal preferences and special
|
|
3625 requirements" options can still have large impacts on speed or quality,
|
|
3626 but that is not what they are primarily useful for. A couple of the
|
|
3627 "personal preference" options may even cause changes that look better
|
|
3628 to some people, but look worse to others.
|
|
3629 </para>
|
|
3630
|
|
3631 <para>
|
|
3632 Before continuing, you need to understand that this guide uses only one
|
|
3633 quality metric: global PSNR.
|
|
3634 For a brief explanation of what PSNR is, see
|
|
3635 <ulink url="http://en.wikipedia.org/wiki/PSNR">the Wikipedia article on PSNR</ulink>.
|
|
3636 Global PSNR is the last PSNR number reported when you include
|
|
3637 the <option>psnr</option> option in <option>x264encopts</option>.
|
|
3638 Any time you read a claim about PSNR, one of the assumptions
|
|
3639 behind the claim is that equal bitrates are used.
|
|
3640 </para>
|
|
3641
|
|
3642 <para>
|
|
3643 Nearly all of this guide's comments assume you are using two pass.
|
|
3644 When comparing options, there are two major reasons for using
|
|
3645 two pass encoding.
|
|
3646 First, using two pass often gains around 1dB PSNR, which is a
|
|
3647 very big difference.
|
|
3648 Secondly, testing options by doing direct quality comparisons
|
|
3649 with one pass encodes introduces a major confounding
|
|
3650 factor: bitrate often varies significantly with each encode.
|
|
3651 It is not always easy to tell whether quality changes are due
|
|
3652 mainly to changed options, or if they mostly reflect essentially
|
|
3653 random differences in the achieved bitrate.
|
|
3654 </para>
|
|
3655 </sect3>
|
|
3656
|
|
3657
|
|
3658 <sect3 id="menc-feat-x264-encoding-options-speedvquality">
|
|
3659 <title>Options which primarily affect speed and quality</title>
|
|
3660
|
|
3661 <itemizedlist>
|
|
3662 <listitem>
|
|
3663 <para>
|
|
3664 <emphasis role="bold">subq</emphasis>:
|
|
3665 Of the options which allow you to trade off speed for quality,
|
|
3666 <option>subq</option> and <option>frameref</option> (see below) are usually
|
|
3667 by far the most important.
|
|
3668 If you are interested in tweaking either speed or quality, these
|
|
3669 are the first options you should consider.
|
|
3670 On the speed dimension, the <option>frameref</option> and
|
|
3671 <option>subq</option> options interact with each other fairly
|
|
3672 strongly.
|
|
3673 Experience shows that, with one reference frame,
|
|
3674 <option>subq=5</option> (the default setting) takes about 35% more time than
|
|
3675 <option>subq=1</option>.
|
|
3676 With 6 reference frames, the penalty grows to over 60%.
|
|
3677 <option>subq</option>'s effect on PSNR seems fairly constant
|
|
3678 regardless of the number of reference frames.
|
|
3679 Typically, <option>subq=5</option> achieves 0.2-0.5 dB higher global
|
|
3680 PSNR in comparison <option>subq=1</option>.
|
|
3681 This is usually enough to be visible.
|
|
3682 </para>
|
|
3683 <para>
|
|
3684 <option>subq=6</option> is slower and yields better quality at a reasonable
|
|
3685 cost.
|
|
3686 In comparison to <option>subq=5</option>, it usually gains 0.1-0.4 dB
|
|
3687 global PSNR with speed costs varying from 25%-100%.
|
|
3688 Unlike other levels of <option>subq</option>, the behavior of
|
|
3689 <option>subq=6</option> does not depend much on <option>frameref</option>
|
|
3690 and <option>me</option>. Instead, the effectiveness of <option>subq=6
|
|
3691 </option> depends mostly upon the number of B-frames used. In normal
|
|
3692 usage, this means <option>subq=6</option> has a large impact on both speed
|
|
3693 and quality in complex, high motion scenes, but it may not have much effect
|
|
3694 in low-motion scenes. Note that it is still recommended to always set
|
|
3695 <option>bframes</option> to something other than zero (see below).
|
|
3696 </para>
|
|
3697 <para>
|
|
3698 <option>subq=7</option> is the slowest, highest quality mode.
|
|
3699 In comparison to <option>subq=6</option>, it usually gains 0.01-0.05 dB
|
|
3700 global PSNR with speed costs varying from 15%-33%.
|
|
3701 Since the tradeoff encoding time vs. quality is quite low, you should
|
|
3702 only use it if you are after every bit saving and if encoding time is
|
|
3703 not an issue.
|
|
3704 </para>
|
|
3705 </listitem>
|
|
3706 <listitem>
|
|
3707 <para>
|
|
3708 <emphasis role="bold">frameref</emphasis>:
|
|
3709 <option>frameref</option> is set to 1 by default, but this
|
|
3710 should not be taken to imply that it is reasonable to set it to 1.
|
|
3711 Merely raising <option>frameref</option> to 2 gains around
|
|
3712 0.15dB PSNR with a 5-10% speed penalty; this seems like a good tradeoff.
|
|
3713 <option>frameref=3</option> gains around 0.25dB PSNR over
|
|
3714 <option>frameref=1</option>, which should be a visible difference.
|
|
3715 <option>frameref=3</option> is around 15% slower than
|
|
3716 <option>frameref=1</option>.
|
|
3717 Unfortunately, diminishing returns set in rapidly.
|
|
3718 <option>frameref=6</option> can be expected to gain only
|
|
3719 0.05-0.1 dB over <option>frameref=3</option> at an additional
|
|
3720 15% speed penalty.
|
|
3721 Above <option>frameref=6</option>, the quality gains are
|
|
3722 usually very small (although you should keep in mind throughout
|
|
3723 this whole discussion that it can vary quite a lot depending on your source).
|
|
3724 In a fairly typical case, <option>frameref=12</option>
|
|
3725 will improve global PSNR by a tiny 0.02dB over
|
|
3726 <option>frameref=6</option>, at a speed cost of 15%-20%.
|
|
3727 At such high <option>frameref</option> values, the only really
|
|
3728 good thing that can be said is that increasing it even further will
|
|
3729 almost certainly never <emphasis role="bold">harm</emphasis>
|
|
3730 PSNR, but the additional quality benefits are barely even
|
|
3731 measurable, let alone perceptible.
|
|
3732 </para>
|
|
3733 <note><title>Note:</title>
|
|
3734 <para>
|
|
3735 Raising <option>frameref</option> to unnecessarily high values
|
|
3736 <emphasis role="bold">can</emphasis> and
|
|
3737 <emphasis role="bold">usually does</emphasis>
|
|
3738 hurt coding efficiency if you turn CABAC off.
|
|
3739 With CABAC on (the default behavior), the possibility of setting
|
|
3740 <option>frameref</option> "too high" currently seems too remote
|
|
3741 to even worry about, and in the future, optimizations may remove
|
|
3742 the possibility altogether.
|
|
3743 </para></note>
|
|
3744 <para>
|
|
3745 If you care about speed, a reasonable compromise is to use low
|
|
3746 <option>subq</option> and <option>frameref</option> values on
|
|
3747 the first pass, and then raise them on the second pass.
|
|
3748 Typically, this has a negligible negative effect on the final
|
|
3749 quality: You will probably lose well under 0.1dB PSNR, which
|
|
3750 should be much too small of a difference to see.
|
|
3751 However, different values of <option>frameref</option> can
|
|
3752 occasionally affect frametype decision.
|
|
3753 Most likely, these are rare outlying cases, but if you want to
|
|
3754 be pretty sure, consider whether your video has either
|
|
3755 fullscreen repetitive flashing patterns or very large temporary
|
|
3756 occlusions which might force an I-frame.
|
|
3757 Adjust the first-pass <option>frameref</option> so it is large
|
|
3758 enough to contain the duration of the flashing cycle (or occlusion).
|
|
3759 For example, if the scene flashes back and forth between two images
|
|
3760 over a duration of three frames, set the first pass
|
|
3761 <option>frameref</option> to 3 or higher.
|
|
3762 This issue is probably extremely rare in live action video material,
|
|
3763 but it does sometimes come up in video game captures.
|
|
3764 </para>
|
|
3765 </listitem>
|
|
3766 <listitem>
|
|
3767 <para>
|
|
3768 <emphasis role="bold">me</emphasis>:
|
|
3769 This option is for choosing the motion estimation search method.
|
|
3770 Altering this option provides a straightforward quality-vs-speed
|
|
3771 tradeoff. <option>me=dia</option> is only a few percent faster than
|
|
3772 the default search, at a cost of under 0.1dB global PSNR. The
|
|
3773 default setting (<option>me=hex</option>) is a reasonable tradeoff
|
|
3774 between speed and quality. <option>me=umh</option> gains a little under
|
|
3775 0.1dB global PSNR, with a speed penalty that varies depending on
|
|
3776 <option>frameref</option>. At high values of
|
|
3777 <option>frameref</option> (e.g. 12 or so), <option>me=umh</option>
|
|
3778 is about 40% slower than the default <option> me=hex</option>. With
|
|
3779 <option>frameref=3</option>, the speed penalty incurred drops to
|
|
3780 25%-30%.
|
|
3781 </para>
|
|
3782 <para>
|
|
3783 <option>me=esa</option> uses an exhaustive search that is too slow for
|
|
3784 practical use.
|
|
3785 </para>
|
|
3786 </listitem>
|
|
3787 <listitem><para>
|
|
3788 <emphasis role="bold">partitions=all</emphasis>:
|
|
3789 This option enables the use of 8x4, 4x8 and 4x4 subpartitions in
|
|
3790 predicted macroblocks (in addition to the default partitions).
|
|
3791 Enabling it results in a fairly consistent
|
|
3792 10%-15% loss of speed. This option is rather useless in source
|
|
3793 containing only low motion, however in some high-motion source,
|
|
3794 particularly source with lots of small moving objects, gains of
|
|
3795 about 0.1dB can be expected.
|
|
3796 </para></listitem>
|
|
3797 <listitem>
|
|
3798 <para>
|
|
3799 <emphasis role="bold">bframes</emphasis>:
|
|
3800 If you are used to encoding with other codecs, you may have found
|
|
3801 that B-frames are not always useful.
|
|
3802 In H.264, this has changed: there are new techniques and block
|
|
3803 types that are possible in B-frames.
|
|
3804 Usually, even a naive B-frame choice algorithm can have a
|
|
3805 significant PSNR benefit.
|
|
3806 It is interesting to note that using B-frames usually speeds up
|
|
3807 the second pass somewhat, and may also speed up a single
|
|
3808 pass encode if adaptive B-frame decision is turned off.
|
|
3809 </para>
|
|
3810 <para>
|
|
3811 With adaptive B-frame decision turned off
|
|
3812 (<option>x264encopts</option>'s <option>nob_adapt</option>),
|
|
3813 the optimal value for this setting is usually no more than
|
|
3814 <option>bframes=1</option>, or else high-motion scenes can suffer.
|
|
3815 With adaptive B-frame decision on (the default behavior), it is
|
|
3816 safe to use higher values; the encoder will reduce the use of
|
|
3817 B-frames in scenes where they would hurt compression.
|
|
3818 The encoder rarely chooses to use more than 3 or 4 B-frames;
|
|
3819 setting this option any higher will have little effect.
|
|
3820 </para>
|
|
3821 </listitem>
|
|
3822 <listitem>
|
|
3823 <para>
|
|
3824 <emphasis role="bold">b_adapt</emphasis>:
|
|
3825 Note: This is on by default.
|
|
3826 </para>
|
|
3827 <para>
|
|
3828 With this option enabled, the encoder will use a reasonably fast
|
|
3829 decision process to reduce the number of B-frames used in scenes that
|
|
3830 might not benefit from them as much.
|
|
3831 You can use <option>b_bias</option> to tweak how B-frame-happy
|
|
3832 the encoder is.
|
|
3833 The speed penalty of adaptive B-frames is currently rather modest,
|
|
3834 but so is the potential quality gain.
|
|
3835 It usually does not hurt, however.
|
|
3836 Note that this only affects speed and frametype decision on the
|
|
3837 first pass.
|
|
3838 <option>b_adapt</option> and <option>b_bias</option> have no
|
|
3839 effect on subsequent passes.
|
|
3840 </para>
|
|
3841 </listitem>
|
|
3842 <listitem><para>
|
|
3843 <emphasis role="bold">b_pyramid</emphasis>:
|
|
3844 You might as well enable this option if you are using >=2 B-frames;
|
|
3845 as the man page says, you get a little quality improvement at no
|
|
3846 speed cost.
|
|
3847 Note that these videos cannot be read by libavcodec-based decoders
|
|
3848 older than about March 5, 2005.
|
|
3849 </para></listitem>
|
|
3850 <listitem>
|
|
3851 <para>
|
|
3852 <emphasis role="bold">weight_b</emphasis>:
|
|
3853 In typical cases, there is not much gain with this option.
|
|
3854 However, in crossfades or fade-to-black scenes, weighted
|
|
3855 prediction gives rather large bitrate savings.
|
|
3856 In MPEG-4 ASP, a fade-to-black is usually best coded as a series
|
|
3857 of expensive I-frames; using weighted prediction in B-frames
|
|
3858 makes it possible to turn at least some of these into much smaller
|
|
3859 B-frames.
|
|
3860 Encoding time cost is minimal, as no extra decisions need to be made.
|
|
3861 Also, contrary to what some people seem to guess, the decoder
|
|
3862 CPU requirements are not much affected by weighted prediction,
|
|
3863 all else being equal.
|
|
3864 </para>
|
|
3865 <para>
|
|
3866 Unfortunately, the current adaptive B-frame decision algorithm
|
|
3867 has a strong tendency to avoid B-frames during fades.
|
|
3868 Until this changes, it may be a good idea to add
|
|
3869 <option>nob_adapt</option> to your x264encopts, if you expect
|
|
3870 fades to have a large effect in your particular video
|
|
3871 clip.
|
|
3872 </para>
|
|
3873 </listitem>
|
|
3874 <listitem id="menc-feat-x264-encoding-options-speedvquality-threads">
|
|
3875 <para>
|
|
3876 <emphasis role="bold">threads</emphasis>:
|
|
3877 This option allows to spawn threads to encode in parallel on multiple CPUs.
|
|
3878 You can manually select the number of threads to be created or, better, set
|
|
3879 <option>threads=auto</option> and let
|
|
3880 <systemitem class="library">x264</systemitem> detect how many CPUs are
|
|
3881 available and pick an appropriate number of threads.
|
|
3882 If you have a multi-processor machine, you should really consider using it
|
|
3883 as it can to increase encoding speed linearly with the number of CPU cores
|
|
3884 (about 94% per CPU core), with very little quality reduction (about 0.005dB
|
|
3885 for dual processor, about 0.01dB for a quad processor machine).
|
|
3886 </para>
|
|
3887 </listitem>
|
|
3888 </itemizedlist>
|
|
3889 </sect3>
|
|
3890
|
|
3891
|
|
3892 <sect3 id="menc-feat-x264-encoding-options-misc-preferences">
|
|
3893 <title>Options pertaining to miscellaneous preferences</title>
|
|
3894
|
|
3895 <itemizedlist>
|
|
3896 <listitem>
|
|
3897 <para>
|
|
3898 <emphasis role="bold">Two pass encoding</emphasis>:
|
|
3899 Above, it was suggested to always use two pass encoding, but there
|
|
3900 are still reasons for not using it. For instance, if you are capturing
|
|
3901 live TV and encoding in realtime, you are forced to use single-pass.
|
|
3902 Also, one pass is obviously faster than two passes; if you use the
|
|
3903 exact same set of options on both passes, two pass encoding is almost
|
|
3904 twice as slow.
|
|
3905 </para>
|
|
3906 <para>
|
|
3907 Still, there are very good reasons for using two pass encoding. For
|
|
3908 one thing, single pass ratecontrol is not psychic, and it often makes
|
|
3909 unreasonable choices because it cannot see the big picture. For example,
|
|
3910 suppose you have a two minute long video consisting of two distinct
|
|
3911 halves. The first half is a very high-motion scene lasting 60 seconds
|
|
3912 which, in isolation, requires about 2500kbps in order to look decent.
|
|
3913 Immediately following it is a much less demanding 60-second scene
|
|
3914 that looks good at 300kbps. Suppose you ask for 1400kbps on the theory
|
|
3915 that this is enough to accomodate both scenes. Single pass ratecontrol
|
|
3916 will make a couple of "mistakes" in such a case. First of all, it
|
|
3917 will target 1400kbps in both segments. The first segment may end up
|
|
3918 heavily overquantized, causing it to look unacceptably and unreasonably
|
|
3919 blocky. The second segment will be heavily underquantized; it may look
|
|
3920 perfect, but the bitrate cost of that perfection will be completely
|
|
3921 unreasonable. What is even harder to avoid is the problem at the
|
|
3922 transition between the two scenes. The first seconds of the low motion
|
|
3923 half will be hugely over-quantized, because the ratecontrol is still
|
|
3924 expecting the kind of bitrate requirements it met in the first half
|
|
3925 of the video. This "error period" of heavily over-quantized low motion
|
|
3926 will look jarringly bad, and will actually use less than the 300kbps
|
|
3927 it would have taken to make it look decent. There are ways to
|
|
3928 mitigate the pitfalls of single-pass encoding, but they may tend to
|
|
3929 increase bitrate misprediction.
|
|
3930 </para>
|
|
3931 <para>
|
|
3932 Multipass ratecontrol can offer huge advantages over a single pass.
|
|
3933 Using the statistics gathered from the first pass encode, the encoder
|
|
3934 can estimate, with reasonable accuracy, the "cost" (in bits) of
|
|
3935 encoding any given frame, at any given quantizer. This allows for
|
|
3936 a much more rational, better planned allocation of bits between the
|
|
3937 expensive (high-motion) and cheap (low-motion) scenes. See
|
|
3938 <option>qcomp</option> below for some ideas on how to tweak this
|
|
3939 allocation to your liking.
|
|
3940 </para>
|
|
3941 <para>
|
|
3942 Moreover, two passes need not take twice as long as one pass. You can
|
|
3943 tweak the options in the first pass for higher speed and lower quality.
|
|
3944 If you choose your options well, you can get a very fast first pass.
|
|
3945 The resulting quality in the second pass will be slightly lower because size
|
|
3946 prediction is less accurate, but the quality difference is normally much
|
|
3947 too small to be visible. Try, for example, adding
|
|
3948 <option>subq=1:frameref=1</option> to the first pass
|
|
3949 <option>x264encopts</option>. Then, on the second pass, use slower,
|
|
3950 higher-quality options:
|
|
3951 <option>subq=6:frameref=15:partitions=all:me=umh</option>
|
|
3952 </para>
|
|
3953 </listitem>
|
|
3954 <listitem><para>
|
|
3955 <emphasis role="bold">Three pass encoding</emphasis>?
|
|
3956 x264 offers the ability to make an arbitrary number of consecutive
|
|
3957 passes. If you specify <option>pass=1</option> on the first pass,
|
|
3958 then use <option>pass=3</option> on a subsequent pass, the subsequent
|
|
3959 pass will both read the statistics from the previous pass, and write
|
|
3960 its own statistics. An additional pass following this one will have
|
|
3961 a very good base from which to make highly accurate predictions of
|
|
3962 framesizes at a chosen quantizer. In practice, the overall quality
|
|
3963 gain from this is usually close to zero, and quite possibly a third
|
|
3964 pass will result in slightly worse global PSNR than the pass before
|
|
3965 it. In typical usage, three passes help if you get either bad bitrate
|
|
3966 prediction or bad looking scene transitions when using only two passes.
|
|
3967 This is somewhat likely to happen on extremely short clips. There are
|
|
3968 also a few special cases in which three (or more) passes are handy
|
|
3969 for advanced users, but for brevity, this guide omits discussing those
|
|
3970 special cases.
|
|
3971 </para></listitem>
|
|
3972 <listitem><para>
|
|
3973 <emphasis role="bold">qcomp</emphasis>:
|
|
3974 <option>qcomp</option> trades off the number of bits allocated
|
|
3975 to "expensive" high-motion versus "cheap" low-motion frames. At
|
|
3976 one extreme, <option>qcomp=0</option> aims for true constant
|
|
3977 bitrate. Typically this would make high-motion scenes look completely
|
|
3978 awful, while low-motion scenes would probably look absolutely
|
|
3979 perfect, but would also use many times more bitrate than they
|
|
3980 would need in order to look merely excellent. At the other extreme,
|
|
3981 <option>qcomp=1</option> achieves nearly constant quantization parameter
|
|
3982 (QP). Constant QP does not look bad, but most people think it is more
|
|
3983 reasonable to shave some bitrate off of the extremely expensive scenes
|
|
3984 (where the loss of quality is not as noticeable) and reallocate it to
|
|
3985 the scenes that are easier to encode at excellent quality.
|
|
3986 <option>qcomp</option> is set to 0.6 by default, which may be slightly
|
|
3987 low for many peoples' taste (0.7-0.8 are also commonly used).
|
|
3988 </para></listitem>
|
|
3989 <listitem><para>
|
|
3990 <emphasis role="bold">keyint</emphasis>:
|
|
3991 <option>keyint</option> is solely for trading off file seekability against
|
|
3992 coding efficiency. By default, <option>keyint</option> is set to 250. In
|
|
3993 25fps material, this guarantees the ability to seek to within 10 seconds
|
|
3994 precision. If you think it would be important and useful to be able to
|
|
3995 seek within 5 seconds of precision, set <option>keyint=125</option>;
|
|
3996 this will hurt quality/bitrate slightly. If you care only about quality
|
|
3997 and not about seekability, you can set it to much higher values
|
|
3998 (understanding that there are diminishing returns which may become
|
|
3999 vanishingly low, or even zero). The video stream will still have seekable
|
|
4000 points as long as there are some scene changes.
|
|
4001 </para></listitem>
|
|
4002 <listitem>
|
|
4003 <para>
|
|
4004 <emphasis role="bold">deblock</emphasis>:
|
|
4005 This topic is going to be a bit controversial.
|
|
4006 </para>
|
|
4007 <para>
|
|
4008 H.264 defines a simple deblocking procedure on I-blocks that uses
|
|
4009 pre-set strengths and thresholds depending on the QP of the block
|
|
4010 in question.
|
|
4011 By default, high QP blocks are filtered heavily, and low QP blocks
|
|
4012 are not deblocked at all.
|
|
4013 The pre-set strengths defined by the standard are well-chosen and
|
|
4014 the odds are very good that they are PSNR-optimal for whatever
|
|
4015 video you are trying to encode.
|
|
4016 The <option>deblock</option> allow you to specify offsets to the preset
|
|
4017 deblocking thresholds.
|
|
4018 </para>
|
|
4019 <para>
|
|
4020 Many people seem to think it is a good idea to lower the deblocking
|
|
4021 filter strength by large amounts (say, -3).
|
|
4022 This is however almost never a good idea, and in most cases,
|
|
4023 people who are doing this do not understand very well how
|
|
4024 deblocking works by default.
|
|
4025 </para>
|
|
4026 <para>
|
|
4027 The first and most important thing to know about the in-loop
|
|
4028 deblocking filter is that the default thresholds are almost always
|
|
4029 PSNR-optimal.
|
|
4030 In the rare cases that they are not optimal, the ideal offset is
|
|
4031 plus or minus 1.
|
|
4032 Adjusting deblocking parameters by a larger amount is almost
|
|
4033 guaranteed to hurt PSNR.
|
|
4034 Strengthening the filter will smear more details; weakening the
|
|
4035 filter will increase the appearance of blockiness.
|
|
4036 </para>
|
|
4037 <para>
|
|
4038 It is definitely a bad idea to lower the deblocking thresholds if
|
|
4039 your source is mainly low in spacial complexity (i.e., not a lot
|
|
4040 of detail or noise).
|
|
4041 The in-loop filter does a rather excellent job of concealing
|
|
4042 the artifacts that occur.
|
|
4043 If the source is high in spacial complexity, however, artifacts
|
|
4044 are less noticeable.
|
|
4045 This is because the ringing tends to look like detail or noise.
|
|
4046 Human visual perception easily notices when detail is removed,
|
|
4047 but it does not so easily notice when the noise is wrongly
|
|
4048 represented.
|
|
4049 When it comes to subjective quality, noise and detail are somewhat
|
|
4050 interchangeable.
|
|
4051 By lowering the deblocking filter strength, you are most likely
|
|
4052 increasing error by adding ringing artifacts, but the eye does
|
|
4053 not notice because it confuses the artifacts with detail.
|
|
4054 </para>
|
|
4055 <para>
|
|
4056 This <emphasis role="bold">still</emphasis> does not justify
|
|
4057 lowering the deblocking filter strength, however.
|
|
4058 You can generally get better quality noise from postprocessing.
|
|
4059 If your H.264 encodes look too blurry or smeared, try playing with
|
|
4060 <option>-vf noise</option> when you play your encoded movie.
|
|
4061 <option>-vf noise=8a:4a</option> should conceal most mild
|
|
4062 artifacting.
|
|
4063 It will almost certainly look better than the results you
|
|
4064 would have gotten just by fiddling with the deblocking filter.
|
|
4065 </para>
|
|
4066 </listitem>
|
|
4067 </itemizedlist>
|
|
4068 </sect3>
|
|
4069 </sect2>
|
|
4070
|
|
4071 <!-- ********** -->
|
|
4072
|
|
4073 <sect2 id="menc-feat-x264-example-settings">
|
|
4074 <title>Encoding setting examples</title>
|
|
4075
|
|
4076 <para>
|
|
4077 The following settings are examples of different encoding
|
|
4078 option combinations that affect the speed vs quality tradeoff
|
|
4079 at the same target bitrate.
|
|
4080 </para>
|
|
4081
|
|
4082 <para>
|
|
4083 All the encoding settings were tested on a 720x448 @30000/1001 fps
|
|
4084 video sample, the target bitrate was 900kbps, and the machine was an
|
|
4085 AMD-64 3400+ at 2400 MHz in 64 bits mode.
|
|
4086 Each encoding setting features the measured encoding speed (in
|
|
4087 frames per second) and the PSNR loss (in dB) compared to the "very
|
|
4088 high quality" setting.
|
|
4089 Please understand that depending on your source, your machine type
|
|
4090 and development advancements, you may get very different results.
|
|
4091 </para>
|
|
4092
|
|
4093 <informaltable frame="all">
|
|
4094 <tgroup cols="4">
|
|
4095 <thead>
|
|
4096 <row>
|
|
4097 <entry>Description</entry>
|
|
4098 <entry>Encoding options</entry>
|
|
4099 <entry>speed (in fps)</entry>
|
|
4100 <entry>Relative PSNR loss (in dB)</entry>
|
|
4101 </row>
|
|
4102 </thead>
|
|
4103 <tbody>
|
|
4104 <row>
|
|
4105 <entry>Very high quality</entry>
|
|
4106 <entry><option>subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4107 <entry>6fps</entry>
|
|
4108 <entry>0dB</entry>
|
|
4109 </row>
|
|
4110 <row>
|
|
4111 <entry>High quality</entry>
|
|
4112 <entry><option>subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b</option></entry>
|
|
4113 <entry>13fps</entry>
|
|
4114 <entry>-0.89dB</entry>
|
|
4115 </row>
|
|
4116 <row>
|
|
4117 <entry>Fast</entry>
|
|
4118 <entry><option>subq=4:bframes=2:b_pyramid:weight_b</option></entry>
|
|
4119 <entry>17fps</entry>
|
|
4120 <entry>-1.48dB</entry>
|
|
4121 </row>
|
|
4122 </tbody>
|
|
4123 </tgroup>
|
|
4124 </informaltable>
|
|
4125 </sect2>
|
|
4126 </sect1>
|
|
4127
|
|
4128
|
|
4129 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4130
|
|
4131
|
|
4132 <sect1 id="menc-feat-video-for-windows">
|
|
4133 <title>
|
|
4134 Encoding with the <systemitem class="library">Video For Windows</systemitem>
|
|
4135 codec family
|
|
4136 </title>
|
|
4137
|
|
4138 <para>
|
|
4139 Video for Windows provides simple encoding by means of binary video codecs.
|
|
4140 You can encode with the following codecs (if you have more, please tell us!)
|
|
4141 </para>
|
|
4142
|
|
4143 <para>
|
|
4144 Note that support for this is very experimental and some codecs may not work
|
|
4145 correctly. Some codecs will only work in certain colorspaces, try
|
|
4146 <option>-vf format=bgr24</option> and <option>-vf format=yuy2</option>
|
|
4147 if a codec fails or gives wrong output.
|
|
4148 </para>
|
|
4149
|
|
4150 <!-- ********** -->
|
|
4151
|
|
4152 <sect2 id="menc-feat-enc-vfw-video-codecs">
|
|
4153 <title>Video for Windows supported codecs</title>
|
|
4154
|
|
4155 <para>
|
|
4156 <informaltable frame="all">
|
|
4157 <tgroup cols="4">
|
|
4158 <thead>
|
|
4159 <row>
|
|
4160 <entry>Video codec file name</entry>
|
|
4161 <entry>Description (FourCC)</entry>
|
|
4162 <entry>md5sum</entry>
|
|
4163 <entry>Comment</entry>
|
|
4164 </row>
|
|
4165 </thead>
|
|
4166 <tbody>
|
|
4167 <row>
|
|
4168 <entry>aslcodec_vfw.dll</entry>
|
|
4169 <entry>Alparysoft lossless codec vfw (ASLC)</entry>
|
|
4170 <entry>608af234a6ea4d90cdc7246af5f3f29a</entry>
|
|
4171 <entry></entry>
|
|
4172 </row>
|
|
4173 <row>
|
|
4174 <entry>avimszh.dll</entry>
|
|
4175 <entry>AVImszh (MSZH)</entry>
|
|
4176 <entry>253118fe1eedea04a95ed6e5f4c28878</entry>
|
|
4177 <entry>needs <option>-vf format</option></entry>
|
|
4178 </row>
|
|
4179 <row>
|
|
4180 <entry>avizlib.dll</entry>
|
|
4181 <entry>AVIzlib (ZLIB)</entry>
|
|
4182 <entry>2f1cc76bbcf6d77d40d0e23392fa8eda</entry>
|
|
4183 <entry></entry>
|
|
4184 </row>
|
|
4185 <row>
|
|
4186 <entry>divx.dll</entry>
|
|
4187 <entry>DivX4Windows-VFW</entry>
|
|
4188 <entry>acf35b2fc004a89c829531555d73f1e6</entry>
|
|
4189 <entry></entry>
|
|
4190 </row>
|
|
4191 <row>
|
|
4192 <entry>huffyuv.dll</entry>
|
|
4193 <entry>HuffYUV (lossless) (HFYU)</entry>
|
|
4194 <entry>b74695b50230be4a6ef2c4293a58ac3b</entry>
|
|
4195 <entry></entry>
|
|
4196 </row>
|
|
4197 <row>
|
|
4198 <entry>iccvid.dll</entry>
|
|
4199 <entry>Cinepak Video (cvid)</entry>
|
|
4200 <entry>cb3b7ee47ba7dbb3d23d34e274895133</entry>
|
|
4201 <entry></entry>
|
|
4202 </row>
|
|
4203 <row>
|
|
4204 <entry>icmw_32.dll</entry>
|
|
4205 <entry>Motion Wavelets (MWV1)</entry>
|
|
4206 <entry>c9618a8fc73ce219ba918e3e09e227f2</entry>
|
|
4207 <entry></entry>
|
|
4208 </row>
|
|
4209 <row>
|
|
4210 <entry>jp2avi.dll</entry>
|
|
4211 <entry>ImagePower MJPEG2000 (IPJ2)</entry>
|
|
4212 <entry>d860a11766da0d0ea064672c6833768b</entry>
|
|
4213 <entry><option>-vf flip</option></entry>
|
|
4214 </row>
|
|
4215 <row>
|
|
4216 <entry>m3jp2k32.dll</entry>
|
|
4217 <entry>Morgan MJPEG2000 (MJ2C)</entry>
|
|
4218 <entry>f3c174edcbaef7cb947d6357cdfde7ff</entry>
|
|
4219 <entry></entry>
|
|
4220 </row>
|
|
4221 <row>
|
|
4222 <entry>m3jpeg32.dll</entry>
|
|
4223 <entry>Morgan Motion JPEG Codec (MJPG)</entry>
|
|
4224 <entry>1cd13fff5960aa2aae43790242c323b1</entry>
|
|
4225 <entry></entry>
|
|
4226 </row>
|
|
4227 <row>
|
|
4228 <entry>mpg4c32.dll</entry>
|
|
4229 <entry>Microsoft MPEG-4 v1/v2</entry>
|
|
4230 <entry>b5791ea23f33010d37ab8314681f1256</entry>
|
|
4231 <entry></entry>
|
|
4232 </row>
|
|
4233 <row>
|
|
4234 <entry>tsccvid.dll</entry>
|
|
4235 <entry>TechSmith Camtasia Screen Codec (TSCC)</entry>
|
|
4236 <entry>8230d8560c41d444f249802a2700d1d5</entry>
|
|
4237 <entry>shareware error on windows</entry>
|
|
4238 </row>
|
|
4239 <row>
|
|
4240 <entry>vp31vfw.dll</entry>
|
|
4241 <entry>On2 Open Source VP3 Codec (VP31)</entry>
|
|
4242 <entry>845f3590ea489e2e45e876ab107ee7d2</entry>
|
|
4243 <entry></entry>
|
|
4244 </row>
|
|
4245 <row>
|
|
4246 <entry>vp4vfw.dll</entry>
|
|
4247 <entry>On2 VP4 Personal Codec (VP40)</entry>
|
|
4248 <entry>fc5480a482ccc594c2898dcc4188b58f</entry>
|
|
4249 <entry></entry>
|
|
4250 </row>
|
|
4251 <row>
|
|
4252 <entry>vp6vfw.dll</entry>
|
|
4253 <entry>On2 VP6 Personal Codec (VP60)</entry>
|
|
4254 <entry>04d635a364243013898fd09484f913fb</entry>
|
|
4255 <entry></entry>
|
|
4256 </row>
|
|
4257 <row>
|
|
4258 <entry>vp7vfw.dll</entry>
|
|
4259 <entry>On2 VP7 Personal Codec (VP70)</entry>
|
|
4260 <entry>cb4cc3d4ea7c94a35f1d81c3d750bc8d</entry>
|
|
4261 <entry>wrong FourCC?</entry>
|
|
4262 </row>
|
|
4263 <row>
|
|
4264 <entry>ViVD2.dll</entry>
|
|
4265 <entry>SoftMedia ViVD V2 codec VfW (GXVE)</entry>
|
|
4266 <entry>a7b4bf5cac630bb9262c3f80d8a773a1</entry>
|
|
4267 <entry></entry>
|
|
4268 </row>
|
|
4269 <row>
|
|
4270 <entry>msulvc06.DLL</entry>
|
|
4271 <entry>MSU Lossless codec (MSUD)</entry>
|
|
4272 <entry>294bf9288f2f127bb86f00bfcc9ccdda</entry>
|
|
4273 <entry>
|
|
4274 Decodable by <application>Window Media Player</application>,
|
|
4275 not <application>MPlayer</application> (yet).
|
|
4276 </entry>
|
|
4277 </row>
|
|
4278 <row>
|
|
4279 <entry>camcodec.dll</entry>
|
|
4280 <entry>CamStudio lossless video codec (CSCD)</entry>
|
|
4281 <entry>0efe97ce08bb0e40162ab15ef3b45615</entry>
|
|
4282 <entry>sf.net/projects/camstudio</entry>
|
|
4283 </row>
|
|
4284 </tbody>
|
|
4285 </tgroup>
|
|
4286 </informaltable>
|
|
4287
|
|
4288 The first column contains the codec names that should be passed after the
|
|
4289 <literal>codec</literal> parameter,
|
|
4290 like: <option>-xvfwopts codec=divx.dll</option>
|
|
4291 The FourCC code used by each codec is given in the parentheses.
|
|
4292 </para>
|
|
4293
|
|
4294 <informalexample>
|
|
4295 <para>
|
|
4296 An example to convert an ISO DVD trailer to a VP6 flash video file
|
|
4297 using compdata bitrate settings:
|
|
4298 <screen>
|
|
4299 mencoder -dvd-device <replaceable>zeiram.iso</replaceable> dvd://7 -o <replaceable>trailer.flv</replaceable> \
|
|
4300 -ovc vfw -xvfwopts codec=vp6vfw.dll:compdata=onepass.mcf -oac mp3lame \
|
|
4301 -lameopts cbr:br=64 -af lavcresample=22050 -vf yadif,scale=320:240,flip \
|
|
4302 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
|
|
4303 </screen>
|
|
4304 </para>
|
|
4305 </informalexample>
|
|
4306 </sect2>
|
|
4307
|
|
4308 <sect2 id="menc-feat-video-for-windows-bitrate-settings">
|
|
4309 <title>Using vfw2menc to create a codec settings file.</title>
|
|
4310
|
|
4311 <para>
|
|
4312 To encode with the Video for Windows codecs, you will need to set bitrate
|
|
4313 and other options. This is known to work on x86 on both *NIX and Windows.
|
|
4314 </para>
|
|
4315 <para>
|
|
4316 First you must build the <application>vfw2menc</application> program.
|
|
4317 It is located in the <filename class="directory">TOOLS</filename> subdirectory
|
|
4318 of the MPlayer source tree.
|
|
4319 To build on Linux, this can be done using <application>Wine</application>:
|
|
4320 <screen>winegcc vfw2menc.c -o vfw2menc -lwinmm -lole32</screen>
|
|
4321
|
|
4322 To build on Windows in <application>MinGW</application> or
|
|
4323 <application>Cygwin</application> use:
|
|
4324 <screen>gcc vfw2menc.c -o vfw2menc.exe -lwinmm -lole32</screen>
|
|
4325
|
|
4326 To build on <application>MSVC</application> you will need getopt.
|
|
4327 Getopt can be found in the original <application>vfw2menc</application>
|
|
4328 archive available at:
|
|
4329 The <ulink url="http://oss.netfarm.it/mplayer-win32.php">MPlayer on win32</ulink> project.
|
|
4330 </para>
|
|
4331 <informalexample>
|
|
4332 <para>
|
|
4333 Below is an example with the VP6 codec.
|
|
4334 <screen>
|
|
4335 vfw2menc -f VP62 -d vp6vfw.dll -s firstpass.mcf
|
|
4336 </screen>
|
|
4337 This will open the VP6 codec dialog window.
|
|
4338 Repeat this step for the second pass
|
|
4339 and use <option>-s <replaceable>secondpass.mcf</replaceable></option>.
|
|
4340 </para>
|
|
4341 </informalexample>
|
|
4342 <para>
|
|
4343 Windows users can use
|
|
4344 <option>-xvfwopts codec=vp6vfw.dll:compdata=dialog</option> to have
|
|
4345 the codec dialog display before encoding starts.
|
|
4346 </para>
|
|
4347 </sect2>
|
|
4348 </sect1>
|
|
4349
|
|
4350
|
|
4351 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4352
|
|
4353
|
|
4354 <sect1 id="menc-feat-quicktime-7">
|
|
4355 <title>Using <application>MEncoder</application> to create
|
|
4356 <application>QuickTime</application>-compatible files</title>
|
|
4357
|
|
4358
|
|
4359 <sect2 id="menc-feat-quicktime-7-why-use-it">
|
|
4360 <title>Why would one want to produce <application>QuickTime</application>-compatible Files?</title>
|
|
4361
|
|
4362 <para>
|
|
4363 There are several reasons why producing
|
|
4364 <application>QuickTime</application>-compatible files can be desirable.
|
|
4365 </para>
|
|
4366 <itemizedlist>
|
|
4367 <listitem><para>
|
|
4368 You want any computer illiterate to be able to watch your encode on
|
|
4369 any major platform (Windows, Mac OS X, Unices …).
|
|
4370 </para></listitem>
|
|
4371 <listitem><para>
|
|
4372 <application>QuickTime</application> is able to take advantage of more
|
|
4373 hardware and software acceleration features of Mac OS X than
|
|
4374 platform-independent players like <application>MPlayer</application>
|
|
4375 or <application>VLC</application>.
|
|
4376 That means that your encodes have a chance to be played smoothly by older
|
|
4377 G4-powered machines.
|
|
4378 </para></listitem>
|
|
4379 <listitem><para>
|
|
4380 <application>QuickTime</application> 7 supports the next-generation codec H.264,
|
|
4381 which yields significantly better picture quality than previous codec
|
|
4382 generations (MPEG-2, MPEG-4 …).
|
|
4383 </para></listitem>
|
|
4384 </itemizedlist>
|
|
4385 </sect2>
|
|
4386
|
|
4387 <sect2 id="menc-feat-quicktime-7-constraints">
|
|
4388 <title><application>QuickTime</application> 7 limitations</title>
|
|
4389
|
|
4390 <para>
|
|
4391 <application>QuickTime</application> 7 supports H.264 video and AAC audio,
|
|
4392 but it does not support them muxed in the AVI container format.
|
|
4393 However, you can use <application>MEncoder</application> to encode
|
|
4394 the video and audio, and then use an external program such as
|
|
4395 <application>mp4creator</application> (part of the
|
|
4396 <ulink url="http://mpeg4ip.sourceforge.net/">MPEG4IP suite</ulink>)
|
|
4397 to remux the video and audio tracks into an MP4 container.
|
|
4398 </para>
|
|
4399
|
|
4400 <para>
|
|
4401 <application>QuickTime</application>'s support for H.264 is limited,
|
|
4402 so you will need to drop some advanced features.
|
|
4403 If you encode your video with features that
|
|
4404 <application>QuickTime</application> 7 does not support,
|
|
4405 <application>QuickTime</application>-based players will show you a pretty
|
|
4406 white screen instead of your expected video.
|
|
4407 </para>
|
|
4408
|
|
4409 <itemizedlist>
|
|
4410 <listitem><para>
|
|
4411 <emphasis role="bold">B-frames</emphasis>:
|
|
4412 <application>QuickTime</application> 7 supports a maximum of 1 B-frame, i.e.
|
|
4413 <option>-x264encopts bframes=1</option>. This means that
|
|
4414 <option>b_pyramid</option> and <option>weight_b</option> will have no
|
|
4415 effect, since they require <option>bframes</option> to be greater than 1.
|
|
4416 </para></listitem>
|
|
4417 <listitem><para>
|
|
4418 <emphasis role="bold">Macroblocks</emphasis>:
|
|
4419 <application>QuickTime</application> 7 does not support 8x8 DCT macroblocks.
|
|
4420 This option (<option>8x8dct</option>) is off by default, so just be sure
|
|
4421 not to explicitly enable it. This also means that the <option>i8x8</option>
|
|
4422 option will have no effect, since it requires <option>8x8dct</option>.
|
|
4423 </para></listitem>
|
|
4424 <listitem><para>
|
|
4425 <emphasis role="bold">Aspect ratio</emphasis>:
|
|
4426 <application>QuickTime</application> 7 does not support SAR (sample
|
|
4427 aspect ratio) information in MPEG-4 files; it assumes that SAR=1. Read
|
|
4428 <link linkend="menc-feat-quicktime-7-scale">the section on scaling</link>
|
|
4429 for a workaround.
|
|
4430 </para></listitem>
|
|
4431 </itemizedlist>
|
|
4432
|
|
4433 </sect2>
|
|
4434
|
|
4435 <sect2 id="menc-feat-quicktime-7-crop">
|
|
4436 <title>Cropping</title>
|
|
4437 <para>
|
|
4438 Suppose you want to rip your freshly bought copy of "The Chronicles of
|
|
4439 Narnia". Your DVD is region 1,
|
|
4440 which means it is NTSC. The example below would still apply to PAL,
|
|
4441 except you would omit <option>-ofps 24000/1001</option> and use slightly
|
|
4442 different <option>crop</option> and <option>scale</option> dimensions.
|
|
4443 </para>
|
|
4444
|
|
4445 <para>
|
|
4446 After running <option>mplayer dvd://1</option>, you follow the process
|
|
4447 detailed in the section <link linkend="menc-feat-telecine">How to deal
|
|
4448 with telecine and interlacing in NTSC DVDs</link> and discover that it is
|
|
4449 24000/1001 fps progressive video. This simplifies the process somewhat,
|
|
4450 since you do not need to use an inverse telecine filter such as
|
|
4451 <option>pullup</option> or a deinterlacing filter such as
|
|
4452 <option>yadif</option>.
|
|
4453 </para>
|
|
4454
|
|
4455 <para>
|
|
4456 Next, you need to crop out the black bars from the top and bottom of the
|
|
4457 video, as detailed in <link linkend="menc-feat-dvd-mpeg4-example-crop">this</link>
|
|
4458 previous section.
|
|
4459 </para>
|
|
4460
|
|
4461 </sect2>
|
|
4462
|
|
4463 <sect2 id="menc-feat-quicktime-7-scale">
|
|
4464 <title>Scaling</title>
|
|
4465
|
|
4466 <para>
|
|
4467 The next step is truly heartbreaking.
|
|
4468 <application>QuickTime</application> 7 does not support MPEG-4 videos
|
|
4469 with a sample aspect ratio other than 1, so you will need to upscale
|
|
4470 (which wastes a lot of disk space) or downscale (which loses some
|
|
4471 details of the source) the video to square pixels.
|
|
4472 Either way you do it, this is highly inefficient, but simply cannot
|
|
4473 be avoided if you want your video to be playable by
|
|
4474 <application>QuickTime</application> 7.
|
|
4475 <application>MEncoder</application> can apply the appropriate upscaling
|
|
4476 or downscaling by specifying respectively <option>-vf scale=-10:-1</option>
|
|
4477 or <option>-vf scale=-1:-10</option>.
|
|
4478 This will scale your video to the correct width for the cropped height,
|
|
4479 rounded to the closest multiple of 16 for optimal compression.
|
|
4480 Remember that if you are cropping, you should crop first, then scale:
|
|
4481
|
|
4482 <screen>-vf crop=720:352:0:62,scale=-10:-1</screen>
|
|
4483 </para>
|
|
4484
|
|
4485 </sect2>
|
|
4486
|
|
4487 <sect2 id="menc-feat-quicktime-7-avsync">
|
|
4488 <title>A/V sync</title>
|
|
4489
|
|
4490 <para>
|
|
4491 Because you will be remuxing into a different container, you should
|
|
4492 always use the <option>harddup</option> option to ensure that duplicated
|
|
4493 frames are actually duplicated in the video output. Without this option,
|
|
4494 <application>MEncoder</application> will simply put a marker in the video
|
|
4495 stream that a frame was duplicated, and rely on the client software to
|
|
4496 show the same frame twice. Unfortunately, this "soft duplication" does
|
|
4497 not survive remuxing, so the audio would slowly lose sync with the video.
|
|
4498 </para>
|
|
4499
|
|
4500 <para>
|
|
4501 The final filter chain looks like this:
|
|
4502 <screen>-vf crop=720:352:0:62,scale=-10:-1,harddup</screen>
|
|
4503 </para>
|
|
4504
|
|
4505 </sect2>
|
|
4506
|
|
4507 <sect2 id="menc-feat-quicktime-7-bitrate">
|
|
4508 <title>Bitrate</title>
|
|
4509
|
|
4510 <para>
|
|
4511 As always, the selection of bitrate is a matter of the technical properties
|
|
4512 of the source, as explained
|
|
4513 <link linkend="menc-feat-dvd-mpeg4-resolution-bitrate">here</link>, as
|
|
4514 well as a matter of taste.
|
|
4515 This movie has a fair bit of action and lots of detail, but H.264 video
|
|
4516 looks good at much lower bitrates than XviD or other MPEG-4 codecs.
|
|
4517 After much experimentation, the author of this guide chose to encode
|
|
4518 this movie at 900kbps, and thought that it looked very good.
|
|
4519 You may decrease bitrate if you need to save more space, or increase
|
|
4520 it if you need to improve quality.
|
|
4521 </para>
|
|
4522
|
|
4523 </sect2>
|
|
4524
|
|
4525 <sect2 id="menc-feat-quicktime-7-example">
|
|
4526 <title>Encoding example</title>
|
|
4527
|
|
4528 <para>
|
|
4529 You are now ready to encode the video. Since you care about
|
|
4530 quality, of course you will be doing a two-pass encode. To shave off
|
|
4531 some encoding time, you can specify the <option>turbo</option> option
|
|
4532 on the first pass; this reduces <option>subq</option> and
|
|
4533 <option>frameref</option> to 1. To save some disk space, you can
|
|
4534 use the <option>ss</option> option to strip off the first few seconds
|
|
4535 of the video. (I found that this particular movie has 32 seconds of
|
|
4536 credits and logos.) <option>bframes</option> can be 0 or 1.
|
|
4537 The other options are documented in <link
|
|
4538 linkend="menc-feat-x264-encoding-options-speedvquality">Encoding with
|
|
4539 the <systemitem class="library">x264</systemitem> codec</link> and
|
|
4540 the man page.
|
|
4541
|
|
4542 <screen>mencoder dvd://1 -o /dev/null -ss 32 -ovc x264 \
|
|
4543 -x264encopts pass=1:turbo:bitrate=900:bframes=1:\
|
|
4544 me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
|
|
4545 -vf crop=720:352:0:62,scale=-10:-1,harddup \
|
|
4546 -oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
|
|
4547 -ofps 24000/1001</screen>
|
|
4548
|
|
4549 If you have a multi-processor machine, don't miss the opportunity to
|
|
4550 dramatically speed-up encoding by enabling
|
|
4551 <link linkend="menc-feat-x264-encoding-options-speedvquality-threads">
|
|
4552 <systemitem class="library">x264</systemitem>'s multi-threading mode</link>
|
|
4553 by adding <option>threads=auto</option> to your <option>x264encopts</option>
|
|
4554 command-line.
|
|
4555 </para>
|
|
4556
|
|
4557 <para>
|
|
4558 The second pass is the same, except that you specify the output file
|
|
4559 and set <option>pass=2</option>.
|
|
4560
|
|
4561 <screen>mencoder dvd://1 <emphasis role="bold">-o narnia.avi</emphasis> -ss 32 -ovc x264 \
|
|
4562 -x264encopts <emphasis role="bold">pass=2</emphasis>:turbo:bitrate=900:frameref=5:bframes=1:\
|
|
4563 me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
|
|
4564 -vf crop=720:352:0:62,scale=-10:-1,harddup \
|
|
4565 -oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
|
|
4566 -ofps 24000/1001</screen>
|
|
4567 </para>
|
|
4568
|
|
4569 <para>
|
|
4570 The resulting AVI should play perfectly in
|
|
4571 <application>MPlayer</application>, but of course
|
|
4572 <application>QuickTime</application> can not play it because it does
|
|
4573 not support H.264 muxed in AVI.
|
|
4574 So the next step is to remux the video into an MP4 container.
|
|
4575 </para>
|
|
4576 </sect2>
|
|
4577
|
|
4578 <sect2 id="menc-feat-quicktime-7-remux">
|
|
4579 <title>Remuxing as MP4</title>
|
|
4580
|
|
4581 <para>
|
|
4582 There are several ways to remux AVI files to MP4. You can use
|
|
4583 <application>mp4creator</application>, which is part of the
|
|
4584 <ulink url="http://mpeg4ip.sourceforge.net/">MPEG4IP suite</ulink>.
|
|
4585 </para>
|
|
4586
|
|
4587 <para>
|
|
4588 First, demux the AVI into separate audio and video streams using
|
|
4589 <application>MPlayer</application>.
|
|
4590
|
|
4591 <screen>mplayer narnia.avi -dumpaudio -dumpfile narnia.aac
|
|
4592 mplayer narnia.avi -dumpvideo -dumpfile narnia.h264</screen>
|
|
4593
|
|
4594 The filenames are important; <application>mp4creator</application>
|
|
4595 requires that AAC audio streams be named <systemitem>.aac</systemitem>
|
|
4596 and H.264 video streams be named <systemitem>.h264</systemitem>.
|
|
4597 </para>
|
|
4598
|
|
4599 <para>
|
|
4600 Now use <application>mp4creator</application> to create a new
|
|
4601 MP4 file out of the audio and video streams.
|
|
4602
|
|
4603 <screen>mp4creator -create=narnia.aac narnia.mp4
|
|
4604 mp4creator -create=narnia.h264 -rate=23.976 narnia.mp4</screen>
|
|
4605
|
|
4606 Unlike the encoding step, you must specify the framerate as a
|
|
4607 decimal (such as 23.976), not a fraction (such as 24000/1001).
|
|
4608 </para>
|
|
4609
|
|
4610 <para>
|
|
4611 This <systemitem>narnia.mp4</systemitem> file should now be playable
|
|
4612 with any <application>QuickTime</application> 7 application, such as
|
|
4613 <application>QuickTime Player</application> or
|
|
4614 <application>iTunes</application>. If you are planning to view the
|
|
4615 video in a web browser with the <application>QuickTime</application>
|
|
4616 plugin, you should also hint the movie so that the
|
|
4617 <application>QuickTime</application> plugin can start playing it
|
|
4618 while it is still downloading. <application>mp4creator</application>
|
|
4619 can create these hint tracks:
|
|
4620
|
|
4621 <screen>mp4creator -hint=1 narnia.mp4
|
|
4622 mp4creator -hint=2 narnia.mp4
|
|
4623 mp4creator -optimize narnia.mp4</screen>
|
|
4624
|
|
4625 You can check the final result to ensure that the hint tracks were
|
|
4626 created successfully:
|
|
4627
|
|
4628 <screen>mp4creator -list narnia.mp4</screen>
|
|
4629
|
|
4630 You should see a list of tracks: 1 audio, 1 video, and 2 hint tracks.
|
|
4631
|
|
4632 <screen>Track Type Info
|
|
4633 1 audio MPEG-4 AAC LC, 8548.714 secs, 190 kbps, 48000 Hz
|
|
4634 2 video H264 Main@5.1, 8549.132 secs, 899 kbps, 848x352 @ 23.976001 fps
|
|
4635 3 hint Payload mpeg4-generic for track 1
|
|
4636 4 hint Payload H264 for track 2
|
|
4637 </screen>
|
|
4638 </para>
|
|
4639
|
|
4640 </sect2>
|
|
4641
|
|
4642 <sect2 id="menc-feat-quicktime-7-metadata">
|
|
4643 <title>Adding metadata tags</title>
|
|
4644
|
|
4645 <para>
|
|
4646 If you want to add tags to your video that show up in iTunes, you can use
|
|
4647 <ulink url="http://atomicparsley.sourceforge.net/">AtomicParsley</ulink>.
|
|
4648
|
|
4649 <screen>AtomicParsley narnia.mp4 --metaEnema --title "The Chronicles of Narnia" --year 2005 --stik Movie --freefree --overWrite</screen>
|
|
4650
|
|
4651 The <option>--metaEnema</option> option removes any existing metadata
|
|
4652 (<application>mp4creator</application> inserts its name in the
|
|
4653 "encoding tool" tag), and <option>--freefree</option> reclaims the
|
|
4654 space from the deleted metadata.
|
|
4655 The <option>--stik</option> option sets the type of video (such as Movie
|
|
4656 or TV Show), which iTunes uses to group related video files.
|
|
4657 The <option>--overWrite</option> option overwrites the original file;
|
|
4658 without it, <application>AtomicParsley</application> creates a new
|
|
4659 auto-named file in the same directory and leaves the original file
|
|
4660 untouched.
|
|
4661 </para>
|
|
4662
|
|
4663 </sect2>
|
|
4664
|
|
4665 </sect1>
|
|
4666
|
|
4667
|
|
4668 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
|
4669
|
|
4670
|
|
4671 <sect1 id="menc-feat-vcd-dvd">
|
|
4672 <title>Using <application>MEncoder</application>
|
|
4673 to create VCD/SVCD/DVD-compliant files</title>
|
|
4674
|
|
4675 <sect2 id="menc-feat-vcd-dvd-constraints">
|
|
4676 <title>Format Constraints</title>
|
|
4677
|
|
4678 <para>
|
|
4679 <application>MEncoder</application> is capable of creating VCD, SCVD
|
|
4680 and DVD format MPEG files using the
|
|
4681 <systemitem class="library">libavcodec</systemitem> library.
|
|
4682 These files can then be used in conjunction with
|
|
4683 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>
|
|
4684 or
|
|
4685 <ulink url="http://dvdauthor.sourceforge.net/">dvdauthor</ulink>
|
|
4686 to create discs that will play on a standard set-top player.
|
|
4687 </para>
|
|
4688
|
|
4689 <para>
|
|
4690 The DVD, SVCD, and VCD formats are subject to heavy constraints.
|
|
4691 Only a small selection of encoded picture sizes and aspect ratios are
|
|
4692 available.
|
|
4693 If your movie does not already meet these requirements, you may have
|
|
4694 to scale, crop or add black borders to the picture to make it
|
|
4695 compliant.
|
|
4696 </para>
|
|
4697
|
|
4698
|
|
4699 <sect3 id="menc-feat-vcd-dvd-constraints-resolution">
|
|
4700 <title>Format Constraints</title>
|
|
4701
|
|
4702 <informaltable frame="all">
|
|
4703 <tgroup cols="9">
|
|
4704 <thead>
|
|
4705 <row>
|
|
4706 <entry>Format</entry>
|
|
4707 <entry>Resolution</entry>
|
|
4708 <entry>V. Codec</entry>
|
|
4709 <entry>V. Bitrate</entry>
|
|
4710 <entry>Sample Rate</entry>
|
|
4711 <entry>A. Codec</entry>
|
|
4712 <entry>A. Bitrate</entry>
|
|
4713 <entry>FPS</entry>
|
|
4714 <entry>Aspect</entry>
|
|
4715 </row>
|
|
4716 </thead>
|
|
4717 <tbody>
|
|
4718 <row>
|
|
4719 <entry>NTSC DVD</entry>
|
|
4720 <entry>720x480, 704x480, 352x480, 352x240</entry>
|
|
4721 <entry>MPEG-2</entry>
|
|
4722 <entry>9800 kbps</entry>
|
|
4723 <entry>48000 Hz</entry>
|
|
4724 <entry>AC-3,PCM</entry>
|
|
4725 <entry>1536 kbps (max)</entry>
|
|
4726 <entry>30000/1001, 24000/1001</entry>
|
|
4727 <entry>4:3, 16:9 (only for 720x480)</entry>
|
|
4728 </row>
|
|
4729 <row>
|
|
4730 <entry>NTSC DVD</entry>
|
|
4731 <entry>352x240<footnote id='fn-rare-resolutions'><para>
|
|
4732 These resolutions are rarely used for DVDs because
|
|
4733 they are fairly low quality.</para></footnote></entry>
|
|
4734 <entry>MPEG-1</entry>
|
|
4735 <entry>1856 kbps</entry>
|
|
4736 <entry>48000 Hz</entry>
|
|
4737 <entry>AC-3,PCM</entry>
|
|
4738 <entry>1536 kbps (max)</entry>
|
|
4739 <entry>30000/1001, 24000/1001</entry>
|
|
4740 <entry>4:3, 16:9</entry>
|
|
4741 </row>
|
|
4742 <row>
|
|
4743 <entry>NTSC SVCD</entry>
|
|
4744 <entry>480x480</entry>
|
|
4745 <entry>MPEG-2</entry>
|
|
4746 <entry>2600 kbps</entry>
|
|
4747 <entry>44100 Hz</entry>
|
|
4748 <entry>MP2</entry>
|
|
4749 <entry>384 kbps (max)</entry>
|
|
4750 <entry>30000/1001</entry>
|
|
4751 <entry>4:3</entry>
|
|
4752 </row>
|
|
4753 <row>
|
|
4754 <entry>NTSC VCD</entry>
|
|
4755 <entry>352x240</entry>
|
|
4756 <entry>MPEG-1</entry>
|
|
4757 <entry>1150 kbps</entry>
|
|
4758 <entry>44100 Hz</entry>
|
|
4759 <entry>MP2</entry>
|
|
4760 <entry>224 kbps</entry>
|
|
4761 <entry>24000/1001, 30000/1001</entry>
|
|
4762 <entry>4:3</entry>
|
|
4763 </row>
|
|
4764 <row>
|
|
4765 <entry>PAL DVD</entry>
|
|
4766 <entry>720x576, 704x576, 352x576, 352x288</entry>
|
|
4767 <entry>MPEG-2</entry>
|
|
4768 <entry>9800 kbps</entry>
|
|
4769 <entry>48000 Hz</entry>
|
|
4770 <entry>MP2,AC-3,PCM</entry>
|
|
4771 <entry>1536 kbps (max)</entry>
|
|
4772 <entry>25</entry>
|
|
4773 <entry>4:3, 16:9 (only for 720x576)</entry>
|
|
4774 </row>
|
|
4775 <row>
|
|
4776 <entry>PAL DVD</entry>
|
|
4777 <entry>352x288<footnoteref linkend='fn-rare-resolutions'/></entry>
|
|
4778 <entry>MPEG-1</entry>
|
|
4779 <entry>1856 kbps</entry>
|
|
4780 <entry>48000 Hz</entry>
|
|
4781 <entry>MP2,AC-3,PCM</entry>
|
|
4782 <entry>1536 kbps (max)</entry>
|
|
4783 <entry>25</entry>
|
|
4784 <entry>4:3, 16:9</entry>
|
|
4785 </row>
|
|
4786 <row>
|
|
4787 <entry>PAL SVCD</entry>
|
|
4788 <entry>480x576</entry>
|
|
4789 <entry>MPEG-2</entry>
|
|
4790 <entry>2600 kbps</entry>
|
|
4791 <entry>44100 Hz</entry>
|
|
4792 <entry>MP2</entry>
|
|
4793 <entry>384 kbps (max)</entry>
|
|
4794 <entry>25</entry>
|
|
4795 <entry>4:3</entry>
|
|
4796 </row>
|
|
4797 <row>
|
|
4798 <entry>PAL VCD</entry>
|
|
4799 <entry>352x288</entry>
|
|
4800 <entry>MPEG-1</entry>
|
|
4801 <entry>1152 kbps</entry>
|
|
4802 <entry>44100 Hz</entry>
|
|
4803 <entry>MP2</entry>
|
|
4804 <entry>224 kbps</entry>
|
|
4805 <entry>25</entry>
|
|
4806 <entry>4:3</entry>
|
|
4807 </row>
|
|
4808 </tbody>
|
|
4809 </tgroup>
|
|
4810 </informaltable>
|
|
4811
|
|
4812 <para>
|
|
4813 If your movie has 2.35:1 aspect (most recent action movies), you will
|
|
4814 have to add black borders or crop the movie down to 16:9 to make a DVD or VCD.
|
|
4815 If you add black borders, try to align them at 16-pixel boundaries in
|
|
4816 order to minimize the impact on encoding performance.
|
|
4817 Thankfully DVD has sufficiently excessive bitrate that you do not have
|
|
4818 to worry too much about encoding efficiency, but SVCD and VCD are
|
|
4819 highly bitrate-starved and require effort to obtain acceptable quality.
|
|
4820 </para>
|
|
4821 </sect3>
|
|
4822
|
|
4823
|
|
4824 <sect3 id="menc-feat-vcd-dvd-constraints-gop">
|
|
4825 <title>GOP Size Constraints</title>
|
|
4826
|
|
4827 <para>
|
|
4828 DVD, VCD, and SVCD also constrain you to relatively low
|
|
4829 GOP (Group of Pictures) sizes.
|
|
4830 For 30 fps material the largest allowed GOP size is 18.
|
|
4831 For 25 or 24 fps, the maximum is 15.
|
|
4832 The GOP size is set using the <option>keyint</option> option.
|
|
4833 </para>
|
|
4834 </sect3>
|
|
4835
|
|
4836
|
|
4837 <sect3 id="menc-feat-vcd-dvd-constraints-bitrate">
|
|
4838 <title>Bitrate Constraints</title>
|
|
4839
|
|
4840 <para>
|
|
4841 VCD video is required to be CBR at 1152 kbps.
|
|
4842 This highly limiting constraint also comes along with an extremly low vbv
|
|
4843 buffer size of 327 kilobits.
|
|
4844 SVCD allows varying video bitrates up to 2500 kbps, and a somewhat less
|
|
4845 restrictive vbv buffer size of 917 kilobits is allowed.
|
|
4846 DVD video bitrates may range anywhere up to 9800 kbps (though typical
|
|
4847 bitrates are about half that), and the vbv buffer size is 1835 kilobits.
|
|
4848 </para>
|
|
4849 </sect3>
|
|
4850 </sect2>
|
|
4851
|
|
4852 <!-- ********** -->
|
|
4853
|
|
4854 <sect2 id="menc-feat-vcd-dvd-output">
|
|
4855 <title>Output Options</title>
|
|
4856
|
|
4857 <para>
|
|
4858 <application>MEncoder</application> has options to control the output
|
|
4859 format.
|
|
4860 Using these options we can instruct it to create the correct type of
|
|
4861 file.
|
|
4862 </para>
|
|
4863
|
|
4864 <para>
|
|
4865 The options for VCD and SVCD are called xvcd and xsvcd, because they
|
|
4866 are extended formats.
|
|
4867 They are not strictly compliant, mainly because the output does not
|
|
4868 contain scan offsets.
|
|
4869 If you need to generate an SVCD image, you should pass the output file to
|
|
4870 <ulink url="http://www.gnu.org/software/vcdimager/vcdimager.html">vcdimager</ulink>.
|
|
4871 </para>
|
|
4872
|
|
4873 <para>
|
|
4874 VCD:
|
|
4875 <screen>-of mpeg -mpegopts format=xvcd</screen>
|
|
4876 </para>
|
|
4877
|
|
4878 <para>
|
|
4879 SVCD:
|
|
4880 <screen>-of mpeg -mpegopts format=xsvcd</screen>
|
|
4881 </para>
|
|
4882
|
|
4883 <para>
|
|
4884 DVD (with timestamps on every frame, if possible):
|
|
4885 <screen>-of mpeg -mpegopts format=dvd:tsaf</screen>
|
|
4886 </para>
|
|
4887
|
|
4888 <para>
|
|
4889 DVD with NTSC Pullup:
|
|
4890 <screen>-of mpeg -mpegopts format=dvd:tsaf:telecine -ofps 24000/1001</screen>
|
|
4891 This allows 24000/1001 fps progressive content to be encoded at 30000/1001
|
|
4892 fps whilst maintaing DVD-compliance.
|
|
4893 </para>
|
|
4894
|
|
4895
|
|
4896 <sect3 id="menc-feat-vcd-dvd-output-aspect">
|
|
4897 <title>Aspect Ratio</title>
|
|
4898
|
|
4899 <para>
|
|
4900 The aspect argument of <option>-lavcopts</option> is used to encode
|
|
4901 the aspect ratio of the file.
|
|
4902 During playback the aspect ratio is used to restore the video to the
|
|
4903 correct size.
|
|
4904 </para>
|
|
4905
|
|
4906 <para>
|
|
4907 16:9 or "Widescreen"
|
|
4908 <screen>-lavcopts aspect=16/9</screen>
|
|
4909 </para>
|
|
4910
|
|
4911 <para>
|
|
4912 4:3 or "Fullscreen"
|
|
4913 <screen>-lavcopts aspect=4/3</screen>
|
|
4914 </para>
|
|
4915
|
|
4916 <para>
|
|
4917 2.35:1 or "Cinemascope" NTSC
|
|
4918 <screen>-vf scale=720:368,expand=720:480 -lavcopts aspect=16/9</screen>
|
|
4919 To calculate the correct scaling size, use the expanded NTSC width of
|
|
4920 854/2.35 = 368
|
|
4921 </para>
|
|
4922
|
|
4923 <para>
|
|
4924 2.35:1 or "Cinemascope" PAL
|
|
4925 <screen>-vf scale=720:432,expand=720:576 -lavcopts aspect=16/9</screen>
|
|
4926 To calculate the correct scaling size, use the expanded PAL width of
|
|
4927 1024/2.35 = 432
|
|
4928 </para>
|
|
4929 </sect3>
|
|
4930
|
|
4931
|
|
4932 <sect3 id="menc-feat-vcd-dvd-a-v-sync">
|
|
4933 <title>Maintaining A/V sync</title>
|
|
4934
|
|
4935 <para>
|
|
4936 In order to maintain audio/video synchronization throughout the encode,
|
|
4937 <application>MEncoder</application> has to drop or duplicate frames.
|
|
4938 This works rather well when muxing into an AVI file, but is almost
|
|
4939 guaranteed to fail to maintain A/V sync with other muxers such as MPEG.
|
|
4940 This is why it is necessary to append the
|
|
4941 <option>harddup</option> video filter at the end of the filter chain
|
|
4942 to avoid this kind of problem.
|
|
4943 You can find more technical information about <option>harddup</option>
|
|
4944 in the section
|
|
4945 <link linkend="menc-feat-dvd-mpeg4-muxing-filter-issues">Improving muxing and A/V sync reliability</link>
|
|
4946 or in the manual page.
|
|
4947 </para>
|
|
4948 </sect3>
|
|
4949
|
|
4950
|
|
4951 <sect3 id="menc-feat-vcd-dvd-output-srate">
|
|
4952 <title>Sample Rate Conversion</title>
|
|
4953
|
|
4954 <para>
|
|
4955 If the audio sample rate in the original file is not the same as
|
|
4956 required by the target format, sample rate conversion is required.
|
|
4957 This is achieved using the <option>-srate</option> option and
|
|
4958 the <option>-af lavcresample</option> audio filter together.
|
|
4959 </para>
|
|
4960
|
|
4961 <para>
|
|
4962 DVD:
|
|
4963 <screen>-srate 48000 -af lavcresample=48000</screen>
|
|
4964 </para>
|
|
4965
|
|
4966 <para>
|
|
4967 VCD and SVCD:
|
|
4968 <screen>-srate 44100 -af lavcresample=44100</screen>
|
|
4969 </para>
|
|
4970 </sect3>
|
|
4971 </sect2>
|
|
4972
|
|
4973 <!-- ********** -->
|
|
4974
|
|
4975 <sect2 id="menc-feat-vcd-dvd-lavc">
|
|
4976 <title>Using libavcodec for VCD/SVCD/DVD Encoding</title>
|
|
4977
|
|
4978 <sect3 id="menc-feat-vcd-dvd-lavc-intro">
|
|
4979 <title>Introduction</title>
|
|
4980
|
|
4981 <para>
|
|
4982 <systemitem class="library">libavcodec</systemitem> can be used to
|
|
4983 create VCD/SVCD/DVD compliant video by using the appropriate options.
|
|
4984 </para>
|
|
4985 </sect3>
|
|
4986
|
|
4987
|
|
4988 <sect3 id="menc-feat-vcd-dvd-lavc-options">
|
|
4989 <title>lavcopts</title>
|
|
4990
|
|
4991 <para>
|
|
4992 This is a list of fields in <option>-lavcopts</option> that you may
|
|
4993 be required to change in order to make a complaint movie for VCD, SVCD,
|
|
4994 or DVD:
|
|
4995 </para>
|
|
4996
|
|
4997 <itemizedlist>
|
|
4998 <listitem><para>
|
|
4999 <emphasis role="bold">acodec</emphasis>:
|
|
5000 <option>mp2</option> for VCD, SVCD, or PAL DVD;
|
|
5001 <option>ac3</option> is most commonly used for DVD.
|
|
5002 PCM audio may also be used for DVD, but this is mostly a big waste of
|
|
5003 space.
|
|
5004 Note that MP3 audio is not compliant for any of these formats, but
|
|
5005 players often have no problem playing it anyway.
|
|
5006 </para></listitem>
|
|
5007 <listitem><para>
|
|
5008 <emphasis role="bold">abitrate</emphasis>:
|
|
5009 224 for VCD; up to 384 for SVCD; up to 1536 for DVD, but commonly
|
|
5010 used values range from 192 kbps for stereo to 384 kbps for 5.1 channel
|
|
5011 sound.
|
|
5012 </para></listitem>
|
|
5013 <listitem><para>
|
|
5014 <emphasis role="bold">vcodec</emphasis>:
|
|
5015 <option>mpeg1video</option> for VCD;
|
|
5016 <option>mpeg2video</option> for SVCD;
|
|
5017 <option>mpeg2video</option> is usually used for DVD but you may also use
|
|
5018 <option>mpeg1video</option> for CIF resolutions.
|
|
5019 </para></listitem>
|
|
5020 <listitem><para>
|
|
5021 <emphasis role="bold">keyint</emphasis>:
|
|
5022 Used to set the GOP size.
|
|
5023 18 for 30fps material, or 15 for 25/24 fps material.
|
|
5024 Commercial producers seem to prefer keyframe intervals of 12.
|
|
5025 It is possible to make this much larger and still retain compatibility
|
|
5026 with most players.
|
|
5027 A <option>keyint</option> of 25 should never cause any problems.
|
|
5028 </para></listitem>
|
|
5029 <listitem><para>
|
|
5030 <emphasis role="bold">vrc_buf_size</emphasis>:
|
|
5031 327 for VCD, 917 for SVCD, and 1835 for DVD.
|
|
5032 </para></listitem>
|
|
5033 <listitem><para>
|
|
5034 <emphasis role="bold">vrc_minrate</emphasis>:
|
|
5035 1152, for VCD. May be left alone for SVCD and DVD.
|
|
5036 </para></listitem>
|
|
5037 <listitem><para>
|
|
5038 <emphasis role="bold">vrc_maxrate</emphasis>:
|
|
5039 1152 for VCD; 2500 for SVCD; 9800 for DVD.
|
|
5040 For SVCD and DVD, you might wish to use lower values depending on your
|
|
5041 own personal preferences and requirements.
|
|
5042 </para></listitem>
|
|
5043 <listitem><para>
|
|
5044 <emphasis role="bold">vbitrate</emphasis>:
|
|
5045 1152 for VCD;
|
|
5046 up to 2500 for SVCD;
|
|
5047 up to 9800 for DVD.
|
|
5048 For the latter two formats, vbitrate should be set based on personal
|
|
5049 preference.
|
|
5050 For instance, if you insist on fitting 20 or so hours on a DVD, you
|
|
5051 could use vbitrate=400.
|
|
5052 The resulting video quality would probably be quite bad.
|
|
5053 If you are trying to squeeze out the maximum possible quality on a DVD,
|
|
5054 use vbitrate=9800, but be warned that this could constrain you to less
|
|
5055 than an hour of video on a single-layer DVD.
|
|
5056 </para></listitem>
|
|
5057 <listitem><para>
|
|
5058 <emphasis role="bold">vstrict</emphasis>:
|
|
5059 <option>vstrict</option>=0 should be used to create DVDs.
|
|
5060 Without this option, <application>MEncoder</application> creates a
|
|
5061 stream that cannot be correctly decoded by some standalone DVD
|
|
5062 players.
|
|
5063 </para></listitem>
|
|
5064 </itemizedlist>
|
|
5065 </sect3>
|
|
5066
|
|
5067
|
|
5068 <sect3 id="menc-feat-vcd-dvd-lavc-examples">
|
|
5069 <title>Examples</title>
|
|
5070
|
|
5071 <para>
|
|
5072 This is a typical minimum set of <option>-lavcopts</option> for
|
|
5073 encoding video:
|
|
5074 </para>
|
|
5075 <para>
|
|
5076 VCD:
|
|
5077 <screen>
|
|
5078 -lavcopts vcodec=mpeg1video:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5079 vrc_maxrate=1152:vbitrate=1152:keyint=15:acodec=mp2
|
|
5080 </screen>
|
|
5081 </para>
|
|
5082
|
|
5083 <para>
|
|
5084 SVCD:
|
|
5085 <screen>
|
|
5086 -lavcopts vcodec=mpeg2video:vrc_buf_size=917:vrc_maxrate=2500:vbitrate=1800:\
|
|
5087 keyint=15:acodec=mp2
|
|
5088 </screen>
|
|
5089 </para>
|
|
5090
|
|
5091 <para>
|
|
5092 DVD:
|
|
5093 <screen>
|
|
5094 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5095 keyint=15:vstrict=0:acodec=ac3
|
|
5096 </screen>
|
|
5097 </para>
|
|
5098 </sect3>
|
|
5099
|
|
5100
|
|
5101 <sect3 id="menc-feat-vcd-dvd-lavc-advanced">
|
|
5102 <title>Advanced Options</title>
|
|
5103
|
|
5104 <para>
|
|
5105 For higher quality encoding, you may also wish to add quality-enhancing
|
|
5106 options to lavcopts, such as <option>trell</option>,
|
|
5107 <option>mbd=2</option>, and others.
|
|
5108 Note that <option>qpel</option> and <option>v4mv</option>, while often
|
|
5109 useful with MPEG-4, are not usable with MPEG-1 or MPEG-2.
|
|
5110 Also, if you are trying to make a very high quality DVD encode, it may
|
|
5111 be useful to add <option>dc=10</option> to lavcopts.
|
|
5112 Doing so may help reduce the appearance of blocks in flat-colored areas.
|
|
5113 Putting it all together, this is an example of a set of lavcopts for a
|
|
5114 higher quality DVD:
|
|
5115 </para>
|
|
5116
|
|
5117 <para>
|
|
5118 <screen>
|
|
5119 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:\
|
|
5120 keyint=15:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:\
|
|
5121 vqmin=1:lmin=1:dc=10:vstrict=0
|
|
5122 </screen>
|
|
5123 </para>
|
|
5124 </sect3>
|
|
5125 </sect2>
|
|
5126
|
|
5127 <!-- ********** -->
|
|
5128
|
|
5129 <sect2 id="menc-feat-vcd-dvd-audio">
|
|
5130 <title>Encoding Audio</title>
|
|
5131
|
|
5132 <para>
|
|
5133 VCD and SVCD support MPEG-1 layer II audio, using one of
|
|
5134 <systemitem class="library">toolame</systemitem>,
|
|
5135 <systemitem class="library">twolame</systemitem>,
|
|
5136 or <systemitem class="library">libavcodec</systemitem>'s MP2 encoder.
|
|
5137 The libavcodec MP2 is far from being as good as the other two libraries,
|
|
5138 however it should always be available to use.
|
|
5139 VCD only supports constant bitrate audio (CBR) whereas SVCD supports
|
|
5140 variable bitrate (VBR), too.
|
|
5141 Be careful when using VBR because some bad standalone players might not
|
|
5142 support it too well.
|
|
5143 </para>
|
|
5144
|
|
5145 <para>
|
|
5146 For DVD audio, <systemitem class="library">libavcodec</systemitem>'s
|
|
5147 AC-3 codec is used.
|
|
5148 </para>
|
|
5149
|
|
5150
|
|
5151 <sect3 id="menc-feat-vcd-dvd-audio-toolame">
|
|
5152 <title>toolame</title>
|
|
5153
|
|
5154 <para>
|
|
5155 For VCD and SVCD:
|
|
5156 <screen>-oac toolame -toolameopts br=224</screen>
|
|
5157 </para>
|
|
5158 </sect3>
|
|
5159
|
|
5160
|
|
5161 <sect3 id="menc-feat-vcd-dvd-audio-twolame">
|
|
5162 <title>twolame</title>
|
|
5163
|
|
5164 <para>
|
|
5165 For VCD and SVCD:
|
|
5166 <screen>-oac twolame -twolameopts br=224</screen>
|
|
5167 </para>
|
|
5168 </sect3>
|
|
5169
|
|
5170
|
|
5171 <sect3 id="menc-feat-vcd-dvd-audio-lavc">
|
|
5172 <title>libavcodec</title>
|
|
5173
|
|
5174 <para>
|
|
5175 For DVD with 2 channel sound:
|
|
5176 <screen>-oac lavc -lavcopts acodec=ac3:abitrate=192</screen>
|
|
5177 </para>
|
|
5178
|
|
5179 <para>
|
|
5180 For DVD with 5.1 channel sound:
|
|
5181 <screen>-channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=384</screen>
|
|
5182 </para>
|
|
5183
|
|
5184 <para>
|
|
5185 For VCD and SVCD:
|
|
5186 <screen>-oac lavc -lavcopts acodec=mp2:abitrate=224</screen>
|
|
5187 </para>
|
|
5188 </sect3>
|
|
5189 </sect2>
|
|
5190
|
|
5191 <!-- ********** -->
|
|
5192
|
|
5193 <sect2 id="menc-feat-vcd-dvd-all">
|
|
5194 <title>Putting it all Together</title>
|
|
5195
|
|
5196 <para>
|
|
5197 This section shows some complete commands for creating VCD/SVCD/DVD
|
|
5198 compliant videos.
|
|
5199 </para>
|
|
5200
|
|
5201
|
|
5202 <sect3 id="menc-feat-vcd-dvd-all-pal-dvd">
|
|
5203 <title>PAL DVD</title>
|
|
5204
|
|
5205 <para>
|
|
5206 <screen>
|
|
5207 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5208 -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 \
|
|
5209 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5210 keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 \
|
|
5211 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5212 </screen>
|
|
5213 </para>
|
|
5214 </sect3>
|
|
5215
|
|
5216
|
|
5217 <sect3 id="menc-feat-vcd-dvd-all-ntsc-dvd">
|
|
5218 <title>NTSC DVD</title>
|
|
5219
|
|
5220 <para>
|
|
5221 <screen>
|
|
5222 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5223 -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \
|
|
5224 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5225 keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 30000/1001 \
|
|
5226 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5227 </screen>
|
|
5228 </para>
|
|
5229 </sect3>
|
|
5230
|
|
5231
|
|
5232 <sect3 id="menc-feat-vcd-dvd-all-pal-ac3-copy">
|
|
5233 <title>PAL AVI Containing AC-3 Audio to DVD</title>
|
|
5234
|
|
5235 <para>
|
|
5236 If the source already has AC-3 audio, use -oac copy instead of re-encoding it.
|
|
5237 <screen>
|
|
5238 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \
|
|
5239 -vf scale=720:576,harddup -ofps 25 \
|
|
5240 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\
|
|
5241 keyint=15:vstrict=0:aspect=16/9 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5242 </screen>
|
|
5243 </para>
|
|
5244 </sect3>
|
|
5245
|
|
5246
|
|
5247 <sect3 id="menc-feat-vcd-dvd-all-ntsc-ac3-copy">
|
|
5248 <title>NTSC AVI Containing AC-3 Audio to DVD</title>
|
|
5249
|
|
5250 <para>
|
|
5251 If the source already has AC-3 audio, and is NTSC @ 24000/1001 fps:
|
|
5252 <screen>
|
|
5253 mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf:telecine \
|
|
5254 -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:\
|
|
5255 vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:aspect=16/9 -ofps 24000/1001 \
|
|
5256 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5257 </screen>
|
|
5258 </para>
|
|
5259 </sect3>
|
|
5260
|
|
5261
|
|
5262 <sect3 id="menc-feat-vcd-dvd-all-pal-svcd">
|
|
5263 <title>PAL SVCD</title>
|
|
5264
|
|
5265 <para>
|
|
5266 <screen>
|
|
5267 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
5268 scale=480:576,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5269 vcodec=mpeg2video:mbd=2:keyint=15:vrc_buf_size=917:vrc_minrate=600:\
|
|
5270 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 25 \
|
|
5271 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5272 </screen>
|
|
5273 </para>
|
|
5274 </sect3>
|
|
5275
|
|
5276
|
|
5277 <sect3 id="menc-feat-vcd-dvd-all-ntsc-svcd">
|
|
5278 <title>NTSC SVCD</title>
|
|
5279
|
|
5280 <para>
|
|
5281 <screen>
|
|
5282 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \
|
|
5283 scale=480:480,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5284 vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:\
|
|
5285 vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
5286 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5287 </screen>
|
|
5288 </para>
|
|
5289 </sect3>
|
|
5290
|
|
5291
|
|
5292 <sect3 id="menc-feat-vcd-dvd-all-pal-vcd">
|
|
5293 <title>PAL VCD</title>
|
|
5294
|
|
5295 <para>
|
|
5296 <screen>
|
|
5297 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
5298 scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5299 vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5300 vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
|
|
5301 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5302 </screen>
|
|
5303 </para>
|
|
5304 </sect3>
|
|
5305
|
|
5306
|
|
5307 <sect3 id="menc-feat-vcd-dvd-all-ntsc-vcd">
|
|
5308 <title>NTSC VCD</title>
|
|
5309
|
|
5310 <para>
|
|
5311 <screen>
|
|
5312 mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
|
|
5313 scale=352:240,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
|
|
5314 vcodec=mpeg1video:keyint=18:vrc_buf_size=327:vrc_minrate=1152:\
|
|
5315 vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 30000/1001 \
|
|
5316 -o <replaceable>movie.mpg</replaceable> <replaceable>movie.avi</replaceable>
|
|
5317 </screen>
|
|
5318 </para>
|
|
5319 </sect3>
|
|
5320 </sect2>
|
|
5321 </sect1>
|
|
5322 </chapter>
|