digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: need some help with my first script (http://www.digitalfaq.com/archives/avisynth/14409-avisynth-first-script.html)

gattotimo 10-31-2006 06:20 AM

Avisynth: need some help with my first script
 
Hi, I'm new to this forum. I wasn't sure about what section I had to post my request, so please excuse me if this is not the right one (and sorry if my english is poor, I'm italian). By the way, here's the question:
My goal is to make a kdvd backup from my original Lost 1st season (PAL). I read in kdvd specification that it can fit up to 6 hrs in one single DVD-5, so that means I can put the entire season (17 hours and an half) into 2 DVD-9 or even just one DVD-9 (using the half resolution template). Then I'm gonna use DVDLab to author the dvd, which I CAN use so I won't bother you about that :wink:. I got three questions:

1 - The first, the most important: I got problems with avisynth. I have installed version 2.5x, and all the needed plugins, but when I try to open the script with wmp (classic), it seems like there's some missing codec: wmp tries a couple of times to connect to his server to download a codec, then after a couple of tries tells me he cannot play the file. Please note that wmp does not show any red message on black screen (I see that happens trying to play wrong scripts).

2 - I would like to keep the anamorphic aspect ratio. How can I do this? I read that FitCd can produce correct avs script, but I'm unsure about what parameters I have to feed it. And about avs script, is the one in the sticky post right for my purpose?

3 - The steps to follow. The kdvd template must be loaded before or after opening the source video in TMPEG? Is it the same or one step must be achieved before the other?

I hope you can help me, thanks to you all

Dialhot 10-31-2006 07:28 AM

Re: I need some help with my first script
 
Quote:

Originally Posted by gattotimo
Hi, I'm new to this forum.

Ciao Matteo.

Quote:

I read in kdvd specification that it can fit up to 6 hrs in one single DVD-5, so that means I can put the entire season (17 hours and an half) into 2 DVD-9 or even just one DVD-9 (using the half resolution template).
One things to know is that the 6 hrs are estimated for a widescreen material, that is a movie shot in 2.35:1. Lost episodes are in 1.85 (or 1.77 I do not remember well) so this is more like 4hours that you can expect on a DVD5. with 17 hours and 2 DVD9, you should have enought space.
Personnaly I put 8 episodes of Lost on a DVD-5 with the half template (two audio - one subtitle). That is 3 DVD-5 for the whole season.

Quote:

1 - The first, the most important: I got problems with avisynth. I have installed version 2.5x, and all the needed plugins, but when I try to open the script with wmp (classic), it seems like there's some missing codec: wmp tries a couple of times to connect to his server to download a codec, then after a couple of tries tells me he cannot play the file. Please note that wmp does not show any red message on black screen (I see trying to play wrong scripts).
A YV12 capable codec is needed to play the result of an avisynth script, as this is the native color space used by avisynth. Install for instance the XVID codec (or Divx). Don't worry, that does not mean that avisynth produces xvid or divx material.

Quote:

2 - I would like to keep the anamorphic aspect ratio. How can I do this? I read that FitCd can produce correct avs script, but I'm unsure about what parameters I have to feed it. And about avs script, is the one in the sticky post right for my purpose?
Can you explain better what you expect : do you plan to keep the DVD as anamorphic (that means a 16/9 picture stetched vertically) or do you want to do a 4/3 DVD with the 16/9 picture "letterboxed" in the middle of it ?
Concerninng the script : you will have to add a deinterlacing filter at top, but I will explain you that afterwards.

Quote:

3 - The steps to follow. The kdvd template must be loaded before or after opening the source video in TMPEG? Is it the same or one step must be achieved before the other?
The template first, the script after. This way this is the script that gives the final resolution and not the template. This way if you take thje wrong template by mistake, there is not importance.

gattotimo 10-31-2006 08:18 AM

Re: I need some help with my first script
 
Ciao Phil!
Thanks for your help. I'll try to answer your questions :wink:

Quote:

Originally Posted by Dialhot
Lost episodes are in 1.85 (or 1.77 I do not remember well) so this is more like 4hours that you can expect on a DVD5. with 17 hours and 2 DVD9, you should have enought space.
Personnaly I put 8 episodes of Lost on a DVD-5 with the half template (two audio - one subtitle). That is 3 DVD-5 for the whole season.

Yes, Lost episodes are in 1.78:1. So 2 dvd-9 should be enough for the whole season + extras with the half template (2 audio and subtitles).

Quote:

A YV12 capable codec is needed to play the result of an avisynth script, as this is the native color space used by avisynth. Install for instance the XVID codec (or Divx). Don't worry, that does not mean that avisynth produces xvid or divx material.
Ok! I just installed divx codecs and the avs script finally plays fine!

Quote:

Can you explain better what you expect : do you plan to keep the DVD as anamorphic (that means a 16/9 picture stetched vertically) or do you want to do a 4/3 DVD with the 16/9 picture "letterboxed" in the middle of it ?
My preferred option would be the first one: I'd like to keep my kdvd as anamorphic as the original one. Do you think it's a good idea or is it just a waste of time and disc-space?

Quote:

Concerninng the script : you will have to add a deinterlacing filter at top, but I will explain you that afterwards.
Ok, I'll do it. I'll post my script as it is now at the end of this post, and if you want you could suggest what changes are needed, like the deinterlacing thing.

I wanna thank you again for your help, I hope I gave you all the informations you need to help me. Now, here's my script as it is now:


## DLL Section ##
#
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\MPEG2Dec3.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\DGDecode.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\GripFit_YV12.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\STMedianFilter.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\asharp.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\unfilter.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\undot.dll")
#
####
## Main section and static filters ###
#
Mpeg2Source("E:\Lavoro KVCD\lost.d2v")
LanczosResize(688,416,0,70,720,436)
AddBorders(16,80,16,80)
#Trim(0,62523).FadeOut(150)
undot()
asharp(1, 4)
STMedianFilter(3, 3, 1, 1 )
MergeChroma(blur(1.5))
MergeLuma(blur(0.1))
#
#

## Linear Motion Adaptive Filtering ##
#
# ( Portions from AviSynth's manual )
# This will apply variable temporalsoften
# and variable blur.
# Both filters are active at all times, and work inversely proportional to the
# activity, measured from current frame to next frame.

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

#
#
#

#GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!

#
#
## Functions ###

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2
}

ConvertToRGB24() # For TMPGEnc or VFAPI
#
####

Dialhot 10-31-2006 12:05 PM

Re: I need some help with my first script
 
Quote:

Originally Posted by gattotimo
My preferred option would be the first one: I'd like to keep my kdvd as anamorphic as the original one. Do you think it's a good idea or is it just a waste of time and disc-space?

352*576 anamorphic is not standard, so your player will perhaps not play the discs. If you don't mind to make a non-standard DVD you should download the KDVD sample disc that I did, there is a test for all resolutions, standard and not.
http://www.kvcd.net/forum/viewtopic.php?t=15522

Else, as I used 3 DVD-5 for the season in 352*576 not anamorphic and you plan to use 2 DVD-9 to do the same in anamorphic, I would says that this is something that sounds possible. But remember that 1.77 anamorphic is actually like a 1.33 picture (anamorphic = the picture is stretched vertically). That means more pixel to encode so more space needed at the end.

Quote:

## DLL Section ##
#
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\MPEG2Dec3.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\DGDecode.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\GripFit_YV12.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\STMedianFilter.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\asharp.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\unfilter.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\undot.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\TDeint.dll")
#
####
## Main section and static filters ###
#
Mpeg2Source("E:\Lavoro KVCD\lost.d2v")
LanczosResize(688,416,0,70,720,436)
TDeint(order=1,tryweave=true)
#Trim(0,62523).FadeOut(150)
undot()
asharp(1, 4)
STMedianFilter(3, 3, 1, 1 )
MergeChroma(blur(1.5))
MergeLuma(blur(0.1))
#
#

## Linear Motion Adaptive Filtering ##
#
# ( Portions from AviSynth's manual )
# This will apply variable temporalsoften
# and variable blur.
# Both filters are active at all times, and work inversely proportional to the
# activity, measured from current frame to next frame.

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

#
#
#

AddBorders(16,80,16,80)
#GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!

#
#
## Functions ###

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2
}

