digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Video Encoding and Conversion (http://www.digitalfaq.com/archives/encode/)
-   -   Mencoder: Optimal Script with mencoder filters (http://www.digitalfaq.com/archives/encode/9079-mencoder-optimal-script.html)

vmesquita 04-11-2004 05:25 PM

Mencoder: Optimal Script with mencoder filters
 
After encoding the same movie in mencoder without filters (very fast) and with the latest optimal script for DVD (2~3 times slower). I decided to try to reproduce the optimal script using mencoder internal filters. What I did was basically:
1) encode the sample with M.A. script
2) encode with some filter combo
3) Check frame by frame the difference using stackhorizontal.
4) change my mencoder filter chain to make the output more like the Optimal Script Output and go back to step 2.

After many tries, I came to a filter chain that gives results close (but still a little worse) than the optimal script. Also note that M.A. filering is not possible with mencoder. This filter chain is intended to low bitrate targets, like near 2 hours CVD. All the tests were done using 2 Pass VBR:

vf=detc,yuvcsp,scale=336:336:0:0:60,unsharp=l3x3:0 .6,hqdn3d=3:6:8,unsharp=l3x3:-0.7:c3x3:-1.5,expand=352:480:-1:-1:1
ofps=23.976
fps=23.976

You have to change scale and expand to the correct values. (use fitcd or moviestacker to find out). If you examine the static optimal KVCD script and this filter chain, you'll see that they share the same idea.

:D

kwag 04-11-2004 06:09 PM

Brilliant :mrgreen:
I just encoded one of my samples again with this line, and this is almost as good as the MA script :D
Now if I could just get mencoder to read my fake avi created with MakeAVIs :x

Edit: But it's slow slow slow :lol:
But that's to be expected :cool:

-kwag

rds_correia 04-11-2004 06:12 PM

Hmm,
That's all very nice.
I once thought about that too.
But from what do you encode the movie?
From VOB?
If so how can you make the whole movie?
You'll get between 6 to 10 m2vs because that's around the amount of VOB files a DVD has.
You join the m2vs in the end?
From AVS script only with Mpeg2Source and have MEnc's internal filters do the job?
C ya

rds_correia 04-11-2004 06:16 PM

@Kwag,
Use only VM's build http://www.jltoca.uaivip.com.br/file...2004-fixed.zip.
Otherwise you can't use makeAVIS :wink:
Don't know what Vinicius did but it was great :D
Cheers

kwag 04-11-2004 06:18 PM

Quote:

Originally Posted by rds_correia
@Kwag,
Use only VM's build http://www.jltoca.uaivip.com.br/file...2004-fixed.zip.
Otherwise you can't use makeAVIS :wink:

That's what I'm using :!: :roll:

-kwag

rds_correia 04-11-2004 06:23 PM

Don't use makeAVIS that comes with latest FFdshow :!:
Use the old ones that came with FFvfw.
I had the same problem today.
I even had to remove FFdshow...
Cheers

rds_correia 04-11-2004 07:01 PM

Hi,
I'm talking with guys near to the developers at the official forum to see if they implement native support for avisynth scripts in Mencoder
See it here http://article.gmane.org/gmane.comp....yer.cygwin/526
This makeAVIS thing is a real nightmare.
It even crashes sometimes...
Just imagine thousands of newbies complaining about that :wink:
Cheers

rds_correia 04-11-2004 07:20 PM

One very special rule to have makeAVIS work:
- choose your source script
- choose your destination fake avi
- tick the "store script in AVI"
This last one is very important :!:
Otherwise it won't work at all...
Cheers

vmesquita 04-11-2004 09:30 PM

Quote:

Originally Posted by rds_correia
But from what do you encode the movie?
From VOB?
If so how can you make the whole movie?
You'll get between 6 to 10 m2vs because that's around the amount of VOB files a DVD has.
You join the m2vs in the end?
From AVS script only with Mpeg2Source and have MEnc's internal filters do the job?
C ya

It's very easy, easier and faster than with Mpeg2source! There are two ways:
1) The lazy way: encode straight from DVD, with no need for ripping. Since you have a slow machine, I recommend you get some kind of cache if you intent to do that to avoid problems leaving your drive on for too much time. Anyway, encoding speed is slower when coming straight from DVD. But you have the option!
Code:

