~ubuntu-branches/debian/squeeze/mplayer/squeeze

« back to all changes in this revision

Viewing changes to DOCS/HTML/en/menc-feat-quicktime-7.html

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2010-07-31 23:44:52 UTC
  • mfrom: (1.1.4 upstream) (8.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100731234452-j7yyrgsh1wustazr
Tags: 2:1.0~rc3++final.dfsg1-1
* upload to unstable
* enable mencoder and mplayer-gui package
* build again against the system FFmpeg 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>11.7. Using MEncoder to create QuickTime-compatible files</title><link rel="stylesheet" href="default.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="MPlayer - The Movie Player"><link rel="up" href="encoding-guide.html" title="Chapter 11. Encoding with MEncoder"><link rel="prev" href="menc-feat-video-for-windows.html" title="11.6.  Encoding with the Video For Windows codec family"><link rel="next" href="menc-feat-vcd-dvd.html" title="11.8. Using MEncoder to create VCD/SVCD/DVD-compliant files"><link rel="preface" href="howtoread.html" title="How to read this documentation"><link rel="chapter" href="intro.html" title="Chapter 1. Introduction"><link rel="chapter" href="install.html" title="Chapter 2. Installation"><link rel="chapter" href="usage.html" title="Chapter 3. Usage"><link rel="chapter" href="advaudio.html" title="Chapter 4. Advanced audio usage"><link rel="chapter" href="cd-dvd.html" title="Chapter 5. CD/DVD usage"><link rel="chapter" href="tv.html" title="Chapter 6. TV"><link rel="chapter" href="radio.html" title="Chapter 7. Radio"><link rel="chapter" href="video.html" title="Chapter 8. Video output devices"><link rel="chapter" href="ports.html" title="Chapter 9. Ports"><link rel="chapter" href="mencoder.html" title="Chapter 10. Basic usage of MEncoder"><link rel="chapter" href="encoding-guide.html" title="Chapter 11. Encoding with MEncoder"><link rel="chapter" href="faq.html" title="Chapter 12. Frequently Asked Questions"><link rel="appendix" href="bugreports.html" title="Appendix A. How to report bugs"><link rel="appendix" href="skin.html" title="Appendix B. MPlayer skin format"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-why-use-it" title="11.7.1. Why would one want to produce QuickTime-compatible Files?"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-constraints" title="11.7.2. QuickTime 7 limitations"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-crop" title="11.7.3. Cropping"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-scale" title="11.7.4. Scaling"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-avsync" title="11.7.5. A/V sync"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-bitrate" title="11.7.6. Bitrate"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-example" title="11.7.7. Encoding example"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-remux" title="11.7.8. Remuxing as MP4"><link rel="subsection" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-metadata" title="11.7.9. Adding metadata tags"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">11.7. Using <span class="application">MEncoder</span> to create
 
2
<span class="application">QuickTime</span>-compatible files</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="menc-feat-video-for-windows.html">Prev</a> </td><th width="60%" align="center">Chapter 11. Encoding with <span class="application">MEncoder</span></th><td width="20%" align="right"> <a accesskey="n" href="menc-feat-vcd-dvd.html">Next</a></td></tr></table><hr></div><div class="sect1" title="11.7. Using MEncoder to create QuickTime-compatible files"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="menc-feat-quicktime-7"></a>11.7. Using <span class="application">MEncoder</span> to create
 
3
<span class="application">QuickTime</span>-compatible files</h2></div></div></div><div class="sect2" title="11.7.1. Why would one want to produce QuickTime-compatible Files?"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-why-use-it"></a>11.7.1. Why would one want to produce <span class="application">QuickTime</span>-compatible Files?</h3></div></div></div><p>
 
4
  There are several reasons why producing
 
5
  <span class="application">QuickTime</span>-compatible files can be desirable.
 
6
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
 
7
  You want any computer illiterate to be able to watch your encode on
 
8
  any major platform (Windows, Mac OS X, Unices …).
 
9
</p></li><li class="listitem"><p>
 
10
  <span class="application">QuickTime</span> is able to take advantage of more
 
11
  hardware and software acceleration features of Mac OS X than
 
12
  platform-independent players like <span class="application">MPlayer</span>
 
13
  or <span class="application">VLC</span>.
 
14
  That means that your encodes have a chance to be played smoothly by older
 
15
  G4-powered machines.
 
16
</p></li><li class="listitem"><p>
 
17
  <span class="application">QuickTime</span> 7 supports the next-generation codec H.264,
 
18
  which yields significantly better picture quality than previous codec
 
19
  generations (MPEG-2, MPEG-4 …).
 
20
</p></li></ul></div></div><div class="sect2" title="11.7.2. QuickTime 7 limitations"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-constraints"></a>11.7.2. <span class="application">QuickTime</span> 7 limitations</h3></div></div></div><p>
 
21
  <span class="application">QuickTime</span> 7 supports H.264 video and AAC audio,
 
22
  but it does not support them muxed in the AVI container format.
 
23
  However, you can use <span class="application">MEncoder</span> to encode
 
24
  the video and audio, and then use an external program such as
 
25
  <span class="application">mp4creator</span> (part of the
 
26
  <a class="ulink" href="http://mpeg4ip.sourceforge.net/" target="_top">MPEG4IP suite</a>)
 
27
  to remux the video and audio tracks into an MP4 container.
 
28
</p><p>
 
29
  <span class="application">QuickTime</span>'s support for H.264 is limited,
 
30
  so you will need to drop some advanced features.
 
31
  If you encode your video with features that
 
32
  <span class="application">QuickTime</span> 7 does not support,
 
33
  <span class="application">QuickTime</span>-based players will show you a pretty
 
34
  white screen instead of your expected video.
 
35
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
 
36
  <span class="bold"><strong>B-frames</strong></span>:
 
37
  <span class="application">QuickTime</span> 7 supports a maximum of 1 B-frame, i.e.
 
38
  <tt class="option">-x264encopts bframes=1</tt>. This means that
 
39
  <tt class="option">b_pyramid</tt> and <tt class="option">weight_b</tt> will have no
 
40
  effect, since they require <tt class="option">bframes</tt> to be greater than 1.
 
41
</p></li><li class="listitem"><p>
 
42
  <span class="bold"><strong>Macroblocks</strong></span>:
 
43
  <span class="application">QuickTime</span> 7 does not support 8x8 DCT macroblocks.
 
44
  This option (<tt class="option">8x8dct</tt>) is off by default, so just be sure
 
45
  not to explicitly enable it. This also means that the <tt class="option">i8x8</tt>
 
46
  option will have no effect, since it requires <tt class="option">8x8dct</tt>.
 
47
</p></li><li class="listitem"><p>
 
48
  <span class="bold"><strong>Aspect ratio</strong></span>:
 
49
  <span class="application">QuickTime</span> 7 does not support SAR (sample
 
50
  aspect ratio) information in MPEG-4 files; it assumes that SAR=1. Read
 
51
  <a class="link" href="menc-feat-quicktime-7.html#menc-feat-quicktime-7-scale" title="11.7.4. Scaling">the section on scaling</a>
 
52
  for a workaround.
 
53
</p></li></ul></div></div><div class="sect2" title="11.7.3. Cropping"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-crop"></a>11.7.3. Cropping</h3></div></div></div><p>
 
54
  Suppose you want to rip your freshly bought copy of "The Chronicles of
 
55
  Narnia". Your DVD is region 1,
 
56
  which means it is NTSC. The example below would still apply to PAL,
 
57
  except you would omit <tt class="option">-ofps 24000/1001</tt> and use slightly
 
58
  different <tt class="option">crop</tt> and <tt class="option">scale</tt> dimensions.
 
59
</p><p>
 
60
  After running <tt class="option">mplayer dvd://1</tt>, you follow the process
 
61
  detailed in the section <a class="link" href="menc-feat-telecine.html" title="11.2. How to deal with telecine and interlacing within NTSC DVDs">How to deal
 
62
  with telecine and interlacing in NTSC DVDs</a> and discover that it is
 
63
  24000/1001 fps progressive video. This simplifies the process somewhat,
 
64
  since you do not need to use an inverse telecine filter such as
 
65
  <tt class="option">pullup</tt> or a deinterlacing filter such as
 
66
  <tt class="option">yadif</tt>.
 
67
</p><p>
 
68
  Next, you need to crop out the black bars from the top and bottom of the
 
69
  video, as detailed in <a class="link" href="menc-feat-enc-libavcodec.html#menc-feat-dvd-mpeg4-example-crop">this</a>
 
70
  previous section.
 
71
</p></div><div class="sect2" title="11.7.4. Scaling"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-scale"></a>11.7.4. Scaling</h3></div></div></div><p>
 
72
  The next step is truly heartbreaking.
 
73
  <span class="application">QuickTime</span> 7 does not support MPEG-4 videos
 
74
  with a sample aspect ratio other than 1, so you will need to upscale
 
75
  (which wastes a lot of disk space) or downscale (which loses some
 
76
  details of the source) the video to square pixels.
 
77
  Either way you do it, this is highly inefficient, but simply cannot
 
78
  be avoided if you want your video to be playable by
 
79
  <span class="application">QuickTime</span> 7.
 
80
  <span class="application">MEncoder</span> can apply the appropriate upscaling
 
81
  or downscaling by specifying respectively <tt class="option">-vf scale=-10:-1</tt>
 
82
  or <tt class="option">-vf scale=-1:-10</tt>.
 
83
  This will scale your video to the correct width for the cropped height,
 
84
  rounded to the closest multiple of 16 for optimal compression.
 
85
  Remember that if you are cropping, you should crop first, then scale:
 
86
 
 
87
  </p><pre class="screen">-vf crop=720:352:0:62,scale=-10:-1</pre><p>
 
88
</p></div><div class="sect2" title="11.7.5. A/V sync"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-avsync"></a>11.7.5. A/V sync</h3></div></div></div><p>
 
89
  Because you will be remuxing into a different container, you should
 
90
  always use the <tt class="option">harddup</tt> option to ensure that duplicated
 
91
  frames are actually duplicated in the video output. Without this option,
 
92
  <span class="application">MEncoder</span> will simply put a marker in the video
 
93
  stream that a frame was duplicated, and rely on the client software to
 
94
  show the same frame twice. Unfortunately, this "soft duplication" does
 
95
  not survive remuxing, so the audio would slowly lose sync with the video.
 
96
</p><p>
 
97
  The final filter chain looks like this:
 
98
  </p><pre class="screen">-vf crop=720:352:0:62,scale=-10:-1,harddup</pre><p>
 
99
</p></div><div class="sect2" title="11.7.6. Bitrate"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-bitrate"></a>11.7.6. Bitrate</h3></div></div></div><p>
 
100
  As always, the selection of bitrate is a matter of the technical properties
 
101
  of the source, as explained
 
102
  <a class="link" href="menc-feat-dvd-mpeg4.html#menc-feat-dvd-mpeg4-resolution-bitrate" title="11.1.5. Choosing resolution and bitrate">here</a>, as
 
103
  well as a matter of taste.
 
104
  This movie has a fair bit of action and lots of detail, but H.264 video
 
105
  looks good at much lower bitrates than XviD or other MPEG-4 codecs.
 
106
  After much experimentation, the author of this guide chose to encode
 
107
  this movie at 900kbps, and thought that it looked very good.
 
108
  You may decrease bitrate if you need to save more space, or increase
 
109
  it if you need to improve quality.
 
110
</p></div><div class="sect2" title="11.7.7. Encoding example"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-example"></a>11.7.7. Encoding example</h3></div></div></div><p>
 
111
  You are now ready to encode the video. Since you care about
 
112
  quality, of course you will be doing a two-pass encode. To shave off
 
113
  some encoding time, you can specify the <tt class="option">turbo</tt> option
 
114
  on the first pass; this reduces <tt class="option">subq</tt> and
 
115
  <tt class="option">frameref</tt> to 1. To save some disk space, you can
 
116
  use the <tt class="option">ss</tt> option to strip off the first few seconds
 
117
  of the video. (I found that this particular movie has 32 seconds of
 
118
  credits and logos.)  <tt class="option">bframes</tt> can be 0 or 1.
 
119
  The other options are documented in <a class="link" href="menc-feat-x264.html#menc-feat-x264-encoding-options-speedvquality" title="11.5.1.2. Options which primarily affect speed and quality">Encoding with
 
120
  the <code class="systemitem">x264</code> codec</a> and
 
121
  the man page.
 
122
 
 
123
  </p><pre class="screen">mencoder dvd://1 -o /dev/null -ss 32 -ovc x264 \
 
124
-x264encopts pass=1:turbo:bitrate=900:bframes=1:\
 
125
me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
 
126
-vf crop=720:352:0:62,scale=-10:-1,harddup \
 
127
-oac faac -faacopts br=192:mpeg=4:object=2 -channels 2 -srate 48000 \
 
128
-ofps 24000/1001</pre><p>
 
129
 
 
130
  If you have a multi-processor machine, don't miss the opportunity to
 
131
  dramatically speed-up encoding by enabling
 
132
  <a class="link" href="menc-feat-x264.html#menc-feat-x264-encoding-options-speedvquality-threads">
 
133
  <code class="systemitem">x264</code>'s multi-threading mode</a>
 
134
  by adding <tt class="option">threads=auto</tt> to your <tt class="option">x264encopts</tt>
 
135
  command-line.
 
136
</p><p>
 
137
  The second pass is the same, except that you specify the output file
 
138
  and set <tt class="option">pass=2</tt>.
 
139
 
 
140
  </p><pre class="screen">mencoder dvd://1 <span class="bold"><strong>-o narnia.avi</strong></span> -ss 32 -ovc x264 \
 
141
-x264encopts <span class="bold"><strong>pass=2</strong></span>:turbo:bitrate=900:frameref=5:bframes=1:\
 
142
me=umh:partitions=all:trellis=1:qp_step=4:qcomp=0.7:direct_pred=auto:keyint=300 \
 
143
-vf crop=720:352:0:62,scale=-10:-1,harddup \
 
144
-oac faac -faacopts br=192:mpeg=4:object=2 -channels 2 -srate 48000 \
 
145
-ofps 24000/1001</pre><p>
 
146
</p><p>
 
147
  The resulting AVI should play perfectly in
 
148
  <span class="application">MPlayer</span>, but of course
 
149
  <span class="application">QuickTime</span> can not play it because it does
 
150
  not support H.264 muxed in AVI.
 
151
  So the next step is to remux the video into an MP4 container.
 
152
</p></div><div class="sect2" title="11.7.8. Remuxing as MP4"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-remux"></a>11.7.8. Remuxing as MP4</h3></div></div></div><p>
 
153
  There are several ways to remux AVI files to MP4. You can use
 
154
  <span class="application">mp4creator</span>, which is part of the
 
155
  <a class="ulink" href="http://mpeg4ip.sourceforge.net/" target="_top">MPEG4IP suite</a>.
 
156
</p><p>
 
157
  First, demux the AVI into separate audio and video streams using
 
158
  <span class="application">MPlayer</span>.
 
159
 
 
160
  </p><pre class="screen">mplayer narnia.avi -dumpaudio -dumpfile narnia.aac
 
161
mplayer narnia.avi -dumpvideo -dumpfile narnia.h264</pre><p>
 
162
 
 
163
  The file names are important; <span class="application">mp4creator</span>
 
164
  requires that AAC audio streams be named <code class="systemitem">.aac</code>
 
165
  and H.264 video streams be named <code class="systemitem">.h264</code>.
 
166
</p><p>
 
167
  Now use <span class="application">mp4creator</span> to create a new
 
168
  MP4 file out of the audio and video streams.
 
169
 
 
170
  </p><pre class="screen">mp4creator -create=narnia.aac narnia.mp4
 
171
mp4creator -create=narnia.h264 -rate=23.976 narnia.mp4</pre><p>
 
172
 
 
173
  Unlike the encoding step, you must specify the framerate as a
 
174
  decimal (such as 23.976), not a fraction (such as 24000/1001).
 
175
</p><p>
 
176
  This <code class="systemitem">narnia.mp4</code> file should now be playable
 
177
  with any <span class="application">QuickTime</span> 7 application, such as
 
178
  <span class="application">QuickTime Player</span> or
 
179
  <span class="application">iTunes</span>. If you are planning to view the
 
180
  video in a web browser with the <span class="application">QuickTime</span>
 
181
  plugin, you should also hint the movie so that the
 
182
  <span class="application">QuickTime</span> plugin can start playing it
 
183
  while it is still downloading.  <span class="application">mp4creator</span>
 
184
  can create these hint tracks:
 
185
 
 
186
  </p><pre class="screen">mp4creator -hint=1 narnia.mp4
 
187
mp4creator -hint=2 narnia.mp4
 
188
mp4creator -optimize narnia.mp4</pre><p>
 
189
 
 
190
  You can check the final result to ensure that the hint tracks were
 
191
  created successfully:
 
192
 
 
193
  </p><pre class="screen">mp4creator -list narnia.mp4</pre><p>
 
194
 
 
195
  You should see a list of tracks: 1 audio, 1 video, and 2 hint tracks.
 
196
 
 
197
</p><pre class="screen">Track   Type    Info
 
198
1       audio   MPEG-4 AAC LC, 8548.714 secs, 190 kbps, 48000 Hz
 
199
2       video   H264 Main@5.1, 8549.132 secs, 899 kbps, 848x352 @ 23.976001 fps
 
200
3       hint    Payload mpeg4-generic for track 1
 
201
4       hint    Payload H264 for track 2
 
202
</pre><p>
 
203
</p></div><div class="sect2" title="11.7.9. Adding metadata tags"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-quicktime-7-metadata"></a>11.7.9. Adding metadata tags</h3></div></div></div><p>
 
204
  If you want to add tags to your video that show up in iTunes, you can use
 
205
  <a class="ulink" href="http://atomicparsley.sourceforge.net/" target="_top">AtomicParsley</a>.
 
206
 
 
207
  </p><pre class="screen">AtomicParsley narnia.mp4 --metaEnema --title "The Chronicles of Narnia" --year 2005 --stik Movie --freefree --overWrite</pre><p>
 
208
 
 
209
  The <tt class="option">--metaEnema</tt> option removes any existing metadata
 
210
  (<span class="application">mp4creator</span> inserts its name in the
 
211
  "encoding tool" tag), and <tt class="option">--freefree</tt> reclaims the
 
212
  space from the deleted metadata.
 
213
  The <tt class="option">--stik</tt> option sets the type of video (such as Movie
 
214
  or TV Show), which iTunes uses to group related video files.
 
215
  The <tt class="option">--overWrite</tt> option overwrites the original file;
 
216
  without it, <span class="application">AtomicParsley</span> creates a new
 
217
  auto-named file in the same directory and leaves the original file
 
218
  untouched.
 
219
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="menc-feat-video-for-windows.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="encoding-guide.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="menc-feat-vcd-dvd.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">11.6. 
 
220
  Encoding with the <code class="systemitem">Video For Windows</code>
 
221
  codec family
 
222
 </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 11.8. Using <span class="application">MEncoder</span>
 
223
  to create VCD/SVCD/DVD-compliant files</td></tr></table></div></body></html>