[MPlayer-users] Re: mencoder: encoding a B&W movie

Rémi Guyomarch rguyom at pobox.com
Mon Oct 21 21:04:02 CEST 2002


On Mon, Oct 21, 2002 at 01:29:33AM -0400, Laurent Joubert wrote:
> [Automatic answer: RTFM (read DOCS, FAQ), also read DOCS/bugreports.html]
> Hello,
> 
> I am trying to encode a B&W movie from a DVD.

I found myself that 4:3 B&W old movies are very hard to compress
well. In addition to the 4:3 aspect ratio which eats lots of bits,
those movies are typically very "noisy", which doesn't help at all.
Anyway :

> After a few tries I am 
> still a little bit disappointed with the video quality. Since it is a 
> "dark" movies, there is a lot of black on the pictures, and on the 
> encoded avi I can see a lot of annoying "mpeg squares". I am using 
> avifile codec, but the best I think is to give you the command line I 
> used to encode a preview of the result:
> 
> First pass:
> mencoder TITLE01-ANGLE1.VOB -oac copy -ovc lavc -lavcopts 
> vcodec=mpeg4:vhq:vpass=1:vbitrate=800:keyint=48 -ofps 23.976 -npp lb 
> -ss 2:00 -endpos 0:30 -vop scale -zoom -xy 640 -o movie.avi

1) keyint=48 is way too low. The default value is 250, this is in
*frames* not seconds. Key frames are significantly larger than P or B
frames, so the less key frames you have, better the overall movie will
be. (huh, like Yoda I speak ;). Try keyint=300 or 350. Don't go beyond
that if you want relatively precise seeking.

2) you may want to play with vlelim and vcelim options. This can
gives you a significant "quality" boost. Try one of these couples :
vlelim=-2:vcelim=3
vlelim=-3:vcelim=5
vlelim=-4:vcelim=7
(and yes, there's a minus)

3) crop & rescale the movie before passing it to the codec. First
crop the movie to not encode black bars if there's any. For a 1h40mn
movie compressed to a 700 MB file, I would try something between
512x384 and 480x320. Don't go below that if you want something
relatively sharp when viewed fullscreen.

4) I would recommend using the Ogg Vorbis audio codec with the
.ogm container format. Ogg Vorbis compress audio better than MP3. On a
typical old, mono-only audio stream, a 45 kbits/s Vorbis stream is ok.
How to extract & compress an audio stream from a ripped DVD (mplayer
-dvd 1 -dumpstream) :

rm -f audiodump.pcm ; mkfifo -m 600 audiodump.pcm
mplayer -quiet -vc null -vo null -aid 128 -ao pcm -nowaveheader stream.dump &
oggenc --raw --raw-bits=16 --raw-chan=2 --raw-rate=48000 -q 1 -o audio-us.ogg audiodump.pcm &
wait

For a nice set of utilities to manager the .ogm format, see Moritz Bunkus'
ogmtools (google is your friend).

5) use the "v4mv" option. This could gives you a few more bits at
the expense of a slightly longer encoding. This is a "lossless"
option, I mean with this option you don't throw away some video
information, it just selects a more precise motion estimation
method. Be warned that on some very un-typical scenes this option may
gives you a longer file than without, although it's very rare and on a
whole film I think it's always a win.

6) you can try the new luminance & darkness masking code. Play
with the "lumi_mask" and "dark_mask" options. I would recommend using
something like :
lumi_mask=0.07:dark_mask=0.10:naq:
lumi_mask=0.10:dark_mask=0.12:naq:
lumi_mask=0.12:dark_mask=0.15:naq
lumi_mask=0.13:dark_mask=0.16:naq:
Be warned that these options are really experimental and the result
could be very good or very bad depending on your visualization device
(computer CRT, TV or TFT screen). Don't push too hard these options.

> Second pass:
> the same with vpass=2

7) I've found that lavc gives better results when the first pass is
done with "vqscale=2" instead of a target bitrate. The statistics
collected seems to be more precise. YMMV.

> I am new to mencoder, so please tell me any idea you have even if it 
> obvious. I also tried the "gray" option of lavc, to encode B&W only, 
> but strangely it gives me "pink" squares from time to time.

Yes, I've seen that too. Playing the resulting file with "-lavdopts
gray" fix the problem but it's not very nice ...

> So if you could tell me what option of mencoder or lavc I should be 
> looking at to lower the number of "squares" on the image, it would be 
> great. The version of mencoder i use is 0.90pre8 on a macos x PPC 
> platform. I guess I would have the same problem by encoding anime 
> movies, where there are a lot of region of the image with the same 
> color. So if you managed to solve this problem...

You could also try the "mpeg_quant" flag. It selects a different set
of quantizers and produce somewhat sharper pictures and less
blocks on large zones with the same or similar luminance, at the
expense of some bits.

> This is completely off topic, but do you know how I can create good 
> subtitles from vobsub subtitles ? I checked the -dumpmpsub option of 
> mplayer, but is there a way to do it really fast (ie without having to 
> play the whole movie) ?

I didn't find a way under *nix to produce reasonably good text
subtitles from vobsubs. OCR *nix softwares seems either not suited to
the task, not powerful enough or both.
I'm extracting the vobsub subtitles and simply use them with the .ogm
/ .avi :
1) rip the DVD to harddisk with "mplayer -dvd 1 -dumpstream"
2) mount the DVD and copy the .ifo file
2) extract all vobsubs to one single file with something like :

for f in 0 1 2 3 4 5 6 7 8 9 10 11 ; do \
    mencoder -ovc copy -oac copy -o /dev/null -sid $f -vobsubout sous-titres -vobsuboutindex $f -ifo vts_01_0.ifo stream.dump
done

(and yes, I've a DVD with 12 subtitles)

> PS. mencoder gives a "bus error" when it finishes encoding the file. It 
> does not seem to be a problem since the avi is perfect, but just to let 
> you know. (mplayer 0.90pre8 and MacOS X 10,2, gcc 3.1)

I've seen lots of PPC fixes lately. Try the latest CVS code (both
mplayer & ffmpeg).

-- 
Rémi




More information about the MPlayer-users mailing list