mencoder -include kvcd.ini -lavcopts vbitrate=873:vpass=1 -dvd-device=F: dvd://TITLE  -o encoded.m2v
replace TITLE with the main movie title number (you can check this using DVD Decrypter) and F: with your DVD-ROM letter

2) Rip the VOBs using DVDDecrypter, but let it joint automatically:
Go to Tools/Settings/IFO Mode and change File Splitting to none. This way DVDDecrypter will produce a big VOB and you just have to do:
Code:

mencoder -include kvcd.ini -lavcopts vbitrate=873:vpass=1 VTS_01_01.VOB  -o encoded.m2v
Remenber, since you are using the VOBs directly, you have to reverse the 3:2 pulldown to recover the progressive frames in case you are dealing with NTSCFilm matherial. That's why you need filmdint in filters chain. if you are dealing with PAL, remove this filter. Mencoder offers 3 IVTC filters, this one seems to be the fastest, but I don't know which one is best qualitywise.

Nice idea native support for avisynth (as an alternative), but I still think we should use the internal filters since they are 2~3 times faster and multiplatafrom. :D

@kwag
Use the package with MakeAVIS only, the link is in rds_correa begginers guide. That's the one I am using. The latest FFDShow didn't come with MakeAvis.
You can use the AtlhonXP version if you have a AtlhonXP, Duron Morgan, Pentium III 1Ghz+ or Pentium IV. It's about 10% faster. :wink: For a 1:1.85 movie, being encoded at 352x480 using this filters, I get around 30 fps! 8O

kwag 04-11-2004 09:43 PM

Quote:

Originally Posted by vmesquita
but I still think we should use the internal filters since they are 2~3 times faster and multiplatafrom. :D

And I second that too :!:
Quote:


@kwag
Use the package with MakeAVIS only, the link is in rds_correa begginers guide. That's the one I am using. The latest FFDShow didn't come with MakeAvis.
Will do :!:

Thanks,
-kwag

vmesquita 04-11-2004 09:51 PM

I did a 1h48m encode to test this filtering with a Real-World example. The movie is "The Lawnmover Man", and it's 1:1.85 AR. The target: 352x480 CVD with 128 kbps audio in 1 80 min CD. The bitrate for that would be 873. I also asked for a Max_rate of 2500.

1st Pass: Average 833 kbps.
2nd Pass: Average 832 kbps.

Averages smaller than asked generally means that quantisizer couldn't be lowered even more. This seems to be the case here, my average quantisizer in second pass was 2.53 (very close to 2, the minimmum). The maximmum bitrate was 2908. It's over the asked value, but maybe it's just a peak that is using VBV buffer. Or maybe it's a problem, but if this is the case it can possibly be fixed playing with rate control. Max quantisizer was 12.95, so mencoder did try to enforce max bitrate.
Aspect in BV: we seen a quantization line with aproximatelly the same shape of the bitrate line. Normal behavior of 2pass VBR.

I'll burn and check the quality in my stand-alone, and report back.

vmesquita 04-11-2004 09:54 PM

Quote:

Originally Posted by kwag
Brilliant :mrgreen:
I just encoded one of my samples again with this line, and this is almost as good as the MA script :D

Yes, and I did it today, alone, trying to reproduce Optimal Script effect. The optimal script has been improved for many people over a lot of months. You see, there's still a lot of room for improvement. :D :D :D 8)

<edit> I watched the encode in my 29" TV. There are DCT blocks in low light areas. :( Most of the movie look good, this is the only problem. But this is a encode problem, not a filtering problem. I can think of two ways to improve this:
1) Encoding settings: I remember that Bilu proposed a special setting for low bitrate encodes
2) Add a little noise. This will make loss of compressibility but at least with this movie, there's bitrate to spare. :D

vmesquita 04-12-2004 06:30 AM

filmdeint was not droppping frames and making the image jump up and down... I only realized wen I tried detc and saw the difference. So I replaced with detc. This should make the video more compressible and end the sync issues. :wink:

Also this is needed to avoid tons of framerate change messages:
ofps=23.976
fps=23.976

<edit>In case anyone needs subs (like me), use this:
sid=0
And replace 0 with the subtitle track number. :wink:
<edit>Added -1:-1:1 to expand, otherwise subtitles keep overlapping.

bilu 04-12-2004 09:56 AM

Quote:

