My script consists of various trimmed sections, as I am applying different filters to different sections in my video.
So for example, something like this works fine:
But there is a specific section that I am applying flatmasks to, and I'm getting a syntax error. The script below is the one I'm using in that particular section. Please advise.Code:vid2= trim (2485, 3637). TTempSmooth(maxr=7,lthresh=20,cthresh=5, strength=5, interlaced=false)
Code:MPEG2Source(video.d2v) AssumeTFF() TFM() TDecimate(mode=1) Crop(6, 0, -6, -0) ##I am not including vid 1, vid 2, etc. in this example, just the vid I'm having trouble with. ### vid4= trim (5435,5614). filtered=trim. TTempSmooth(maxr=7,lthresh=20,cthresh=5, strength=5, interlaced=false). flatmask(filtered, str=100, r=10, luma=true, lth=32, upper=true, show=false)
+ Reply to Thread
Results 1 to 21 of 21
MPEG2Source(video.d2v) AssumeTFF() TFM() TDecimate(mode=1) Crop(6, 0, -6, -0) ##I am not including vid 1, vid 2, etc. in this example, just the vid I'm having trouble with. ### vid4= trim (5435,5614). filtered=trim. TTempSmooth(maxr=7,lthresh=20,cthresh=5, strength=5, interlaced=false). flatmask(filtered, str=100, r=10, luma=true, lth=32, upper=true, show=false)
I tried to do it with filtered=vid4, and I get a syntax error.
My original script for that clip only goes as follows:
MPEG2Source("video.d2v") TFM() TDecimate(mode=1) filtered=last TTempSmooth(maxr=7,lthresh=20,cthresh=5, strength=5, interlaced=false) flatmask(filtered, str=100, r=10, luma=true, lth=32, upper=true, show=false) McTemporalDenoise(settings="high") Tweak(hue=0.0, sat=0.80, bright=0, cont=1.0, coring=true, sse=false) Import("C:\Program Files\AviSynth 2.5\plugins\fastlinedarkenmod.avs") Fastlinedarkenmod(strength=60)
You get it here:
And you use it like this:
BaseClip=Last SourceClip=BaseClip SourceClip=SourceClip.filter1.filter2.filter3... ReplaceFramesSimple(BaseClip,SourceClip,Mappings="[FirstFrame1 LastFrame1] [FirstFrame2 LastFrame2] [FirstFrame3 LastFrame3]")
That doesn't answer your original question, of course, but one way to figure where it's going wrong when the error message doesn't point to a specific line is to put a 'Return Last' after one line, open it in VDub to check, and then move the 'Return Last' down line-by-line until you come to the offending line.
"Return last" results in the entire mask to apply to the rest of the clip, which is not what I want.
Update: the mask section of my script works, but it applies the mask to the rest of my clip from that point on. That shouldn't happen.
Here is a sample of my script.
##starting the script with the basics--the video with simple IVTC script## MPEG2Source(video.d2v) AssumeTFF() TFM() TDecimate(mode=1) Crop(6, 0, -6, -0) #from frame 0-300- apply no filters# vid1=Trim(0,300) #from frame 301 to frame 400, apply grayscale# vid2=Trim(301,400). Grayscale() #from 401 - 500, back to color (no other filters)# vid3=trim(401,500) #from 501-900 apply the mask# vid4=trim(501,900) Raw=last Invert() flatmask(raw, str=100, r=10, luma=true, lth=32, upper=true, show=false) ##from 901-1000 apply no filters## ###<-------although I trimmed vid5 separately, flatmasks from vid4 is still being applied to this. Why???### vid5=trim(901,1000) vid1 ++vid2 ++vid3 ++vid4 ++vid5
What happens if you move:
above the part beginning with:
If that doesn't help at all, then smarter people than I will have to help out.
It worked. How did reversing the order work?
Because "last" is implied when you don't mention otherwise. It refers to the section previously
Since vid5=trim(901,1000) was preceded by the already filtered vid4 section, that's the new "last" . It no longer applies to the main unfiltered video
If it's more clear, you can label the sections more clearly, which is the main video etc...
Ah, got it. Thanks fellas.
vid5=trim(901,1000) really means vid5=last.trim(901,1000)
I break it out and label everything
So instead of omitting "last" , I use real names and labels. I might use "mainvideo" , or even other names like "a" or "b" , whatever is appropriate because I get confused easily and when you have huge scripts with many sections it gets hectic quickly
This section actually doesn't do what you think it does, it's applied to the whole video
#from 501-900 apply the mask
flatmask(raw, str=100, r=10, luma=true, lth=32, upper=true, show=false)
But raw=last means now you call the IVTCed cropped section "Raw" now (instead of "last). It's not applied to the "vid4" label. So the entire video is inverted and flatmasked because "last" was the IVTCed and cropped main video . And when you use vid5 in the next section, last is implied, so it calls that entire flatmasked video
This section could be re-written
flatmask(raw, str=100, r=10, luma=true, lth=32, upper=true, show=false)
So now "vid4" refers to that flatmasked 501-900 section
If you're only doing this type of masking - using replaceframes, replaceframesimple as suggested above, or clipclop would easier and more elegant solution than using trims
Of course, replaceframes is just a matter of choice for the sake of simplifying the look of your script, right? It doesn't affect the framerate or anything in terms of quality?
But it's faster for writing (fewer keys to type) , and it's easier to organize complex scripts - you can mix & match different sections more easily in much less time (to type) . Think of it as mixing & matching different versions of the video
Note - there are multiple different ways of organizing scripts. You'll eventually find the "style" that you prefer
The danger in not using labels or organizing is "last" or "implicit last" might not refer to what you think it refers to and you get double filtered and unexpected results
Quick question off topic: Is transcoding mpeg2 to h.264 with I and P frames only a better option for quality, IF your goal is to lose as little quality as possible in the transcode process? (I know this should be in a different thread, just hoping it's a simple yes, no, usually yes, usually no)
It's not a simple answer
If you use very low quantizers (very high bitrates) relative to content complexity , then using all I frames will give higher quality . But I frames cost a lot of bitrate (they are encoded separately , and do not derive any information from other frames)
p and b-frames give better temporal compression, but are slighly lower in quality (you normally don't see the difference in normal viewing)
In "normal" bitrate ranges, using a mix of p and b frames will generally give higher quality overall
Some h.264 encoders can encode lossless e.g. x264. Even lossless with p and b frames (long gop lossless), but lossless h.264 isn't supported by most hardware (only software)
Thanks. And thanks for the trim info.
PDR, could you give me a script sample of what you mean? I think the visual will help me alot in conjunction with your explanation. Perhaps you can just re-arrange my script to reflect your explanation?
I'm assuming you mean just broken out? Not replaceframes/replaceframessimple? - because there is an example above of that and many examples in the documentation
Main = last
#Now "main" refers to the entire video IVTCed and cropped. So instead of using "last" or "implied last". You call it by using main with your trimmed sections
#Now "a" refers to "Main" with filter1 and filter2 applied . It's been cut to 0-100 .
#Now "b" refers to "Main" with filter3 and filter 4 applied. It's been cut to frames 101-200
Notice they are always named variables. Everything is spelled out. (You explicitly call "Main" to start so you know exactly what to expect). You don't have to use "a" or "b" . You can use other variable name like "dog" or "cat". Or maybe use something more descriptive for that section like "darksection_filtered". Notice "last" is never implied, or used the way you used it earlier (that's where you can make mistakes if you don't keep track of what "last" really means) . When you use the notation like vid8=trim(x,y) , you don't know video you're referring to, so "last" is implied. But you changed what "last" meant when doing the mask section
This is a tedious way to do , but you're less prone to mistakes . ReplaceFrames or similar functions is the better way to do it in avisynth IMO. They allow you to repeat filters in alternate sections much easier instead of typing everything out multiple times (if you're applying the same set of filters over different sections, and other sets of filters over other sections) . It can be many times faster to do it that way (typing wise, not processing speed)
Beautiful. I'll give this a shot this afternoon.
Worked like a charm. And yeah, I prefer to use trim for now. It may require more typing, but I'm used to it. However, your sample makes my script look alot cleaner, more organized and easier to work with. Thanks again, folks.