PDA

View Full Version : Some questions from a newbie


Anacondo
7th June 2003, 00:11
Hi people. I'm new to video encoding in Linux, although I have some experience with Windows and have made some quite-good looking rips. Some time ago I decided to migrate to Linux, and except for playing, audio and video editing I'm (almost) totally independant from it now.

I was very used to DVD2AVI + Avisynth + VirtalDub, and at first I thought I would not be capable of doing a decent rip with Linux, but after some hours of testing and digging into mencoder's man page I completed my first rip. I used windows for ripping (can't remember the app, I don't know how to do this with Linux yet), mencoder with libavcodec for the video part and wine + besweet + vorbis for the audio. I muxed the results with ogmmerge The result was fairly good, a bit more blocky than I would have liked, but looks great on my TV set. I have to admit that mencoder is one incredible app. And damn, it's fast! I got about 25fps for every pass (K7 1GHz)! I'm impressed with what Linux offers me once again. I don't think i'll miss my old method with the power & flexibility I have discovered now. I was a bit reacious at first of doing everything from the command line, but now I see it's the best thing to do if one wants total control over everything.

Anyway, as I'm just starting I have some questions and doubts:

1º) Video transcoding with Mencoder

I used this commands for my rip:

cat /mnt/datos/kpax/vob/video*.vob | nice -+19 mencoder -sws 9 -vop scale=544:256:5,crop=650:435:35:75 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=850:vhq:v4mv:vpass=1:vqmin=2:vqmax=31:vmax_b_frames=2 -o /dev/null -

cat /mnt/datos/kpax/vob/video*.vob | nice -+19 mencoder -sws 9 -vop scale=544:256:5,crop=650:435:35:75 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=850:vhq:v4mv:vpass=2:vqmin=2:vqmax=31:vmax_b_frames=2 -o K-Pax.avi -

When doing the 1st pass in Windows, I think the codec (divx) used a constant quantizer of 2 for gathering statistics and then the desired bitrate for the 2nd pass. I saw in a mencoder guide that the author used vbitrate=X for both passes, so I did the same. Is this the way to go with libavcodec?

I used -sws 9 (lanczos) for my resize. I couldn't see much difference in performance (~1fps) with bilinear (I believe it uses bilinear if I don't say otherwise). Is this normal? Am I resizing properly?

I tested my cropping with -vop rectangle and calculated the aspect ratios by hand. Is there a better way of doing this?

I've been playing lately with the options that are mentioned in this thread:
http://forum.doom9.org/showthread.php?s=&threadid=49082&highlight=libavcodec
and I could only get around 10fps. Could anyone please explain me the impact of these options over quality and processing time?
(precmp, cmp, subcmp, vb_qfactor, vb_offset, trell)

2º) Audio transcoding

I used wine + besweet for the audio as I said. However, I'd like to know how you people transcode your audio with Linux. I played a bit with transcode (tcextract & tcdecode) and was able to output an .ac3 file to .ogg (although I couldn't specify a custom command line for oggenc), but I'd like to have more control over the process, i.e. controlling the output levels, how the channels are mixed, increasing the loudness... Can this be done in a similar way to besweet?

That's all for now. I hope to learn a lot from you people so I can make better rips :D! Thanks in advance!

TactX
7th June 2003, 11:39
Welcome to this board :)

Originally posted by Anacondo
When doing the 1st pass in Windows, I think the codec (divx) used a constant quantizer of 2 for gathering statistics and then the desired bitrate for the 2nd pass. I saw in a mencoder guide that the author used vbitrate=X for both passes, so I did the same. Is this the way to go with libavcodec?
I'm not sure if you need to use the same bitrate for both passes, but it's save to do so...

Originally posted by Anacondo
I used -sws 9 (lanczos) for my resize. I couldn't see much difference in performance (~1fps) with bilinear (I believe it uses bilinear if I don't say otherwise). Is this normal? Am I resizing properly?
If you don't pass any resize method to mencoder it will use bicubic and tell you...
SwScaler: BICUBIC scaler, from Planar YV12 to Planar YV12 using MMX2
I've never used lanczos, but your cropping/resizing looks O.K. and 1 fps difference seems quite realistic.

Originally posted by Anacondo
I tested my cropping with -vop rectangle and calculated the aspect ratios by hand. Is there a better way of doing this?
Propably yes :D
But that's also the way I do it...

Originally posted by Anacondo
I've been playing lately with the options that are mentioned in this thread:
http://forum.doom9.org/showthread.php?s=&threadid=49082&highlight=libavcodec
and I could only get around 10fps. Could anyone please explain me the impact of these options over quality and processing time?
(precmp, cmp, subcmp, vb_qfactor, vb_offset, trell)

What CPU do you have? I get ~10 fps on my TBird 800 MHz with trellis quantization, very high quality, b-frames and 4 Motion Vectors.
Qpel and vhq seem to take lots of processing time.
In the link you mentioned you can see the fps for every tested setup, so I think it would be good to have a look at it.

Anacondo
7th June 2003, 13:27
I've never used lanczos, but your cropping/resizing looks O.K. and 1 fps difference seems quite realistic.
I remember reading it is a bit sharper than bicubic and faster (at least it was with windows), so I started using it and I'm quite pleased with the results.

What CPU do you have? I get ~10 fps on my TBird 800 MHz with trellis quantization, very high quality, b-frames and 4 Motion Vectors. Qpel and vhq seem to take lots of processing time. In the link you mentioned you can see the fps for every tested setup, so I think it would be good to have a look at it.
I'm using this command line right now:

cat vts_*.vob | mencoder -nosound -sws 9 -vop scale=480:384:5,crop=698:568:10:4,lavcdeint -ovc lavc -lavcopts vcodec=mpeg4:vqscale=2:vhq:v4mv:vmax_b_frames=1:precmp=2:cmp=2:subcmp=2:vb_qoffset=0.6:qpel:trell:vpass=1 -o /dev/null -

cat vts_*.vob | mencoder -nosound -sws 9 -vop scale=480:384:5,crop=698:568:10:4,lavcdeint -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1600:vhq:v4mv:vmax_b_frames=1:precmp=2:cmp=2:subcmp=2:vb_qoffset=0.6:qpel:trell:vpass=2 -o beethoven.avi -

I get ~6fps with an Athlon-TB@1GHz. Quality is fantastic. Without qpel i get ~9fps. precmp, cmp, and subcmp don't seem to have a severe impact on performance (~10fps w/o them). 13fps without trell. And ~18 with no vhq.

TactX
7th June 2003, 13:39
Originally posted by Anacondo
I get ~6fps with an Athlon-TB@1GHz. Quality is fantastic. Without qpel i get ~9fps. precmp, cmp, and subcmp don't seem to have a severe impact on performance (~10fps w/o them). 13fps without trell. And ~18 with no vhq.

Hmmm...

with this setup...

mencoder stream.dump -vop scale=576:240,crop=714:424:2:78 -o pass1.avi -nosound -ovc lavc -lavcopts vcodec=
mpeg4:vbitrate=655919:vhq:v4mv:precmp=2:cmp=2:subcmp=2:vb_qfactor=1.25:vb_qoffset=0.6:vmax_b_frames=1:trell
:vrc_override=184680,190500,-500:qpel:vpass=1

... I get ~10 fps. Hehe my system is faster :D

Actually, this is quite strange :rolleyes:

Anacondo
7th June 2003, 14:08
I just noticed my source is interlaced and I'm using lavcdeint, which may have some impact in performance. And maybe using a higher nice value will give me a pair more fps. I'll test again with progressive source.

I see you're using a value of 655919 for vbitrate. Isn't that overkill? Why not go with vqscale=2 instead?

BTW, how do you transcode your audio? Which options do you use?

Thanks, and cheers.

TactX
7th June 2003, 16:52
Originally posted by Anacondo
I just noticed my source is interlaced and I'm using lavcdeint, which may have some impact in performance. And maybe using a higher nice value will give me a pair more fps. I'll test again with progressive source.
O.K. this is propably the reason for your bad performance.


Originally posted by Anacondo
I see you're using a value of 655919 for vbitrate. Isn't that overkill? Why not go with vqscale=2 instead?
Quoted from the mplayer manpage:
vbitrate=<value> specify bitrate (pass 1/2) in
kBit <4-16000> or
Bit <16001-24000000>
(warning: 1kBit = 1000 Bits)
(default: 800)
As you see my bitrate is not 655919 kbit/s but 655919 bit/s ;)


Originally posted by Anacondo
BTW, how do you transcode your audio? Which options do you use?
I'm using AVIdemux for muxing, cutting and audio most of the time.
I normally use 112 or 128 kbit/s MP3 audio with "6 dB press" activated in AVIdemux.

Anacondo
7th June 2003, 17:43
As you see my bitrate is not 655919 kbit/s but 655919 bit/s
:rolleyes:

I'm using AVIdemux for muxing, cutting and audio most of the time. I normally use 112 or 128 kbit/s MP3 audio with "6 dB press" activated in AVIdemux.

I see. And how do you demux the AC3 track from a .vob to open it with avidemux?

TactX
7th June 2003, 18:03
"mplayer -aid <id> -dumpaudio"

Anacondo
7th June 2003, 18:42
"mplayer -aid <id> -dumpaudio"
Fantastic. I was thinking of a long tedious tcextract & tcdemux commandline... This program keeps surprising me :)

Thanks man!

Anacondo
8th June 2003, 18:46
One more question about audio. I extracted the ac3 file with "mplayer -aid 128 -dumpaudio". I remeber that with windows rippers I used to demux the AC3 track insted of copying it in the decrypted VOBs. The apps I used (smartripper, dvddecrypter) used to point me the A-V delay in the AC3 track (generally in milliseconds) so I could correct it later when transcoding. Now in Linux i'm doing a similar thing: demuxing the audio track and dumping it to disk. Do you know if mplayer corrects any delay issues? If not, how do I know the amount of delay?

Anacondo
8th June 2003, 23:10
I just checked out one thing. I extracted a small chapter from a DVD with wine+dvddecrypter, demuxing the AC3 track. The result was an .ac3 file and the program notes it has -60ms of delay.

I made the same with dvd::rip and extracted the AC3 with mplayer -dumpaudio. The two files are bit-identical, so I suppose mplayer doesn't correct the A-V delay for itself. Then, there's a delay which value I don't know (I know it now because of windows) and even if I knew it I wouldn't know how to fix it. Has anyone experienced this problem? What can I do?

I've checked my first (and only) movie rip and the A-V delay was 0ms, so it seems I was lucky :D

BTW, is there any way of redirecting "mplayer FILE -aid ID -dumpaudio" to standard output so I can use a pipe for encoding, without intermediate files?

mean
9th June 2003, 10:34
To do this, a bit tricky
Encode video, play video and audio from ac3 direcly
Use +- in mplayer until you got the sync

Note down the value

Use mplayer/avidemux/transcode to take into account the time shift