Mercurial > mplayer.hg
annotate DOCS/tech/encoding-tips.txt @ 29705:e426da101145
Add EXTERN_ASM define needed by FFmpeg on ARM.
author | reimar |
---|---|
date | Fri, 02 Oct 2009 08:58:29 +0000 |
parents | 0f1b5b68af32 |
children |
rev | line source |
---|---|
9012 | 1 |
2 Some important URLs: | |
3 ~~~~~~~~~~~~~~~~~~~~ | |
17679 | 4 http://mplayerhq.hu/~michael/codec-features.html <- lavc vs. divx5 vs. xvid |
16205 | 5 http://www.ee.oulu.fi/~tuukkat/mplayer/tests/rguyom.ath.cx/ <- lavc benchmarks, options |
6 http://ffdshow.sourceforge.net/tikiwiki/tiki-view_articles.php <- lavc for win32 :) | |
7 http://www.bunkus.org/dvdripping4linux/index.html <- a nice tutorial | |
8 http://forum.zhentarim.net/viewtopic.php?p=237 <- lavc option comparison | |
9 http://www.ee.oulu.fi/~tuukkat/mplayer/tests/readme.html <- series of benchmarks | |
16285
2de4d051dd21
The thread "Call for video encoding settings" has to be easily found until its infos make it to our docs
gpoirier
parents:
16205
diff
changeset
|
10 http://thread.gmane.org/gmane.comp.video.mencoder.user/1196 <- free codecs shoutout and recommended encoding settings |
9012 | 11 |
11423
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
12 |
9012 | 13 ================================================================================ |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
14 |
11423
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
15 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
16 FIXING A/V SYNC WHEN ENCODING |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
17 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
18 I know this is a popular topic on the list, so I thought I'd share a |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
19 few comments on my experience fixing a/v sync. As everyone seems to |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
20 know, mencoder unfortunately doesn't have a -delay option. But that |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
21 doesn't mean you can't fix a/v sync. There are a couple ways to still |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
22 do it. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
23 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
24 In example 1, we'll suppose you want to re-encode the audio anyway. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
25 This will be essential if your source audio isn't mp3, e.g. for DVD's |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
26 or nasty avi files with divx/wma audio. This approach makes things |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
27 much easier. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
28 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
29 Step 1: Dump the audio with mplayer -ao pcm -nowaveheader. There are |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
30 various options that can be used to speed this up, most notably -vo |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
31 null, -vc null, and/or -hardframedrop. -benchmark also seemed to help |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
32 in the past. :) |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
33 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
34 Step 2: Figure out what -delay value syncs the audio right in mplayer. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
35 If this number is positive, use a command like the following: |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
36 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
37 dd if=audiodump.wav bs=1764 skip=[delay] | lame -x - out.mp3 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
38 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
39 where [delay] is replaced by your delay amount in hundredths of a |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
40 second (1/10 the value you use with mplayer). Otherwise, if delay is |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
41 negative, use a command like this: |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
42 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
43 ( dd if=/dev/zero bs=1764 skip=[delay] ; cat audiodump.wav ) | lame -x - out.mp3 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
44 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
45 Don't include the minus (-) sign in delay. Also, keep in mind you'll |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
46 have to change the 1764 number and provide additional options to lame |
13047 | 47 if your audio stream isn't 44100/16bit/little-endian/stereo. |
11423
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
48 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
49 Step 3: Use mencoder to remux your new mp3 file with the movie: |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
50 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
51 mencoder -audiofile out.mp3 -oac copy ... |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
52 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
53 You can either copy video as-is (with -ovc copy) or re-encode it at |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
54 the same time you merge in the audio like this. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
55 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
56 Finally, as a variation on this method (makes things a good bit faster |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
57 and doesn't use tons of temporary disk space) you can merge steps 1 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
58 and 2 by making a named pipe called "audiodump.wav" (type mkfifo |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
59 audiodump.wav) and have mplayer write the audio to it at the same time |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
60 you're running lame to encode. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
61 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
62 Now for example 2. This time we won't re-encode audio at all. Just |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
63 dump the mp3 stream from the avi file with mplayer -dumpaudio. Then, |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
64 you have to cut and paste the raw mp3 stream a bit... |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
65 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
66 If delay is negative, things are easier. Just use lame to encode |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
67 silence for the duration of delay, at the same samplerate and |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
68 samplesize used in your avi file. Then, do something like: |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
69 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
70 cat silence.mp3 stream.dump > out.mp3 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
71 mencoder -audiofile out.mp3 -oac copy ... |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
72 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
73 On the other hand, if delay is positive, you'll need to crop off part |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
74 of the mp3 from the beginning. If it's (at least roughly) CBR this is |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
75 easy -- just take off the first (bitrate*delay/8) bytes of the file. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
76 You can use the excellent dd tool, or just your favorite |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
77 binary-friendly text editor to do this. Otherwise, you'll have to |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
78 experiment with cutting off different amounts. You can test with |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
79 mplayer -audiofile before actually spending time remuxing/encoding |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
80 with mencoder to make sure you cut the right amount. |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
81 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
82 I hope this has all been informative. If anyone would like to clean |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
83 this message up a bit and make it into part of the docs, feel free. Of |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
84 course mencoder should eventually just get -delay. :) |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
85 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
86 Rich |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
87 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
88 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
89 ================================================================================ |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
90 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
91 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
92 ENCODING QUALITY - OR WHY AUTOMATISM IS BAD. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
93 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
94 Hi everyone. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
95 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
96 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
|
97 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
|
98 on that. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
99 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
100 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
|
101 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
|
102 first place? Go do something different! |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
103 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
104 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
|
105 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
106 The bad news is: it's not THAT easy ;) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
107 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
108 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
|
109 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
|
110 things like subtitles. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
111 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
112 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
|
113 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
|
114 (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
|
115 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
|
116 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 a video bitrate of: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
124 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
125 $videosize * 8 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
126 $videobitrate = -------------- |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
127 $length * 1000 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
128 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
129 $videosize in bytes, $length in seconds, $videobitrate in kbit/s. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
130 In my example I end up with $videobitrate = 895. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
131 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
132 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
|
133 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
|
134 typical mencoder line: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
135 |
10405 | 136 mencoder dvd://1 -o /dev/null -oac copy -ovc lavc \ |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
137 -lavcopts vcodec=mpeg4:vbitrate=1000:vhq:vqmin=2:\ |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
138 vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:vpass=1 \ |
9644
0fe056bdb135
vop -> vf change, small fixes. The Polish documentation should be checked for correctness.
jonas
parents:
9012
diff
changeset
|
139 -vf crop=716:572:2:2,scale=640:480 |
8463
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 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
|
142 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
|
143 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
|
144 on two CDs and so on. vcodec=mpeg4 is mandatory. |
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 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
|
147 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
|
148 improve quality a bit. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
149 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
150 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
|
151 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
|
152 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
|
153 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
|
154 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
155 $videobitrate * 1000 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
156 $bpp = ----------------------- |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
157 $width * $height * $fps |
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 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
|
160 a movie. You'll have to give it four parameters: |
9644
0fe056bdb135
vop -> vf change, small fixes. The Polish documentation should be checked for correctness.
jonas
parents:
9012
diff
changeset
|
161 a) the cropped but unscaled resolution (use '-vf cropdetect'), |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 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
|
166 what you are looking for. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
167 c) the video bitrate in kbit/s and |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
168 d) the fps. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
169 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
170 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
|
171 like this (warning - long lines ahead): |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
172 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
173 mosu@anakin:~$ ./calcbpp.pl 720x440 16/9 896 25 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
174 Prescaled picture: 1023x440, AR 2.33 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 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
|
206 decision easier. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
207 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
208 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
|
209 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
|
210 but no one will notice. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
211 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
212 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
|
213 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
|
214 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
215 < 0.10: don't do it. Please. I beg you! |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
216 < 0.15: It will look bad. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
217 < 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
|
218 < 0.25: It will look really good. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
219 > 0.25: It won't really improve visually. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
220 > 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
|
221 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 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
|
226 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
227 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
|
228 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
|
229 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
|
230 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
|
231 than my targetted 700M. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
232 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
233 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
|
234 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
|
235 more 'scientific' analysis. The second Perl script I attached counts |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
236 the quantizers used for the encoding. Simply call it with |
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 countquant.pl < divx2pass.log |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
239 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
240 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
|
241 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
|
242 then you can safely increase your picture size. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
243 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
244 > The "counting the quantesizer"-thing could improve the quality of |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
245 > full automated scripts, as I understand ? |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
246 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 glance at the distribution of the quantizers can be enlightening. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
256 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
257 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
|
258 quantizers really lose quality. So if your distribution shows the |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
259 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
|
260 the resolution (you'll definitly see block artefacts). |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
261 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
262 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
263 Well... Several people will probably disagree with me on certain |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
264 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
|
265 $bpp categories and the percentage of the quantizers used). But |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
266 the idea is still valid. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
267 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 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
|
272 important - understanding what steps are involved in video encoding. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
273 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
|
274 end up with movies that could certainly look better. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
275 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
276 Now please shoot me if you have any complaints ;) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
277 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
278 -- |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
279 ==> Ciao, Mosu (Moritz Bunkus) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
280 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
281 =========== |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
282 ANOTHER APPROACH: BITS PER BLOCK: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
283 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
284 > $videobitrate * 1000 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
285 > $bpp = ----------------------- |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
286 > $width * $height * $fps |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
287 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 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
|
292 bit is quite atomic ;) |
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 So the equation was something like: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
295 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
296 bitrate |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
297 bpb = ----------------- |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
298 fps * ((width * height) / (16 * 16)) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
299 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
300 (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
|
301 bits (i.e. 900kbps is 900000)) |
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 This way it apeared that the minimum bits per block is ~40, very |
11271
252fb0cf331a
spelling fixes, mostly by <ismail.donmez@boun.edu.tr>
diego
parents:
10432
diff
changeset
|
304 good results are with ~50, and everything above 60 is a waste of bandwidth. |
22316
f3d7a1b58a82
cosmetics: Fix some common typos, appropiate --> appropRiate,
diego
parents:
17679
diff
changeset
|
305 And what's actually funny is that it was independent of codec used. The |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
306 results were exactly the same, whether I used DIV3 (with tricky nandub's |
26908
13061a6174b6
Change spelling of XviD to Xvid as has already been done in the (rest of the)
diego
parents:
26883
diff
changeset
|
307 magick), ffmpeg odivx, DivX5 on Windows or Xvid. |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
308 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
309 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
|
310 starved encoding: ringing almost never apears this way. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
311 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
312 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
|
313 drastically different resolutions. Smaller picture (like MPEG1 sizes) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
314 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
|
315 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
316 Robert |
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 =========== |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
320 DON'T SCALE DOWN TOO MUCH |
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 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
|
323 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
|
324 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
|
325 scaled-down version. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 better compressed to 704x288 with an average weighted quantizer of |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
330 ~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
|
331 quantizer of 2.4. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
332 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
|
333 countquant.pl :) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
334 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 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
|
339 scale down again in desesperate need of some bandwidth :) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
340 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
341 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
|
342 watching what's going on. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
343 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
344 -- |
23734 | 345 RĂ©mi |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
346 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
347 =========== |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
348 TIPS FOR ENCODING |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
349 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
350 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 (non-animated) movies are: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
358 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
359 vlelim=-4 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
360 vcelim=9 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
361 lumi_mask=0.05 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
362 dark_mask=0.01 |
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 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
|
365 other animation, the above recommendations may not be so good. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
366 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
367 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 confirm?). |
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 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
|
376 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
|
377 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
|
378 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 do so will drastically reduce quality. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
383 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
384 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
|
385 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
|
386 amount of detail. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
387 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 "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
|
394 around with the options. |
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 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
397 Rich |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
398 |
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 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
|
401 |
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 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
|
404 (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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 positive value, but the DC coefficient is also considered. Unfortunately |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
411 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
|
412 (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
|
413 probably makes the encoder less likely to apply single coefficient |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
414 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
|
415 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
|
416 chroma. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
417 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
418 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
|
419 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
|
420 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
|
421 (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
|
422 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
|
423 (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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 eye) in order to save bits for use elsewhere. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
429 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
430 Rich |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
431 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
432 =================== |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
433 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
|
434 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
435 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
|
436 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
|
437 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
|
438 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
|
439 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
|
440 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
|
441 weights the quantizer accordingly. However, you can control this |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
442 behavior somewhat with scplx_mask, tcplx_mask, dark_mask, and |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
443 lumi_mask. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
444 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
445 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
|
446 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
|
447 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
|
448 previous coded frame for P blocks). |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
449 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
450 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
|
451 complexity. Temporal complexity is measured according to motion |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
452 vectors. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
453 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
454 dark_mask -- raise quantizer on very dark mb's. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
455 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
456 lumi_mask -- raise quantizer on very bright mb's. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
457 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
|
458 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
|
459 0.5 or so. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
460 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
461 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
|
462 this (called adaptive quantization), you might decrease or (more |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
463 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
|
464 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
|
465 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
|
466 experience. What naq does is "normalize adaptive quantization". That |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
467 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
|
468 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
|
469 stays fixed at the desired qp. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
470 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
471 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
|
472 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
|
473 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
|
474 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
|
475 a setup yet, so it's just speculation right now. |
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 Have fun playing around with it. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
478 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
479 Rich |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
480 |
11423
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
481 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
482 ================================================================================ |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
483 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
484 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
485 TIPS FOR ENCODING OLD BLACK & WHITE MOVIES: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
486 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
487 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
|
488 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
|
489 typically very "noisy", which doesn't help at all. Anyway : |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
490 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
491 > After a few tries I am |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
492 > still a little bit disappointed with the video quality. Since it is a |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
493 > "dark" movies, there is a lot of black on the pictures, and on the |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
494 > encoded avi I can see a lot of annoying "mpeg squares". I am using |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
495 > avifile codec, but the best I think is to give you the command line I |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
496 > used to encode a preview of the result: |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
497 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
498 > |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
499 > First pass: |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
500 > mencoder TITLE01-ANGLE1.VOB -oac copy -ovc lavc -lavcopts |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
501 > vcodec=mpeg4:vhq:vpass=1:vbitrate=800:keyint=48 -ofps 23.976 -npp lb |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
502 > -ss 2:00 -endpos 0:30 -vf scale -zoom -xy 640 -o movie.avi |
8463
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 1) keyint=48 is way too low. The default value is 250, this is in *frames* |
13022 | 505 not seconds. Keyframes are significantly larger than P or B frames, so the |
506 less keyframes you have, better the overall movie will be. (huh, like Yoda | |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
507 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
|
508 relatively precise seeking. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
509 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
510 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
|
511 a significant "quality" boost. Try one of these couples : |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
512 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
513 vlelim=-2:vcelim=3 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
514 vlelim=-3:vcelim=5 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
515 vlelim=-4:vcelim=7 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
516 (and yes, there's a minus) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
517 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
518 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
|
519 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
|
520 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
|
521 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
|
522 viewed fullscreen. |
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 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
|
525 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
|
526 old, mono-only audio stream, a 45 kbits/s Vorbis stream is ok. How to |
10432 | 527 extract & compress an audio stream from a ripped DVD (mplayer dvd://1 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
528 -dumpstream) : |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
529 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
530 rm -f audiodump.pcm ; mkfifo -m 600 audiodump.pcm |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
531 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
|
532 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
|
533 +audiodump.pcm & |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
534 wait |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
535 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
536 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
|
537 ogmtools (google is your friend). |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
538 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
539 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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 win. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
546 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
547 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
|
548 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
|
549 something like : |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
550 lumi_mask=0.07:dark_mask=0.10:naq: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
551 lumi_mask=0.10:dark_mask=0.12:naq: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
552 lumi_mask=0.12:dark_mask=0.15:naq |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
553 lumi_mask=0.13:dark_mask=0.16:naq: |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
554 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
|
555 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
|
556 (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
|
557 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
558 > Second pass: |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
559 > the same with vpass=2 |
8463
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 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
|
562 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
|
563 seems to be more precise. YMMV. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
564 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
565 > I am new to mencoder, so please tell me any idea you have even if it |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
566 > obvious. I also tried the "gray" option of lavc, to encode B&W only, |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
567 > but strangely it gives me "pink" squares from time to time. |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
568 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
569 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
|
570 fix the problem but it's not very nice ... |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
571 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
572 > So if you could tell me what option of mencoder or lavc I should be |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
573 > looking at to lower the number of "squares" on the image, it would be |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
574 > great. The version of mencoder i use is 0.90pre8 on a macos x PPC |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
575 > platform. I guess I would have the same problem by encoding anime |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
576 > movies, where there are a lot of region of the image with the same |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
577 > color. So if you managed to solve this problem... |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
578 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
579 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
|
580 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
|
581 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
|
582 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
583 > This is completely off topic, but do you know how I can create good |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
584 > subtitles from vobsub subtitles ? I checked the -dumpmpsub option of |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
585 > mplayer, but is there a way to do it really fast (ie without having to |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
586 > play the whole movie) ? |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
587 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
588 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
|
589 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
|
590 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
|
591 them with the .ogm |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
592 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
593 / .avi : |
10405 | 594 1) rip the DVD to harddisk with "mplayer dvd://1 -dumpstream" |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
595 2) mount the DVD and copy the .ifo file |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
596 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
|
597 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
598 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
|
599 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
|
600 +-vobsuboutindex $f -ifo vts_01_0.ifo stream.dump |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
601 done |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
602 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
603 (and yes, I've a DVD with 12 subtitles) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
604 -- |
23734 | 605 RĂ©mi |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
606 |
11423
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
607 |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
608 ================================================================================ |
dffc970f1922
FIXING A/V SYNC WHEN ENCODING, from an old mail by Rich:
diego
parents:
11271
diff
changeset
|
609 |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
610 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
611 TIPS FOR SMOKE & CLOUDS |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
612 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
613 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
|
614 fog and smoke: They don't look fine (they look very bad if I watch the |
25744 | 615 movie in TV-out). There are some artifacts, white clouds looks as snow |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 In particular I'm using vqscale=2:vhq:v4mv |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
620 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
621 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
|
622 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
623 Q: I tried your suggestion and it improved the image a little ... but not |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
624 enough. I was playing with different options and I couldn't find the way. |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
625 I suppose that the vob is not so good (watching it in TV trough the |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
626 computer looks better than my encoding, but it isn't a lot of better). |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
627 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
628 A: Yes, those scenes with qscale=2 looks terrible :-( |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
629 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
630 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
|
631 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
|
632 in DOCS/tech/libavc-options.txt. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
633 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
634 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
|
635 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
|
636 with the "vrc_override" option. |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
637 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
638 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
|
639 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 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
|
644 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
|
645 why ;) |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
646 |
23734 | 647 A = RĂ©mi |
8463
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
648 |
e421b4ab7815
encoding tips - collected from mplayer-users list mailings by
arpi
parents:
diff
changeset
|
649 |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
650 ================================================================================ |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
651 |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
652 |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
653 TIPS FOR TWEAKING RATECONTROL |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
654 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
655 (For the purpose of this explanation, consider "2nd pass" to be any beyond |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
656 the 1st. The algorithm is run only on P-frames; I- and B-frames use QPs |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
657 based on the adjacent P. While x264's 2pass ratecontrol is based on lavc's, |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
658 it has diverged somewhat and not all of this is valid for x264.) |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
659 |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
660 Consider the default ratecontrol equation in lavc: "tex^qComp". |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
661 At the beginning of the 2nd pass, rc_eq is evaluated for each frame, and |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
662 the result is the number of bits allocated to that frame (multiplied by |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
663 some constant as needed to match the total requested bitrate). |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
664 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
665 "tex" is the complexity of a frame, i.e. the estimated number of bits it |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
666 would take to encode at a given quantizer. (If the 1st pass was CQP and |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
667 not turbo, then we know tex exactly. Otherwise it is calculated by |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
668 multiplying the 1st pass's bits by the QP of that frame. But that's not |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
669 why CQP is potentially good; more on that later.) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
670 "qComp" is just a constant. It has no effect outside the rc_eq, and is |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
671 directly set by the vqcomp parameter. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
672 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
673 If vqcomp=1, then rc_eq=tex^1=tex, so 2pass allocates to each frame the |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
674 number of bits needed to encode them all at the same QP. |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
675 If vqcomp=0, then rc_eq=tex^0=1, so 2pass allocates the same number of |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
676 bits to each frame, i.e. CBR. (Actually, this is worse than 1pass CBR in |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
677 terms of quality; CBR can vary within its allowed buffer size, while |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
678 vqcomp=0 tries to make each frame exactly the same size.) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
679 If vqcomp=0.5, then rc_eq=sqrt(tex), so the allocation is somewhere |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
680 between CBR and CQP. High complexity frames get somewhat lower quality |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
681 than low complexity, but still more bits. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
682 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
683 While the actual selection of a good value of vqcomp is experimental, the |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
684 following underlying factors determine the result: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
685 Arguing towards CQP: You want the movie to be somewhere approaching |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
686 constant quality; oscillating quality is even more annoying than constant |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
687 low quality. (However, constant quality does not mean constant PSNR nor |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
688 constant QP. Details are less noticeable in high-motion scenes, so you can |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
689 get away with somewhat higher QP in high-complexity frames for the same |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
690 perceived quality.) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
691 Arguing towards CBR: You get more quality per bit if you spend those bits |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
692 in frames where motion compensation works well (which tends to be |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
693 correlated with "tex"): A given artifact may stick around several seconds |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26908
diff
changeset
|
694 in a low-motion scene, and you only have to fix it in one frame to improve |
15015
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
695 the quality of the whole sequence. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
696 |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
697 Now for why the 1st pass ratecontrol method matters: |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
698 The number of bits at constant quant is as good a measure of complexity as |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
699 any other simple formula for the purpose of allocating bits. But it's not |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
700 perfect for predicting which QP will produce the desired number of bits. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
701 Bits are approximately inversely proportional to QP, but the exact scaling |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
702 is non-linear, and depends on the amount of detail/noise, the complexity of |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
703 motion, the quality of previous frames, and other stuff not measured by the |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
704 ratecontrol. So it predicts best when the QP used for a given frame in the |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
705 2nd pass is close to the QP used in the 1st pass. When the prediction is |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
706 wrong, lavc needs to distribute the surplus or deficit of bits among future |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
707 frames, which means that they too deviate from the planned distribution. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
708 Obviously, with vqcomp=1 you can get the 1st pass QPs very close by using |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
709 CQP, and with vqcomp=0 a CBR 1st pass is very close. But with vqcomp=0.5 |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
710 it's more ambiguous. The accepted wisdom is that CBR is better for |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
711 vqcomp=0.5, mostly because you then don't have to guess a QP in advance. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
712 But with vqcomp=0.6 or 0.7, the 2nd pass QPs vary less, so a CQP 1st pass |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
713 (with the right QP) will be a better predictor than CBR. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
714 |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
715 To make it more confusing, 1pass CBR uses the same rc_eq with a different |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
716 meaning. In CBR, we don't have a real encode to estimate from, so "tex" is |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
717 calculated from the full-pixel precision motion-compensation residual. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
718 While the number of bits allocated to a given frame is decided by the rc_eq |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
719 just like in 2nd pass, the target bitrate is constant (instead of being the |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
720 sum of per-frame rc_eq values). So the scaling factor (which is constant in |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
721 2nd pass) now varies in order to keep the local average bitrate near the |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
722 CBR target. So vqcomp does affect CBR, though it only determines the local |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
723 allocation of bits, not the long-term allocation. |
23237af42335
Technical explanation of how to use vqcomp, and why, featured by Loren Merritt
gpoirier
parents:
13199
diff
changeset
|
724 |
16205 | 725 --Loren Merritt |