ConvertToRGB24() # For TMPGEnc or VFAPI
#
####
TDeint is Tritical Deinterlacer :
http://avisynth.org/warpenterprises/...l_20060410.zip

Note: your script produce a 704*576 non anamorphic target. Set correctly filtCD to obtain what you wants (ie a 352*576, anamorphic or not, target)

gattotimo 10-31-2006 12:35 PM

Re: I need some help with my first script
 
Quote:

Originally Posted by Dialhot
352*576 anamorphic is not standard, so your player will perhaps not play the discs. If you don't mind to make a non-standard DVD you should download the KDVD sample disc that I did, there is a test for all resolutions, standard and not.
http://www.kvcd.net/forum/viewtopic.php?t=15522

I thought 352x576 anamorphic was standard, but since it's not I think I'll shift to non-anamorphic. BTW I'll try your sample disc to check what resolutions my player can or cannot handle

Quote:

Note: your script produce a 704*576 non anamorphic target. Set correctly filtCD to obtain what you wants (ie a 352*576, anamorphic or not, target)
While I was waiting for your answer, I tried the avs script I posted before with the KDVD (full resolution) template. The output video was good, but the image was wrongly vertically cropped (actors name in the first part of the movies were only half displayed). Now I see you added this line to the script
AddBorders(16,80,16,80)
is that to prevent that kind of errors?

