⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menc-feat-enc-libavcodec.html

📁 MPlayer-mingw32-1.0rc2.zip 经典播放器源码
💻 HTML
📖 第 1 页 / 共 2 页
字号:
With this feature of
<a class="link" href="video-codecs.html#ffmpeg" title="7.1.1.聽FFmpeg/libavcodec"><code class="systemitem">libavcodec</code></a>
you are able to set custom inter (I-frames/keyframes) and intra
(P-frames/predicted frames) matrices. It is supported by many of the codecs:
<code class="systemitem">mpeg1video</code> and <code class="systemitem">mpeg2video</code>
are reported as working.
</p><p>
A typical usage of this feature is to set the matrices preferred by the
<a class="ulink" href="http://www.kvcd.net/" target="_top">KVCD</a> specifications.
</p><p>
The <span class="bold"><strong>KVCD "Notch" Quantization Matrix:</strong></span>
</p><p>
Intra:
</p><pre class="screen">
 8  9 12 22 26 27 29 34
 9 10 14 26 27 29 34 37
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 29 34 37 38 40 48 58
29 34 37 38 40 48 58 69
34 37 38 40 48 58 69 79
</pre><p>

Inter:
</p><pre class="screen">
16 18 20 22 24 26 28 30
18 20 22 24 26 28 30 32
20 22 24 26 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 36 38 40
28 30 32 34 36 38 42 42
30 32 34 36 38 40 42 44
</pre><p>
</p><p>
Usage:
</p><pre class="screen">
mencoder <em class="replaceable"><code>input.avi</code></em> -o <em class="replaceable"><code>output.avi</code></em> -oac copy -ovc lavc \
    -lavcopts inter_matrix=...:intra_matrix=...
</pre><p>
</p><p>
</p><pre class="screen">
mencoder <em class="replaceable"><code>input.avi</code></em> -ovc lavc -lavcopts \
vcodec=mpeg2video:intra_matrix=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,\
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,\
29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79\
:inter_matrix=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,\
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,\
36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 -oac copy -o svcd.mpg
</pre><p>
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="menc-feat-dvd-mpeg4-example"></a>14.3.6.聽Example</h3></div></div></div><p>
So, you have just bought your shiny new copy of Harry Potter and the Chamber
of Secrets (widescreen edition, of course), and you want to rip this DVD
so that you can add it to your Home Theatre PC. This is a region 1 DVD,
so it is NTSC. The example below will still apply to PAL, except you will
omit <tt class="option">-ofps 24000/1001</tt> (because the output framerate is the
same as the input framerate), and of course the crop dimensions will be
different.
</p><p>
After running <tt class="option">mplayer dvd://1</tt>, we follow the process
detailed in the section <a class="link" href="menc-feat-telecine.html" title="14.2.聽How to deal with telecine and interlacing within NTSC DVDs">How to deal
with telecine and interlacing in NTSC DVDs</a> and discover that it is
24000/1001 fps progressive video, which means that we need not use an inverse
telecine filter, such as <tt class="option">pullup</tt> or
<tt class="option">filmdint</tt>.
</p><p><a name="menc-feat-dvd-mpeg4-example-crop"></a>
Next, we want to determine the appropriate crop rectangle, so we use the
cropdetect filter:
</p><pre class="screen">mplayer dvd://1 -vf cropdetect</pre><p>
Make sure you seek to a fully filled frame (such as a bright scene,
past the opening credits and logos), and
you will see in <span class="application">MPlayer</span>'s console output:
</p><pre class="screen">crop area: X: 0..719  Y: 57..419  (-vf crop=720:362:0:58)</pre><p>
We then play the movie back with this filter to test its correctness:
</p><pre class="screen">mplayer dvd://1 -vf crop=720:362:0:58</pre><p>
And we see that it looks perfectly fine. Next, we ensure the width and
height are a multiple of 16. The width is fine, however the height is
not. Since we did not fail 7th grade math, we know that the nearest
multiple of 16 lower than 362 is 352.
</p><p>
We could just use <tt class="option">crop=720:352:0:58</tt>, but it would be nice
to take a little off the top and a little off the bottom so that we
retain the center. We have shrunk the height by 10 pixels, but we do not
want to increase the y-offset by 5-pixels since that is an odd number and
will adversely affect quality. Instead, we will increase the y-offset by
4 pixels:
</p><pre class="screen">mplayer dvd://1 -vf crop=720:352:0:62</pre><p>
Another reason to shave pixels from both the top and the bottom is that we
ensure we have eliminated any half-black pixels if they exist. Note that if
your video is telecined, make sure the <tt class="option">pullup</tt> filter (or
whichever inverse telecine filter you decide to use) appears in the filter
chain before you crop. If it is interlaced, deinterlace before cropping.
(If you choose to preserve the interlaced video, then make sure your
vertical crop offset is a multiple of 4.)
</p><p>
If you are really concerned about losing those 10 pixels, you might
prefer instead to scale the dimensions down to the nearest multiple of 16.
The filter chain would look like:
</p><pre class="screen">-vf crop=720:362:0:58,scale=720:352</pre><p>
Scaling the video down like this will mean that some small amount of
detail is lost, though it probably will not be perceptible. Scaling up will
result in lower quality (unless you increase the bitrate). Cropping
discards those pixels altogether. It is a tradeoff that you will want to
consider for each circumstance. For example, if the DVD video was made
for television, you might want to avoid vertical scaling, since the line
sampling corresponds to the way the content was originally recorded.
</p><p>
On inspection, we see that our movie has a fair bit of action and high
amounts of detail, so we pick 2400Kbit for our bitrate.
</p><p>
We are now ready to do the two pass encode. Pass one:
</p><pre class="screen">
mencoder dvd://1 -ofps 24000/1001 -oac copy -o <em class="replaceable"><code>Harry_Potter_2.avi</code></em> -ovc lavc \
    -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=1 \
    -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
