annotate DOCS/tech/encoding-tips.txt @ 9012:805b19425c19

some URLs
author arpi
date Sun, 19 Jan 2003 01:24:56 +0000
parents e421b4ab7815
children 0fe056bdb135
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9012
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
1
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
2 Some important URLs:
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
3 ~~~~~~~~~~~~~~~~~~~~
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
4 http://www.mplayerhq.hu/~michael/codec-features.html <- lavc vs. divx5 vs. xvid
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
5 http://rguyom.chez.tiscali.fr/libavcodec_tests.html <- lavc benchmarks, options
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
6 http://cutka.szm.sk/ffdshow/index.html <- lavc for win32 :)
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
7 http://www.bunkus.org/dvdripping4linux/index.html <- a nice tutorial
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
8
805b19425c19 some URLs
arpi
parents: 8463
diff changeset
9 ================================================================================
8463
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
10
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
11 ENCODING QUALITY - OR WHY AUTOMATISM IS BAD.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
12
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
13 Hi everyone.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
14
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
15 Some days ago someone suggested adding some preset options to mencoder.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
16 At that time I replied 'don't do that', and now I decided to elaborate
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
17 on that.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
18
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
19 Warning: this is rather long, and it involves mathematics. But if you
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
20 don't want to bother with either then why are you encoding in the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
21 first place? Go do something different!
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
22
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
23 The good news is: it's all about the bpp (bits per pixel).
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
24
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
25 The bad news is: it's not THAT easy ;)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
26
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
27 This mail is about encoding a DVD to MPEG4. It's about the video
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
28 quality, not (primarily) about the audio quality or some other fancy
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
29 things like subtitles.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
30
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
31 The first step is to encode the audio. Why? Well if you encode the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
32 audio prior to the video you'll have to make the video fit onto one
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
33 (or two) CD(s). That way you can use oggenc's quality based encoding
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
34 mode which is much more sophisticated than its ABR based mode.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
35
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
36 After encoding the audio you have a certain amount of space left to
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
37 fill with video. Let's assume the audio takes 60M (no problem with
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
38 Vorbis), and you aim at a 700M CD. This leaves you 640M for the video.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
39 Let's further assume that the video is 100 minutes or 6000 seconds
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
40 long, encoded at 25fps (those nasty NTSC fps values give me
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
41 headaches. Adjust to your needs, of course!). This leaves you with
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
42 a video bitrate of:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
43
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
44 $videosize * 8
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
45 $videobitrate = --------------
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
46 $length * 1000
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
47
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
48 $videosize in bytes, $length in seconds, $videobitrate in kbit/s.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
49 In my example I end up with $videobitrate = 895.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
50
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
51 And now comes the question: how do I chose my encoding parameters
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
52 so that the results will be good? First let's take a look at a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
53 typical mencoder line:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
54
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
55 mencoder -dvd 1 -o /dev/null -oac copy -ovc lavc \
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
56 -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vqmin=2:\
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
57 vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:vpass=1 \
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
58 -vop scale=640:480,crop=716:572:2:2
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
59
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
60 Phew, all those parameters! Which ones should I change? NEVER leave
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
61 out 'vhq'. Never ever. 'vqmin=2' is always good if you aim for sane
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
62 settings - like 'normal length' movies on one CD, 'very long movies'
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
63 on two CDs and so on. vcodec=mpeg4 is mandatory.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
64
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
65 The 'vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01' are parameters
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
66 suggested by D Richard Felker for non-animated movies, and they
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
67 improve quality a bit.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
68
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
69 But the two things that have the most influence on quality are
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
70 vbitate and scale. Why? Because both together tell the codec how
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
71 many bits it may spend on each frame for each bit: and this is
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
72 the 'bpp' value (bits per pixel). It's simply defined as
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
73
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
74 $videobitrate * 1000
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
75 $bpp = -----------------------
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
76 $width * $height * $fps
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
77
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
78 I've attached a small Perl script that calculates the $bpp for
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
79 a movie. You'll have to give it four parameters:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
80 a) the cropped but unscaled resolution (use '-vop cropdetect'),
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
81 b) the encoded aspect ratio. All DVDs come at 720x576 but contain
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
82 a flag that tells the player wether it should display the DVD at
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
83 an aspect ratio of 4/3 (1.333) or at 16/9 (1.777). Have a look
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
84 at mplayer's output - there's something about 'prescaling'. That's
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
85 what you are looking for.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
86 c) the video bitrate in kbit/s and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
87 d) the fps.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
88
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
89 In my example the command line and calcbpp.pl's output would look
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
90 like this (warning - long lines ahead):
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
91
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
92 mosu@anakin:~$ ./calcbpp.pl 720x440 16/9 896 25
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
93 Prescaled picture: 1023x440, AR 2.33
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
94 720x304, diff 5, new AR 2.37, AR error 1.74% scale=720:304 bpp: 0.164
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
95 704x304, diff -1, new AR 2.32, AR error 0.50% scale=704:304 bpp: 0.167
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
96 688x288, diff 8, new AR 2.39, AR error 2.58% scale=688:288 bpp: 0.181
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
97 672x288, diff 1, new AR 2.33, AR error 0.26% scale=672:288 bpp: 0.185
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
98 656x288, diff -6, new AR 2.28, AR error 2.17% scale=656:288 bpp: 0.190
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
99 640x272, diff 3, new AR 2.35, AR error 1.09% scale=640:272 bpp: 0.206
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
100 624x272, diff -4, new AR 2.29, AR error 1.45% scale=624:272 bpp: 0.211
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
101 608x256, diff 5, new AR 2.38, AR error 2.01% scale=608:256 bpp: 0.230
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
102 592x256, diff -2, new AR 2.31, AR error 0.64% scale=592:256 bpp: 0.236
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
103 576x240, diff 8, new AR 2.40, AR error 3.03% scale=576:240 bpp: 0.259
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
104 560x240, diff 1, new AR 2.33, AR error 0.26% scale=560:240 bpp: 0.267
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
105 544x240, diff -6, new AR 2.27, AR error 2.67% scale=544:240 bpp: 0.275
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
106 528x224, diff 3, new AR 2.36, AR error 1.27% scale=528:224 bpp: 0.303
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
107 512x224, diff -4, new AR 2.29, AR error 1.82% scale=512:224 bpp: 0.312
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
108 496x208, diff 5, new AR 2.38, AR error 2.40% scale=496:208 bpp: 0.347
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
109 480x208, diff -2, new AR 2.31, AR error 0.85% scale=480:208 bpp: 0.359
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
110 464x192, diff 7, new AR 2.42, AR error 3.70% scale=464:192 bpp: 0.402
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
111 448x192, diff 1, new AR 2.33, AR error 0.26% scale=448:192 bpp: 0.417
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
112 432x192, diff -6, new AR 2.25, AR error 3.43% scale=432:192 bpp: 0.432
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
113 416x176, diff 3, new AR 2.36, AR error 1.54% scale=416:176 bpp: 0.490
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
114 400x176, diff -4, new AR 2.27, AR error 2.40% scale=400:176 bpp: 0.509
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
115 384x160, diff 5, new AR 2.40, AR error 3.03% scale=384:160 bpp: 0.583
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
116 368x160, diff -2, new AR 2.30, AR error 1.19% scale=368:160 bpp: 0.609
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
117 352x144, diff 7, new AR 2.44, AR error 4.79% scale=352:144 bpp: 0.707
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
118 336x144, diff 0, new AR 2.33, AR error 0.26% scale=336:144 bpp: 0.741
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
119 320x144, diff -6, new AR 2.22, AR error 4.73% scale=320:144 bpp: 0.778
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
120
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
121 A word for the $bpp. For a fictional movie which is only black and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
122 white: if you have a $bpp of 1 then the movie would be stored
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
123 uncompressed :) For a real life movie with 24bit color depth you
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
124 need compression of course. And the $bpp can be used to make the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
125 decision easier.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
126
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
127 As you can see the resolutions suggested by the script are all
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
128 dividable by 16. This will make the aspect ratio slightly wrong,
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
129 but no one will notice.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
130
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
131 Now if you want to decide which resolution (and scaling parameters)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
132 to chose you can do that by looking at the $bpp:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
133
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
134 < 0.10: don't do it. Please. I beg you!
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
135 < 0.15: It will look bad.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
136 < 0.20: You will notice blocks, but it will look ok.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
137 < 0.25: It will look really good.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
138 > 0.25: It won't really improve visually.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
139 > 0.30: Don't do that either - try a bigger resolution instead.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
140
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
141 Of course these values are not absolutes! For movies with really lots
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
142 of black areas 0.15 may look very good. Action movies with only high
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
143 motion scenes on the other hand may not look perfect at 0.25. But these
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
144 values give you a great idea about which resolution to chose.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
145
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
146 I see a lot of people always using 512 for the width and scaling
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
147 the height accordingly. For my (real-world-)example this would be
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
148 simply a waste of bandwidth. The encoder would probably not even
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
149 need the full bitrate, and the resulting file would be smaller
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
150 than my targetted 700M.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
151
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
152 After encoding you'll do your 'quality check'. First fire up the movie
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
153 and see whether it looks good to you or not. But you can also do a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
154 more 'scientific' analysis. The second Perl script I attached counts
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
155 the quantizers used for the encoding. Simply call it with
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
156
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
157 countquant.pl < divx2pass.log
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
158
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
159 It will print out which quantizer was used how often. If you see that
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
160 e.g. the lowest quantizer (vqmin=2) gets used for > 95% of the frames
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
161 then you can safely increase your picture size.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
162
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
163 > The "counting the quantesizer"-thing could improve the quality of
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
164 > full automated scripts, as I understand ?
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
165
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
166 Yes, the log file analysis can be used be tools to automatically adjust
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
167 the scaling parameters (if you'd do that you'd end up with a three-pass
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
168 encoding for the video only ;)), but it can also provide answers for
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
169 you as a human. From time to time there's a question like 'hey,
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
170 mencoder creates files that are too small! I specified this bitrate and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
171 the resulting file is 50megs short of the target file size!'. The
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
172 reason is probably that the codec already uses the minimum quantizer
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
173 for nearly all frames so it simply does not need more bits. A quick
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
174 glance at the distribution of the quantizers can be enlightening.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
175
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
176 Another thing is that q=2 and q=3 look really good while the 'bigger'
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
177 quantizers really lose quality. So if your distribution shows the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
178 majority of quantizers at 4 and above then you should probably decrease
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
179 the resolution (you'll definitly see block artefacts).
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
180
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
181
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
182 Well... Several people will probably disagree with me on certain
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
183 points here, especially when it comes down to hard values (like the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
184 $bpp categories and the percentage of the quantizers used). But
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
185 the idea is still valid.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
186
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
187 And that's why I think that there should NOT be presets in mencoder
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
188 like the presets lame knows. 'Good quality' or 'perfect quality' are
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
189 ALWAYS relative. They always depend on a person's personal preferences.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
190 If you want good quality then spend some time reading and - more
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
191 important - understanding what steps are involved in video encoding.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
192 You cannot do it without mathematics. Oh well, you can, but you'll
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
193 end up with movies that could certainly look better.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
194
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
195 Now please shoot me if you have any complaints ;)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
196
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
197 --
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
198 ==> Ciao, Mosu (Moritz Bunkus)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
199
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
200 ===========
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
201 ANOTHER APPROACH: BITS PER BLOCK:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
202
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
203 > $videobitrate * 1000
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
204 > $bpp = -----------------------
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
205 > $width * $height * $fps
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
206
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
207 Well, I came to similar equation going through different route. Only I
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
208 didn't use bits per pixel, in my case it was bits per block (BPB). The block
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
209 is 16x16 because lots of software depends on video width/height being
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
210 divisable by 16. And because I didn't like this 0.2 bit per pixel, when
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
211 bit is quite atomic ;)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
212
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
213 So the equation was something like:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
214
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
215 bitrate
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
216 bpb = -----------------
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
217 fps * ((width * height) / (16 * 16))
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
218
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
219 (width and height are from destination video size, and bitrate is in
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
220 bits (i.e. 900kbps is 900000))
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
221
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
222 This way it apeared that the minimum bits per block is ~40, very
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
223 good results are with ~50, and everything above 60 is a waste of bandwith.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
224 And what's actually funny is that it was independant of codec used. The
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
225 results were exactly the same, whether I used DIV3 (with tricky nandub's
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
226 magick), ffmpeg odivx, DivX5 on Windows or XviD.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
227
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
228 Surprisingly there is one advantage of using nandub-DIV3 for bitrate
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
229 starved encoding: ringing almost never apears this way.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
230
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
231 But I also found out, that the quality/BPB isn't constant for
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
232 drastically different resolutions. Smaller picture (like MPEG1 sizes)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
233 need more BPB to look good than say typical MPEG2 resolutions.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
234
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
235 Robert
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
236
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
237
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
238 ===========
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
239 DON'T SCALE DOWN TOO MUCH
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
240
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
241 Sometimes I found that encoding to y-scaled only DVD qualty (ie 704 x
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
242 288 for a 2.85 film) gives better visual quality than a scaled-down
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
243 version even if the quantizers are significantly higher than for the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
244 scaled-down version.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
245 Keep in mind that blocs, fuzzy parts and generaly mpeg artefacts in a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
246 704x288 image will be harder to spot in full-screen mode than on a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
247 512x208 image. In fact I've see example where the same movie looks
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
248 better compressed to 704x288 with an average weighted quantizer of
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
249 ~3 than the same movie scaled to 576x240 with an average weighted
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
250 quantizer of 2.4.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
251 Btw, a print of the weighted average quantizer would be nice in
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
252 countquant.pl :)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
253
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
254 Another point in favor of not trying to scale down too much : on hard
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
255 scaled-down movies, the MPEG codec will need to compress relatively
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
256 high frequencies rather than low frequencies and it doesn't like that
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
257 at all. You will see less and less returns while you scale down and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
258 scale down again in desesperate need of some bandwidth :)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
259
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
260 In my experience, don't try to go below a width of 576 without closely
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
261 watching what's going on.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
262
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
263 --
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
264 Rémi
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
265
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
266 ===========
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
267 TIPS FOR ENCODING
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
268
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
269 That being said, with video you have some tradeoffs you can make. Most
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
270 people seem to encode with really basic options, but if you play with
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
271 single coefficient elimination and luma masking settings, you can save lots
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
272 of bits, resulting in lower quantizers, which means less blockiness and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
273 less ugly noise (ringing) around sharp borders. The tradeoff, however, is
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
274 that you'll get some "muddiness" in some parts of the image. Play around
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
275 with the settings and see for yourself. The options I typically use for
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
276 (non-animated) movies are:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
277
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
278 vlelim=-4
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
279 vcelim=9
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
280 lumi_mask=0.05
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
281 dark_mask=0.01
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
282
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
283 If things look too muddy, making the numbers closer to 0. For anime and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
284 other animation, the above recommendations may not be so good.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
285
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
286 Another option that may be useful is allowing four motion vectors per
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
287 macroblock (v4mv). This will increase encoding time quite a bit, and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
288 last I checked it wasn't compatible with B frames. AFAIK, specifying
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
289 v4mv should never reduce quality, but it may prevent some old junky
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
290 versions of DivX from decoding it (can anyone conform?). Another issue
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
291 might be increased cpu time needed for decoding (again, can anyone
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
292 confirm?).
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
293
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
294 To get more fair distribution of bits between low-detail and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
295 high-detail scenes, you should probably try increasing vqcomp from the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
296 default (0.5) to something in the range 0.6-0.8.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
297
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
298 Of course you also want to make sure you crop ALL of the black border and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
299 any half-black pixels at the edge of the image, and make sure the final
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
300 image dimensions after cropping and scaling are multiples of 16. Failing to
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
301 do so will drastically reduce quality.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
302
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
303 Finally, if you can't seem to get good results, you can try scaling the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
304 movie down a bit smaller or applying a weak gaussian blur to reduce the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
305 amount of detail.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
306
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
307 Now, my personal success story! I just recently managed to fit a beautiful
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
308 encode of Kundun (well over 2 hours long, but not too many high-motion
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
309 scenes) on one cd at 640x304, with 66 kbit/sec abr ogg audio, using the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
310 options I described above. So, IMHO it's definitely possible to get very
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
311 good results with libavcodec (certainly MUCH better than all the idiot
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
312 "release groups" using DivX3 make), as long as you take some time to play
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
313 around with the options.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
314
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
315
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
316 Rich
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
317
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
318 ============
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
319 ABOUT VLELIM, VCELIM, LUMI_MASK AND DARK_MASK PART I: LUMA & CHROMA
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
320
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
321
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
322 The l/c in vlelim and vcelim stands for luma (brightness plane) and chroma
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
323 (color planes). These are encoded separately in all mpeg-like algorithms.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
324 Anyway, the idea behind these options is (at least from what I understand)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
325 to use some good heuristics to determine when the change in a block is less
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
326 than the threshold you specify, and in such a case, to just encode the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
327 block as "no change". This saves bits and perhaps speeds up encoding. Using
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
328 a negative value for either one means the same thing as the corresponding
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
329 positive value, but the DC coefficient is also considered. Unfortunately
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
330 I'm not familiar enough with the mpeg terminology to know what this means
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
331 (my first guess would be that it's the constant term from the DCT), but it
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
332 probably makes the encoder less likely to apply single coefficient
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
333 elimination in cases where it would look bad. It's presumably recommended
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
334 to use negative values for luma (which is more noticable) and positive for
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
335 chroma.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
336
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
337 The other options -- lumi_mask and dark_mask -- control how the quantizer
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
338 is adjusted for really dark or bright regions of the picture. You're
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
339 probably already at least a bit familiar with the concept of quantizers
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
340 (qscale, lower = more precision, higher quality, but more bits needed to
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
341 encode). What not everyone seems to know is that the quantizer you see
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
342 (e.g. in the 2pass logs) is just an average for the whole frame, and lower
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
343 or higher quantizers may in fact be used in parts of the picture with more
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
344 or less detail. Increasing the values of lumi_mask and dark_mask will cause
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
345 lavc to aggressively increase the quantizer in very dark or very bright
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
346 regions of the picture (which are presumably not as noticable to the human
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
347 eye) in order to save bits for use elsewhere.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
348
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
349 Rich
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
350
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
351 ===================
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
352 ABOUT VLELIM, VCELIM, LUMI_MASK AND DARK_MASK PART II: VQSCALE
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
353
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
354 OK, a quick explanation. The quantizer you set with vqscale=N is the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
355 per-frame quantizer parameter (aka qp). However, with mpeg4 it's
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
356 allowed (and recommended!) for the encoder to vary the quantizer on a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
357 per-macroblock (mb) basis (as I understand it, macroblocks are 16x16
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
358 regions composed of 4 8x8 luma blocks and 2 8x8 chroma blocks, u and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
359 v). To do this, lavc scores each mb with a complexity value and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
360 weights the quantizer accordingly. However, you can control this
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
361 behavior somewhat with scplx_mask, tcplx_mask, dark_mask, and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
362 lumi_mask.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
363
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
364 scplx_mask -- raise quantizer on mb's with lots of spacial complexity.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
365 Spacial complexity is measured by variance of the texture (this is
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
366 just the actual image for I blocks and the difference from the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
367 previous coded frame for P blocks).
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
368
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
369 tcplx_mask -- raise quantizer on mb's with lots of temporal
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
370 complexity. Temporal complexity is measured according to motion
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
371 vectors.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
372
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
373 dark_mask -- raise quantizer on very dark mb's.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
374
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
375 lumi_mask -- raise quantizer on very bright mb's.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
376 Somewhere around 0-0.15 is a safe range for these values, IMHO. You
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
377 might try as high as 0.25 or 0.3. You should probably never go over
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
378 0.5 or so.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
379
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
380 Now, about naq. When you adjust the quantizers on a per-mb basis like
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
381 this (called adaptive quantization), you might decrease or (more
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
382 likely) increase the average quantizer used, so that it no longer
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
383 matches the requested average quantizer (qp) for the frame. This will
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
384 result in weird things happening with the bitrate, at least from my
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
385 experience. What naq does is "normalize adaptive quantization". That
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
386 is, after the above masking parameters are applied on a per-mb basis,
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
387 the quantizers of all the blocks are rescaled so that the average
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
388 stays fixed at the desired qp.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
389
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
390 So, if I used vqscale=4 with naq and fairly large values for the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
391 masking parameters, I might be likely to see lots of frames using
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
392 qscale 2,3,4,5,6,7 across different macroblocks as needed, but with
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
393 the average sticking around 4. However, I haven't actually tested such
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
394 a setup yet, so it's just speculation right now.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
395
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
396 Have fun playing around with it.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
397
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
398 Rich
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
399
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
400 ======================
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
401 TIPS FOR ENCODING OLD BLACK & WHITE MOVIES:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
402
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
403 I found myself that 4:3 B&W old movies are very hard to compress well. In
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
404 addition to the 4:3 aspect ratio which eats lots of bits, those movies are
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
405 typically very "noisy", which doesn't help at all. Anyway :
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
406
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
407 > After a few tries I am
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
408 > still a little bit disappointed with the video quality. Since it is a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
409 > "dark" movies, there is a lot of black on the pictures, and on the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
410 > encoded avi I can see a lot of annoying "mpeg squares". I am using
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
411 > avifile codec, but the best I think is to give you the command line I
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
412 > used to encode a preview of the result:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
413
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
414 >
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
415 > First pass:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
416 > mencoder TITLE01-ANGLE1.VOB -oac copy -ovc lavc -lavcopts
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
417 > vcodec=mpeg4:vhq:vpass=1:vbitrate=800:keyint=48 -ofps 23.976 -npp lb
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
418 > -ss 2:00 -endpos 0:30 -vop scale -zoom -xy 640 -o movie.avi
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
419
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
420 1) keyint=48 is way too low. The default value is 250, this is in *frames*
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
421 not seconds. Key frames are significantly larger than P or B frames, so the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
422 less key frames you have, better the overall movie will be. (huh, like Yoda
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
423 I speak ;). Try keyint=300 or 350. Don't go beyond that if you want
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
424 relatively precise seeking.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
425
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
426 2) you may want to play with vlelim and vcelim options. This can gives you
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
427 a significant "quality" boost. Try one of these couples :
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
428
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
429 vlelim=-2:vcelim=3
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
430 vlelim=-3:vcelim=5
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
431 vlelim=-4:vcelim=7
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
432 (and yes, there's a minus)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
433
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
434 3) crop & rescale the movie before passing it to the codec. First crop the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
435 movie to not encode black bars if there's any. For a 1h40mn movie
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
436 compressed to a 700 MB file, I would try something between 512x384 and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
437 480x320. Don't go below that if you want something relatively sharp when
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
438 viewed fullscreen.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
439
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
440 4) I would recommend using the Ogg Vorbis audio codec with the .ogm
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
441 container format. Ogg Vorbis compress audio better than MP3. On a typical
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
442 old, mono-only audio stream, a 45 kbits/s Vorbis stream is ok. How to
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
443 extract & compress an audio stream from a ripped DVD (mplayer -dvd 1
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
444 -dumpstream) :
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
445
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
446 rm -f audiodump.pcm ; mkfifo -m 600 audiodump.pcm
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
447 mplayer -quiet -vc null -vo null -aid 128 -ao pcm -nowaveheader stream.dump &
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
448 oggenc --raw --raw-bits=16 --raw-chan=2 --raw-rate=48000 -q 1 -o audio-us.ogg
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
449 +audiodump.pcm &
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
450 wait
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
451
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
452 For a nice set of utilities to manager the .ogm format, see Moritz Bunkus'
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
453 ogmtools (google is your friend).
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
454
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
455 5) use the "v4mv" option. This could gives you a few more bits at the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
456 expense of a slightly longer encoding. This is a "lossless" option, I mean
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
457 with this option you don't throw away some video information, it just
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
458 selects a more precise motion estimation method. Be warned that on some
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
459 very un-typical scenes this option may gives you a longer file than
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
460 without, although it's very rare and on a whole film I think it's always a
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
461 win.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
462
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
463 6) you can try the new luminance & darkness masking code. Play
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
464 with the "lumi_mask" and "dark_mask" options. I would recommend using
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
465 something like :
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
466 lumi_mask=0.07:dark_mask=0.10:naq:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
467 lumi_mask=0.10:dark_mask=0.12:naq:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
468 lumi_mask=0.12:dark_mask=0.15:naq
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
469 lumi_mask=0.13:dark_mask=0.16:naq:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
470 Be warned that these options are really experimental and the result
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
471 could be very good or very bad depending on your visualization device
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
472 (computer CRT, TV or TFT screen). Don't push too hard these options.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
473
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
474 > Second pass:
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
475 > the same with vpass=2
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
476
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
477 7) I've found that lavc gives better results when the first pass is done
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
478 with "vqscale=2" instead of a target bitrate. The statistics collected
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
479 seems to be more precise. YMMV.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
480
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
481 > I am new to mencoder, so please tell me any idea you have even if it
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
482 > obvious. I also tried the "gray" option of lavc, to encode B&W only,
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
483 > but strangely it gives me "pink" squares from time to time.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
484
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
485 Yes, I've seen that too. Playing the resulting file with "-lavdopts gray"
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
486 fix the problem but it's not very nice ...
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
487
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
488 > So if you could tell me what option of mencoder or lavc I should be
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
489 > looking at to lower the number of "squares" on the image, it would be
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
490 > great. The version of mencoder i use is 0.90pre8 on a macos x PPC
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
491 > platform. I guess I would have the same problem by encoding anime
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
492 > movies, where there are a lot of region of the image with the same
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
493 > color. So if you managed to solve this problem...
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
494
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
495 You could also try the "mpeg_quant" flag. It selects a different set of
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
496 quantizers and produce somewhat sharper pictures and less blocks on large
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
497 zones with the same or similar luminance, at the expense of some bits.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
498
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
499 > This is completely off topic, but do you know how I can create good
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
500 > subtitles from vobsub subtitles ? I checked the -dumpmpsub option of
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
501 > mplayer, but is there a way to do it really fast (ie without having to
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
502 > play the whole movie) ?
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
503
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
504 I didn't find a way under *nix to produce reasonably good text subtitles
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
505 from vobsubs. OCR *nix softwares seems either not suited to the task, not
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
506 powerful enough or both. I'm extracting the vobsub subtitles and simply use
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
507 them with the .ogm
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
508
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
509 / .avi :
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
510 1) rip the DVD to harddisk with "mplayer -dvd 1 -dumpstream"
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
511 2) mount the DVD and copy the .ifo file
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
512 2) extract all vobsubs to one single file with something like :
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
513
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
514 for f in 0 1 2 3 4 5 6 7 8 9 10 11 ; do \
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
515 mencoder -ovc copy -oac copy -o /dev/null -sid $f -vobsubout sous-titres
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
516 +-vobsuboutindex $f -ifo vts_01_0.ifo stream.dump
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
517 done
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
518
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
519 (and yes, I've a DVD with 12 subtitles)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
520 --
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
521 Rémi
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
522
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
523 ================================
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
524
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
525 TIPS FOR SMOKE & CLOUDS
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
526
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
527 Q: I'm trying to encode Dante's Peak and I'm having problems with clouds,
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
528 fog and smoke: They don't look fine (they look very bad if I watch the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
529 movie in TVout). There are some artifacts, white clouds looks as snow
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
530 mountains, there are things likes hip in the colors so one can see frontier
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
531 curves between white and light gray and dark gray ... (I don't know if you
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
532 can understand me, I want to mean that the colors don't change smoothly)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
533 In particular I'm using vqscale=2:vhq:v4mv
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
534
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
535 A: Try adding "vqcomp=0.7:vqblur=0.2:mpeg_quant" to lavcopts.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
536
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
537 Q: I tried your suggestion and it improved the image a little ... but not
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
538 enough. I was playing with different options and I couldn't find the way.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
539 I suppose that the vob is not so good (watching it in TV trough the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
540 computer looks better than my encoding, but it isn't a lot of better).
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
541
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
542 A: Yes, those scenes with qscale=2 looks terrible :-(
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
543
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
544 Try with vqmin=1 in addition to mpeg_quant:vlelim=-4:vcelim=-7 (and maybe
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
545 with "-sws 10 -ssf ls=1" to sharpen a bit the image) and read about vqmin=1
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
546 in DOCS/tech/libavc-options.txt.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
547
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
548 If after the whole movie is encoded you still see the same problem, it will
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
549 means that the second pass didn't picked-up q=1 for this scene. Force q=1
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
550 with the "vrc_override" option.
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
551
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
552 Q: By the way, is there a special difficult in encode clouds or smoke?
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
553
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
554 A: I would say it depends on the sharpness of these clouds / smokes and the
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
555 fact that they are mostly black/white/grey or colored. The codec will do
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
556 the right thing with vqmin=2 for example on a cigarette smoke (sharp) or on
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
557 a red/yellow cloud (explosion, cloud of fire). But may not with a grey and
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
558 very fuzzy cloud like in the chocolat scene. Note that I don't know exactly
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
559 why ;)
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
560
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
561 A = Rémi
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
562
e421b4ab7815 encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff changeset
563