Thanks again :)

Dialhot 10-31-2006 12:39 PM

I think that you miss how to use fitCD (look for a tutorial on the net) or better use Incredible's tool : Paranoia.

The tool : http://www.kvcd.net/forum/viewforum.php?f=93
A tutorial in flash done by Rui : http://www.kvcd.net/forum/viewtopic.php?t=16590

gattotimo 10-31-2006 01:04 PM

Quote:

Originally Posted by Dialhot
I think that you miss how to use fitCD (look for a tutorial on the net) or better use Incredible's tool : Paranoia.

The tool : http://www.kvcd.net/forum/viewforum.php?f=93
A tutorial in flash done by Rui : http://www.kvcd.net/forum/viewtopic.php?t=16590

Ok, I'll try that one!

edit: Nice tutorial. I'm right now trying encoding with the new script, I'll post later the results

Boulder 11-01-2006 02:11 PM

352x576 at 16:9 will look very bad I'm afraid. It'll be very blurry because it's stretched so much by the DVD player upon playback.

gattotimo 11-02-2006 04:24 AM

Yesterday I wasn't at home so I couldn't try, right now I'm at work but I left my pc with some homeworks to do :wink:, I'm trying both full resolution (CQ 60) and half resolution (CQ 100) to start a comparison. I took the resize script line from Paranoia, while the rest of the script is from Dialhot's suggested one: I'll let you know some impressions when I'll be home again

Dialhot 11-02-2006 04:39 AM

Quote:

Originally Posted by Boulder
352x576 at 16:9 will look very bad I'm afraid. It'll be very blurry because it's stretched so much by the DVD player upon playback.

All my old KVCD/KDVD look blurry now that I'm watching them on a 50" HDTV screen (before I had a 28" 4/3 TV) but things are really better now that I use anytime a LimitedSharpen line. Actually all depend on the size of the TV of gattotimo.

gattotimo 11-02-2006 04:55 AM

Quote:

Originally Posted by Dialhot
Actually all depend on the size of the TV of gattotimo.

Well, the tv in my room is an old 21" (50hz). The other one (the good one) is a 29" (100hz), which will be probabily soon changed into a little bigger lcd (maybe even a HDTV one). Does it means that the half resolution would be ok for the smaller tv while the full resolution would be the best for the bigger tv, or the limited sharpen line would fix any problem on any tv (so I should use it anyway)?

Dialhot 11-02-2006 05:13 AM

I advice you to use it. The problem is that the file size is increased about 10% or more when you use a sharpen line.