</pre><p>
And pass two is the same, except that we specify <tt class="option">vpass=2</tt>:
</p><pre class="screen">
mencoder dvd://1 -ofps 24000/1001 -oac copy -o <em class="replaceable"><code>Harry_Potter_2.avi</code></em> -ovc lavc \
    -lavcopts vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:autoaspect:vpass=2 \
    -vf pullup,softskip,crop=720:352:0:62,hqdn3d=2:1:2
</pre><p>
</p><p>
The options <tt class="option">v4mv:mbd=2:trell</tt> will greatly increase the
quality at the expense of encoding time. There is little reason to leave
these options out when the primary goal is quality. The options
<tt class="option">cmp=3:subcmp=3</tt> select a comparison function that
yields higher quality than the defaults. You might try experimenting with
this parameter (refer to the man page for the possible values) as
different functions can have a large impact on quality depending on the
source material. For example, if you find
<code class="systemitem">libavcodec</code> produces too much
blocky artifacting, you could try selecting the experimental NSSE as
comparison function via <tt class="option">*cmp=10</tt>.
</p><p>
For this movie, the resulting AVI will be 138 minutes long and nearly
3GB. And because you said that file size does not matter, this is a
perfectly acceptable size. However, if you had wanted it smaller, you
could try a lower bitrate. Increasing bitrates have diminishing
returns, so while we might clearly see an improvement from 1800Kbit to
2000Kbit, it might not be so noticeable above 2000Kbit. Feel
free to experiment until you are happy.
</p><p>
Because we passed the source video through a denoise filter, you may want
to add some of it back during playback. This, along with the
<tt class="option">spp</tt> post-processing filter, drastically improves the
perception of quality and helps eliminate blocky artifacts in the video.
With <span class="application">MPlayer</span>'s <tt class="option">autoq</tt> option,
you can vary the amount of post-processing done by the spp filter
depending on available CPU. Also, at this point, you may want to apply
gamma and/or color correction to best suit your display. For example:
</p><pre class="screen">
mplayer <em class="replaceable"><code>Harry_Potter_2.avi</code></em> -vf spp,noise=9ah:5ah,eq2=1.2 -autoq 3
</pre><p>
</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-telecine.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-xvid.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">14.2.聽How to deal with telecine and interlacing within NTSC DVDs聽</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">聽14.4.聽Encoding with the <code class="systemitem">Xvid</code>
  codec</td></tr></table></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -