[MPlayer-DOCS] Interested in contributing case studies

Guillaume Poirier gpoirier at mplayerhq.hu
Tue Oct 24 00:14:05 CEST 2006


Hi,


On Oct 23, 2006, at 7:35 , Mark Pilgrim wrote:

> On 10/21/06, Loren Merritt <lorenm at u.washington.edu> wrote:
>> "...does not support MPEG-4 videos with a sample aspect ratio  
>> other than 1."
>> Your statement meant instead that the whole video must be square.
>
> Fixed.  As you may have guessed from the first few drafts, I am
> relatively new to this field, and self-taught.  Which means I know how
> to fix the problem, but not necessarily how to explain it.

Same for me, welcome on board! ;-)


> Thanks for all the feedback.  Draft 3 is attached.




+  <emphasis role="bold">Aspect ratio</emphasis>:
+  <application>QuickTime</application> 7 does not support SAR (sample
+  aspect ratio) information in MPEG-4 files; it assumes that SAR=1.   
Read
+  <link linkend="menc-feat-quicktime-7-scale">the section on  
scaling</link>
+  for a workaround.
+</para></listitem>
+</itemizedlist>

I'm a bit surprised. I'm quite confident that Quicktime supports  
anamorphic videos in some way. If it doesn't support SAR, maybe it  
supports Pixel Aspect Ratio or Display Aspect Ration?

The doc here:
http://developer.apple.com/documentation/QuickTime/Conceptual/ 
QT7-1_Update_Guide/Content/2NewFeaturesChangesa.html

Seem to indicate that QT7.1 supports pixel aspect ratio (pasp)

Upscaling a video so make sure that it's correctly displayed should  
be avoided as much as possible IMHO because it wastes bits.

Please someone confirm if QT really needs this.


+<sect2 id="menc-feat-quicktime-7-crop">
+<title>Cropping</title>
+<para>
+  Suppose you want to rip your freshly bought copy of "The  
Chronicles of
+  Narnia" and add it to your local video collection, hosted on your  
local
+  web server running Gallery2.  Unfortunately, your wife is still  
using an
+  Apple PowerBook, so your rip will need to be
+  <application>QuickTime</application>-compatible.

IMHO, the doc should be a little bit more "impersonal"... well, at  
least, it's the way it we have tried to maintain it.

(plus, I don't see why a wife who has a powerbook is unfortunate. I'd  
prefer a Mac-use rather than a Windows-user wife if I was given the  
choice ;-P )

I'd be happier if this paragraph would read smth similar to this:

Suppose you want to rip your freshly bought copy of "The Chronicles of
Narnia" and add it to your local video collection, and want to be  
able to watch it natively on all major plateforms such as Unices,  
Windows, OSX, ...
Therefore, your rip should be <application>QuickTime</application>- 
compatible.


My English is terrible, so don't just copy and paste me ;-)



+<para>
+  Next, you need to crop out the black bars from the top and bottom  
of the
+  video, so you use the <option>cropdetect</option> filter:
+
+  <screen>mplayer dvd://1 -vf cropdetect</screen>
+
+  Make sure you seek to a fully filled frame (past the opening  
credits and
+  logos), and you will see the crop rectangle in
+  <application>MPlayer</application>'s console output:
+
+  <screen>crop area: X: 0..719  Y: 61..413  (-vf crop=720:352:0:62)</ 
screen>
+
+  Play the movie back with this filter to make sure it looks good:
+
+  <screen>mplayer dvd://1 -vf crop=720:352:0:62</screen>
+</para>


I'd be happier if you could replace this duplicated entry with a link  
to the relevant section of the existing doc.
That would mean less work for the translators.

Maybe the previous paragraph (the one about DVD region and telecine)  
too, though this doesn't seem so important to me right now.


+</sect2>
+
+<sect2 id="menc-feat-quicktime-7-scale">
+<title>Scaling</title>
+
+<para>
+  The next step is truly heartbreaking.
+  <application>QuickTime</application> 7 does not support MPEG-4 videos
+  with a sample aspect ratio other than 1, so you will need to scale
+  the video to square pixels.  This wastes a lot of disk space, but it
+  simply can not be avoided if you want your video to be playable by
+  <application>QuickTime</application> 7.
+  <application>MEncoder</application> can apply the appropriate scaling
+  by specifying <option>-vf scale=-10:-1</option>.  This will scale  
your
+  video to the correct width for the cropped height, rounded to a  
multiple
+  of 16 for optimal compression.  Remember that if you are cropping,  
you
+  should crop first, then scale:
+
+  <screen>-vf crop=720:352:0:62,scale=-10:-1</screen>
+</para>

Like I said, I'd really like if you could make _dead sure_ that QT  
doesn't support any kind of aspect ration information.