Anyway the optimal script already have a "asharp" line (I never used this script for my own usage). I would just suggest you to replace the "asharp" line by a "limitedsharpen" one. But this filter is a little bit more complicated to use. See there :
http://www.kvcd.net/forum/viewtopic....asc&highlight=
(you can jump to the last page if you need latest informations :-)).

gattotimo 11-02-2006 06:44 AM

Ok, I just read the whole thread. I understood just some of the stuff posted there, since I'm almost a newbie to advanced encoding (but you've got to start somewhere, right :P?). BTW, here are my new questions (I hope I'm not bothering you, Phil).
Ok, so LimitedSharpen is a good thing, and, if I'm not wrong, since my source is a good MPG2 maybe it won't be TOO difficult to use that to have good results. I'll start copying what it seems to be a good generic script for clean sources:

Lremovedust(4,1)
limitedsharpen(ss_x=1, ss_y=1, smode=3, strength=50, soft=20)

The first problem is: I read that LS can also be used to resize the video. Should I do so or simply add the above lines after (or before) the bicubicresize one? If the answer is to let LS do the resize, how can it be done?
Second problem: the Lremovedust line. For clean materials like the one I have to encode, that line should be used before or after the LS one?
Third (and last) problem: I read that there is another filter (LSFast) which is (let me guess...) faster than LS, so maybe I should use that one instead. Are his parameters the same as LS or is its usage different?

Dialhot 11-02-2006 08:35 AM

To answer to all your questions is faster for me to give you the script that I used :

Code:

DGDecode_Mpeg2source("PATH\NAME.d2v",cpu=4,idct=7)

LanczosResize(... given by Paranoia ...)

LimitedSharpenFaster()
LRemoveDust_YV12(17,1)

MergeLuma(Blur(0.1))
MergeChroma(Blur(1.58))

Addborders(... given by Paranoia ...)

When I'm short in disc space, I sometimes add this line just before the Addborder one
Code:

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1)  ")
With that line, my script is not so different than the "official" optimal script.

Note : the parameter 17 for LRemoveDust is the mode, in other word, the denoiser that will be used. Perhaps 4 is better than 17, I confess that I did not compare really all the modes.
Note2: yes, LSFaster is "just" a faster implementation of LS. Use it with the same parameters.

Boulder 11-02-2006 10:23 AM

Mode 17 in RemoveGrain should preserve thin lines better than mode 4 so it's recommended.

gattotimo 11-02-2006 11:26 AM

Thanks again guys. :D
So, after all your suggestions my script is at the moment like this
(source: pal anamorphic, target: pal, half resolution, non anamorphic)
*note: there's surely some unneeded plugin in the load section, but I think that's not harm, isn't it?:

LoadPlugin("C:\Programmi\Avisynth 2.5\filters\MPEG2Dec3.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\DGDecode.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\GripFit_YV12.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\STMedianFilter.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\asharp.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\unfilter.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\undot.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\TDeint.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\mt_masktools.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\RemoveGrain.dll")
LoadPlugin("C:\Programmi\Avisynth 2.5\filters\Repair.dll")

Import("C:\Programmi\Avisynth 2.5\filters\LimitedSharpenFaster.avsi")
Import("C:\Programmi\Avisynth 2.5\filters\LRemoveDust_YV12.avsi")


dgdecode_mpeg2source("E:\Lavoro KVCD\lost.d2v", cpu=4, idct=7)
BicubicResize(352,432,1./3.,1./3.,10,0,700,572)
TDeint(order=1,tryweave=true)
LimitedSharpenFaster()
LRemoveDust_YV12(17,1)
MergeLuma(blur(0.1))
MergeChroma(blur(1.58 ))

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

Letterbox(16,16,16,16)

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2
}

Addborders(0,72,0,72)


I unpacked both the removegrain (v 1.0) package and the masktool one (v 2.0a27) in my filters directory. For the LRemoveDust_YV12 function I found this one

function LRemoveDust_YV12(clip input, int clmode, int "limit")
{
limit=default(limit,2)
clmode=default(clmode,17)
repmode = 2
clensed = Clense(input)
rep = Repair(clensed, input, mode=repmode)
rg = RemoveGrain(rep, mode=clmode)
return LimitChange(rg, input, limit)
}