Originally Posted by vmesquita
filmdeint was not droppping frames and making the image jump up and down... I only realized wen I tried detc and saw the difference. So I replaced with detc. This should make the video more compressible and end the sync issues. :wink:

Also this is needed to avoid tons of framerate change messages:
ofps=23.976
fps=23.976

Are you doing DVDs with this framerate? 8O

Bilu

digitall.doc 04-12-2004 11:18 AM

Very nice vmesquita!,
I, as rds, had this in the to do list. But didn't decide to because was too lazy to read and understand the manpage, to look for the filters combo.
But you, da man,... :lol:

You say this is for KDVD encoding. But I don't really think there's a single optimal script for KDVD encoding. Sure your filter combo will be very good (I have to test). But there's also Dialhot suggestion (with fluxsmooth and tempcleaner, or with deen), kwag suggestion (just the MA part with unfilter and tempsmoother),...
I tell you since we could (I'll try to also) make several filter chain and see what is better and faster for mencoder. Maybe mencoder benefits from an special combo of filters. And as you said, this was just (just?) the result of your work. With everybody help we can fine adjust it... if possible :wink:

kwag 04-12-2004 11:46 AM

Quote:

Originally Posted by bilu
Quote:

Originally Posted by vmesquita
filmdeint was not droppping frames and making the image jump up and down... I only realized wen I tried detc and saw the difference. So I replaced with detc. This should make the video more compressible and end the sync issues. :wink:

Also this is needed to avoid tons of framerate change messages:
ofps=23.976
fps=23.976

Are you doing DVDs with this framerate? 8O

Bilu

If the source is FILM, yes you should :!:
If not, you would be encoding at 29.97fps, loosing a lot of quality.
Then run pulldown (or use the internal softpulldown, I believe it's called )

-kwag

bilu 04-12-2004 12:16 PM

Quote:

Originally Posted by kwag
If the source is FILM, yes you should :!:
If not, you would be encoding at 29.97fps, loosing a lot of quality.
Then run pulldown (or use the internal softpulldown, I believe it's called )

IMHO softpulldown+detc or pulldown.exe+detc should use -ofps 23.976, but softpulldown alone should use -ofps 29.97 fps.

softpulldown isn't capable of creating MPEG-2 RFF flags like pulldown.exe
It copies a field into the stream and it becomes hard-telecined 29.97fps.
Of course IVTC works just the same over hard-telecined :)


Bilu

kwag 04-12-2004 12:47 PM

Ok, so then the correct way is as vmesquita posted, and then running pulldown.exe on the resulting .m2v file. :)
Which is the same process as if the file was encoded with ffmpeg.
Well, actually, it is, because mencoder really uses libavcodec, so the result is identical to an ffmpeg encode :!:

-kwag

bilu 04-12-2004 01:01 PM

I'm doing -ofps 29.97 and softpulldown because it's multi-platform.

AFAIK there is nothing like pulldown.exe for Linux :?


Bilu

digitall.doc 04-12-2004 01:07 PM

Quote:

Originally Posted by vmesquita
Quote:

Originally Posted by rds_correia
But from what do you encode the movie?
From VOB?
If so how can you make the whole movie?
You'll get between 6 to 10 m2vs because that's around the amount of VOB files a DVD has.
You join the m2vs in the end?
From AVS script only with Mpeg2Source and have MEnc's internal filters do the job?
C ya

It's very easy, easier and faster than with Mpeg2source! There are two ways:....

And I'll give you the third one. I don't want to say it's better, but just one else to use. You have got all your vobs in a folder. And you feed mencoder through piping, this way:
Code:

type D:\vobs\*.vob|D:\mencoder\mencoder -include ... -vf ... -lavcopts ... -o D:\encoded\1pass.m2v  -
The keys are "type" and | in the begining of the command, and "-" in the end.
It's working for me. When encoding, mencoder complains in the begining:
Code:

Reading from stdin...
success: format: 0 data: 0x0 - 0x0
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
Cannot seek backward in linear streams!
Seek failed
MPEG-PS file format detected.

And then it doesn't show the percentage encoded, nor the aproximate final file size, nor time left... but it works. Just try if you think it does worth.


All times are GMT -5. The time now is 05:58 PM  —  vBulletin Jelsoft Enterprises Ltd

Site design, images and content © 2002-2022 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2022 Jelsoft Enterprises Ltd.