Apple ships high quality and well thought out software, so I'd be  
_really_ surprised if they had forget to implement such a basic  
feature (though I understand embedded players don't support custom  
aspect ratio for cpu consumption reasons).



+</sect2>
+
+<sect2 id="menc-feat-quicktime-7-avsync">
+<title>A/V sync</title>
+
+<para>
+  Because you will be remuxing into a different container, you should
+  always use the <option>harddup</option> option to ensure that  
duplicated
+  frames are actually duplicated in the video output.  Without this  
option,
+  <application>MEncoder</application> will simply put a marker in  
the video
+  stream that a frame was duplicated, and rely on the client  
software to
+  show the same frame twice.  Unfortunately, this "soft duplication"  
does
+  not survive remuxing, so the audio will slowly lose sync with the  
video.
+</para>

Please add a link the section "Improving muxing and A/V sync  
reliability" here too. Though you are slightly duplicating that  
existing entry, your working is quite clearer and less technical,  
which is quite good.


+<para>
+  The final filter chain looks like this:
+
+  <screen>-vf crop=720:352:0:62,scale=-10:-1,harddup</screen>
+</para>
+
+</sect2>
+
+<sect2 id="menc-feat-quicktime-7-bitrate">
+<title>Bitrate</title>
+
+<para>
+  As always, the selection of bitrate is a matter of taste.  This movie
+  has a fair bit of action and lots of detail, but H.264 video looks
+  good at much lower bitrates than XviD or other MPEG-4 codecs.  After
+  much experimentation, I chose to encode this movie at 900kbps.  Yes,
+  you read that correctly: 900kbps.  My wife thought the result looked
+  phenomenal on her PowerBook's screen.  Your wife may have different
+  standards; adjust your bitrate accordingly.

Please add a link to the different bitrate computation techniques  
that exist in existing doc; that way, the user will see that it's not  
just a made up figure.

Also, like I said, I don't quite like "too personal" style, so I'd  
prefer smth along the lines of:

  After much experimentation, and after computing bitrate with the  
techniques exposed <here/> in the doc you can try to encode this  
movie at 900kbps. This may seem quite low but experience show that  
for people who aren't after every details, it's yields a very decent  
picture quality.
Other people may have different standards; adjust your bitrate  
accordingly.


+<sect2 id="menc-feat-quicktime-7-example">
+<title>Encoding example</title>
+
+<para>
+  You are now ready to encode the video.  Since you care about
+  quality, of course you will be doing a two-pass encode.  To shave off
+  some encoding time, you can specify the <option>turbo</option> option
+  on the first pass; this reduces <option>subq</option> and
+  <option>frameref</option> to 1.  To save some disk space, you can
+  use the <option>ss</option> option to strip off the first few seconds
+  of the video.  (I found that this particular movie has 32 seconds of
+  credits and logos.)  <option>bframes</option> can be 0 or 1.
+  The other options are documented in <link
+  linkend="menc-feat-x264-encoding-options-speedvquality">Encoding with
+  the <systemitem class="library">x264</systemitem> codec</link> and
+  the man page.
+
+  <screen>mencoder dvd://1 -o /dev/null -ss 32 -ovc x264 \
+-x264encopts pass=1:turbo:bitrate=900:bframes=1:\
+me=umh:4x4mv:trellis=1:qp_step=4:qcomp=0.7:direct_pred=3:keyint=300 \
+-vf crop=720:352:0:62,scale=-10:-1,harddup \
+-oac faac -faacopts br=192:mpeg=4:object=1 -channels 2 -srate 48000 \
+-ofps 24000/1001</screen>
+
+  I have a dual-processor machine, so I usually add
+  <option>threads=2</option>.  This increases encoding speed by 20-30%,
+  but it can result in slightly larger files.

My own un-scientific experiments with x264's multi-threaded encoding  
allowed me to enjoy speed-ups larger than 30%, I didn't measure  
precisely, but I think it was quite close to 40% at fairly high  
quality encoding settings.



+<para>
+  This <systemitem>narnia.mp4</systemitem> file should now be playable
+  with any <application>QuickTime</application> 7 application, such as
+  <application>QuickTime Player</application> or
+  <application>iTunes</application>.  If you are planning to view the
+  video in a web browser with the <application>QuickTime</application>
+  plugin, you should also hint the movie so that the
+  <application>QuickTime</application> plugin can start playing it
+  while it is still downloading.

Our of curiosity, do you have an idea what there "hints" result in in  
the MP4 stream? Are they some sort of special indexes?

Do adding hints make the video file grow bigger?


Thanks a lot for the work, it's highly appreciated.

Guillaume



More information about the MPlayer-DOCS mailing list