But the script doesn't work: a red message jumps up in wmp saying <There is no function named "limitchange"...>. Where's the bug :?:

Dialhot 11-02-2006 11:39 AM

Quote:

Originally Posted by gattotimo
*note: there's surely some unneeded plugin in the load section, but I think that's not harm, isn't it?:

Not it does not harm. Actually, if you rename the folder "filter" to "plugins", avisynth with autoload all the plugin and you can remove all the "Loadplugin" lines.
Quote:

But the script doesn't work: a red message jumps up in wmp saying <There is no function named "limitchange"...>. Where's the bug :?:
See my answer (the second one) there :
http://www.kvcd.net/forum/viewtopic....tchange#125123

gattotimo 11-02-2006 12:06 PM

Quote:

Originally Posted by Dialhot
See my answer (the second one) there :
http://www.kvcd.net/forum/viewtopic....tchange#125123

Ok, another trouble solved: I should build you some kind of statue, instead of just thanking you :wink:.
I'll start encoding with the above posted script, lets see what I'll get. I'll keep you informed as ever

Dialhot 11-02-2006 12:20 PM

Prego :D

gattotimo 11-03-2006 03:56 AM

I'm so sorry to keep asking questions, but unfortunally I got antoher problem :oops: . I'm sure its solution it's easy, but I'm trying since yesterday and I still can't get over it: TMPEGEnc simply stopped working with avs scripts (even the simpliest ones). I tried to uninstall the program and reinstall other versions (even deleting the ini files), but the end is always the same: when I try to load my brand new avs script, TMPEG says something like "file type not supported". I even tried to reenter the avsreader key in the registry, but it doesn't work. The strange thing it's that I didn't do any change to the system since the last time TMPEG worked. And, of course, the script itself plays great with wmp. TMPEG still can accept d2v files. Maybe I should have this question posted in the TMPEG area, I eventually posted it here to keep a continuity with my whole "case". Where's the trick :??

Dialhot 11-03-2006 05:20 AM

Open tmgenc, go into "Environnemental Settings" and then "VFAPI plugin".

1/ verify that the line "Avisynth/Virtualdub script reader" is present and checked.
2/ verify that the priority of this line is bigger than all otehr ones. Else raise it (right click on the name -> Higher priority).
3/ let the cursor on the name "Avisynth / virtual...." for 2 seconds and read in the baloon window if there is an error reported and if the path to the file Readavs.dll is correct.

gattotimo 11-03-2006 05:53 AM

I already tried the first two on yesterday. Right now I'm at work so I cannot try the third one, I'll do it as soon as I'll be home again in the afternoon. Stay tuned for the forthcoming news :wink:

gattotimo 11-03-2006 09:55 AM

Hi, Phil, I just came home and checked: the path for readavs.dll is right, but tmpeg still fails to open avs scripts :cry: . What can I try now?

Dialhot 11-03-2006 11:00 AM

Add a line "ConvertToRGB24()" at the end of the script and test again with this.

Also try to open the script with virtualdubmod if you have it, to see if the problem is the same or not.

gattotimo 11-03-2006 11:53 AM

Quote:

Originally Posted by Dialhot
Add a line "ConvertToRGB24()" at the end of the script and test again with this.

Also try to open the script with virtualdubmod if you have it, to see if the problem is the same or not.

I've tried both, and the result is the same: red cross with error message ("cannot open or unsupported" for TMPEG, and "avisynth: open error script open failed" with VirtualDubMod). May the avisynth installation have somehow gotten corrupted?

Dialhot 11-03-2006 11:55 AM

Quote:

Originally Posted by gattotimo
[May the avisynth installation have somehow gotten corrupted?

As the error is also with virtualdub you can tell that the problem is not tmpgenc :).
Reinstall avisynth and / or divx codec (or try xvid insteed of divx).

Note: this can be due also to a file in the plugin directory that as nothing to do there : a document, a txt file, or may be an avsi script that is corrupted.

gattotimo 11-03-2006 12:08 PM

Quote:

Originally Posted by Dialhot
Note: this can be due also to a file in the plugin directory that as nothing to do there : a document, a txt file, or may be an avsi script that is corrupted.

Ok, maybe we're there! Installing XVid didn't make any change, but then I tried deleting all the files in the plugins dir and now tmpeg accept avs again. So the plugins dir can ONLY have the dlls? What about the lots of other files (.ccp, .h and so on) which usually come with the filters' packages? Are they just for developpers?

EDIT: As you suggested, there was a corrupted file in the plugins dir. I deleted them all and installed just the dlls needed by the script, and everything works :D. Maybe the stupid-questions-time is finally over

Dialhot 11-03-2006 12:36 PM

Quote:

Originally Posted by gattotimo
What about the lots of other files (.ccp, .h and so on) which usually come with the filters' packages? Are they just for developpers?

plugin are often in open source, and the file .c .h .cpp are the source files. In the plugin directory you should have only dll.

Quote:

EDIT: As you suggested, there was a corrupted file in the plugins dir. I deleted them all and installed just the dlls needed by the script, and everything works :D. Maybe the stupid-questions-time is finally over
Don't worry, I had the same problem some weeks ago. You are lucky that I remembered how I solved it :D

gattotimo 11-03-2006 03:19 PM

Ok, I just finished my first encoding with an advanced script, and results seems pretty good to me. I used the half template, with CQ set to 75 and the maximum bitrate raised to 3500. The final file size for a single episode is 344 MB without audio tracks, so the total file size assuming I'll add both ac3 tracks (eng and italian) would be 575, which is a bit larger than needed to put 8 episode in a single dvd-5 disc (dvd-9 are still too expensive, so I shifted my project to 3 dvd-5 for episodes and another one for extras). I'll try lowering the maximum bitrate to 3000, but maybe it'll be enough to convert one of the audio tracks to mp2. BTW I'm not as trained as you are to spot for video artifacts or errors, so I'd like to post some screenshot I took with DGIndex. They're quite large BMP (about an half MB each), should I convert them to jpg with photoshop or is it better to post them "as they are" to prevent photoshop from altering them during the conversion (and this would be the real last stupid question :oops:)?

EDIT: Here are the screenshots.
http://www.digitalfaq.com/archives/error.gif
http://www.digitalfaq.com/archives/i.../2006/11/2.jpg
http://www.digitalfaq.com/archives/error.gif
http://www.digitalfaq.com/archives/i.../2006/11/3.jpg

Dialhot 11-04-2006 12:00 PM

Hard to speak with low res bmp. But no need to see them : 3000 will be too low for the lost episode : tree leaves are some of the most difficult things for MPEG2 codec. I mean that scenes shot in a forest always use a lot of bitrate. And guess what you have in lost ? :).

I suggest you to let the max at 3500, lower the min to 0, and don't use original 5.1 audio. You should use 2.0 MP2 audio at 128 kbit/s.

gattotimo 11-06-2006 04:58 AM

Quote:

Originally Posted by Dialhot
Hard to speak with low res bmp. But no need to see them : 3000 will be too low for the lost episode : tree leaves are some of the most difficult things for MPEG2 codec. I mean that scenes shot in a forest always use a lot of bitrate. And guess what you have in lost ? :).

Yesterday I checked some tree leaves scenes, and you're right: there's some pixelation even with the max bitrate set at 3500 (most of that pixelations in the scene where Kate saves the old farmer from the burning car), so I tried to raise the maximum br to 4000 lowering the min to 0, CQ still set to 75... I had a file which is almost the same size as the previus (just 2 MB bigger), which would allow me to put the first language in AC3 and the second one in MP3, but I still didn't check the results quality-wise since I'm at work right now. I'll post some comparison screenshots from the above scene in the afternoon.

gattotimo 11-06-2006 12:44 PM

I'm right now trying small modification in the script and/or in settings (ie, I shifted LRemoveDust and LimitedSharpenFaster line positions to see what's better) with different encodings of the same source, to post a more accurate screenshot comparison. But I'm noticing the encoding is really slow, about 2,20 hrs for 40 mins of video: I remember reading somewhere in this forum (but I can't remember where :cry: ) there's a trick to improve the encoding speed (something like a "useless" script line). Did I misunderstood or such a way to boost speed do exist? I got a 3Ghz P4 (with HT), so I think Tmpeg should work a bit faster

Dialhot 11-06-2006 12:49 PM

The speed you have is not normal, I have quite the same on a 1.3Ghz P4 :).
The line that you are talking about in in the LRemoveDust function :

Quote:

function LRemoveDust_YV12(clip input, int clmode, int "limit")
{
input=Crop(input,0,0,-0,-0,true)
limit=default(limit,2)
clmode=default(clmode,17)
repmode = 2
clensed = Clense(input)
rep = Repair(clensed, input, mode=repmode)
rg = RemoveGrain(rep, mode=clmode)
return LimitChange(rg, input, limit, limitU=255)
}

gattotimo 11-06-2006 01:21 PM

Quote:

Originally Posted by Dialhot
The speed you have is not normal, I have quite the same on a 1.3Ghz P4 :).

So I remembered right, that's not a regular speed... I'll add that line as soon as my current encoding end. Stay tuned, and thanks as always :wink:

gattotimo 11-06-2006 02:48 PM

Hi Phil, I added that line in the function and started a new encoding, but things didn't get better... The estimated time for the usual 40 min episode at 720x576 is almost 5 hrs :cry:! Is there any other script optimization I can use? I'll post the script as it is now as well as the functions used:

The script
Import("C:\Programmi\Avisynth 2.5\plugins\LimitedSharpenFaster.avsi")
Import("C:\Programmi\Avisynth 2.5\plugins\LRemoveDust_YV12.avsi")

dgdecode_mpeg2source("E:\Lavoro KVCD\lost.d2v", cpu=4, idct=7)
BicubicResize(720,576,1./3.,1./3.,2,0,716,572)
TDeint(order=1,tryweave=true)
LRemoveDust_YV12(17,1)
LimitedSharpenFaster()
MergeLuma(blur(0.1))
MergeChroma(blur(1.58))

ScriptClip(" nf = YDifferenceToNext()" +chr(13)+ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ).TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

Letterbox(16,16,16,16)

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2
}

ConvertToRGB24()


LimitedSharpenFaster
function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(1 1,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().r emovegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().r emovegrain(11,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrai n(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : mt_makediff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFF FF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(de st_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale

return last
}


LRemoveDust_YV12
function LRemoveDust_YV12(clip input, int clmode, int "limit")
{
input=Crop(input,0,0,-0,-0,true)
limit=default(limit,2)
clmode=default(clmode,17)
repmode = 2
clensed = Clense(input)
rep = Repair(clensed, input, mode=repmode)
rg = RemoveGrain(rep, mode=clmode)
return LimitChange(rg, input, limit, limitU=255)
}

Boulder 11-06-2006 02:52 PM

You can ditch TDeint. Lost should be progressive.

gattotimo 11-06-2006 02:56 PM

Quote:

Originally Posted by Boulder
You can ditch TDeint. Lost should be progressive.

Ok, I'll try that too. Do you think this will improve the encoding speed?

Boulder 11-06-2006 04:08 PM

It definitely should, TDeint isn't the fastest filter around :wink:

Dialhot 11-06-2006 06:14 PM

Quote:

Originally Posted by Boulder
You can ditch TDeint. Lost should be progressive.

I did not understand why but first disc of the box set (1st half of season 2) is interlaced while 2 other discs are progressive.

Beside this, I need 3h per episode on my 1.3 Ghz but I did not use the adaptative script (no line "Scriptclip" in my script). This is the slowest part of the script !

Boulder 11-07-2006 02:48 AM

Could you upload a small sample of the first disc? It would be interesting to see whether it's just field shifted or if there has been some weird NTSC->PAL conversion done again.


All times are GMT -5. The time now is 04:49 PM  —  vBulletin © Jelsoft Enterprises Ltd

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