VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 21 of 21
Thread
  1. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    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:

    Code:
    vid2= trim (2485, 3637). TTempSmooth(maxr=7,lthresh=20,cthresh=5, strength=5, interlaced=false)
    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.

    Thanks


    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)
    Quote Quote  
  2. 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)
    Huh? Do you mean to say filtered=vid4? Trim, as used in the bold-faced section, is undefined. I don't know if anything's wrong with the rest of it as I don't understand some of it.
    Quote Quote  
  3. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    I tried to do it with filtered=vid4, and I get a syntax error.

    My original script for that clip only goes as follows:

    Code:
    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)
    How can I incorporate this same script into a trimmed section of my video? Note, my entire video by default is filtered by MCTemporalDenoise. But certain sections (like the one discussed) need additional filters. This one for instance needs flatmasks, because I only wanted TTempSmooth to filter a specific section in that clip, but not the entire thing.
    Quote Quote  
  4. Originally Posted by unclescoob View Post
    How can I incorporate this same script into a trimmed section of my video?
    In my opinion, the best way to filter parts of a video is with the RemapFrames.dll by stickboy, of which ReplaceFramesSimple is a part. You don't need to use Trim at all.

    You get it here:

    http://avisynth.org/stickboy/

    And you use it like this:

    Code:
    BaseClip=Last
    SourceClip=BaseClip
    SourceClip=SourceClip.filter1.filter2.filter3...
    ReplaceFramesSimple(BaseClip,SourceClip,Mappings="[FirstFrame1 LastFrame1] [FirstFrame2 LastFrame2] [FirstFrame3 LastFrame3]")
    You can use it multiple times in a video to filter different parts differently.

    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.
    Quote Quote  
  5. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    "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.


    Code:
    ##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
    Quote Quote  
  6. Originally Posted by unclescoob View Post
    "Return last" results in the entire mask to apply to the rest of the clip, which is not what I want.
    The suggestion was to use 'Return Last' as a test to see where the script is going wrong - to figure out which line is responsible for the error, not to encode with it on. But now that I see the script, I realize the suggestion might not work.

    What happens if you move:
    vid5=trim(901,1000)

    above the part beginning with:

    vid4=trim(501,900)

    If that doesn't help at all, then smarter people than I will have to help out.
    Quote Quote  
  7. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    It worked. How did reversing the order work?
    Quote Quote  
  8. 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...
    Quote Quote  
  9. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Ah, got it. Thanks fellas.
    Quote Quote  
  10. 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
    vid4=trim(501,900)
    Raw=last
    Invert()
    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

    Raw=last
    Invert()
    flatmask(raw, str=100, r=10, luma=true, lth=32, upper=true, show=false)
    Trim(501,900)
    vid4=last

    So now "vid4" refers to that flatmasked 501-900 section
    Quote Quote  
  11. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Originally Posted by poisondeathray View Post
    This section actually doesn't do what you think it does, it's applied to the whole video

    #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)

    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
    In other words, "Last" means the last video segment rendered to the script. In this case, MPEG2Source(). Therefore, the mask will be applied to the entire video, ignoring trimmed sections. Am I on track here?


    Originally Posted by poisondeathray View Post
    This section could be re-written

    Raw=last
    Invert()
    flatmask(raw, str=100, r=10, luma=true, lth=32, upper=true, show=false)
    Trim(501,900)
    vid4=last

    So now "vid4" refers to that flatmasked 501-900 section
    This works well, except now, if I add additional trimmed sections following the masked trimmed section, it won't show up. My clip will end at frame 900. Manono's suggestion of reversing the order: adding video 5,6,7, etc after video 3 and leaving video 4 on the last line (hence "last" in the function) worked.
    Quote Quote  
  12. Originally Posted by unclescoob View Post
    Originally Posted by poisondeathray View Post
    This section actually doesn't do what you think it does, it's applied to the whole video

    #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)

    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
    In other words, "Last" means the last video segment rendered to the script. In this case, MPEG2Source(). Therefore, the mask will be applied to the entire video, ignoring trimmed sections. Am I on track here?
    Yes, the MPEG2Source() with the IVTC and crop . Not the original unfiltered video



    Originally Posted by poisondeathray View Post
    This section could be re-written

    Raw=last
    Invert()
    flatmask(raw, str=100, r=10, luma=true, lth=32, upper=true, show=false)
    Trim(501,900)
    vid4=last

    So now "vid4" refers to that flatmasked 501-900 section
    This works well, except now, if I add additional trimmed sections following the masked trimmed section, it won't show up. My clip will end at frame 900. Manono's suggestion of reversing the order: adding video 5,6,7, etc after video 3 and leaving video 4 on the last line (hence "last" in the function) worked.
    I was trying to explain (poorly) that you should use descriptors for each section . If you add additional trimmed sections, don't use implicit "last" ; use whatever name you assigned to the MPEG2Souce , IVTC, crop section . Otherwise, you have to place all your unfiltered sections before all your masked sections in script order or you will run into the same problems as before (because "last" will no longer refer to the MPEG2Source) . When you begin to apply different filters to different sections (more complex scripts), it will be difficult to keep track

    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
    Quote Quote  
  13. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    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?
    Quote Quote  
  14. Originally Posted by unclescoob View Post
    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?

    Yes

    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
    Quote Quote  
  15. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    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)
    Quote Quote  
  16. Originally Posted by unclescoob View Post
    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)
    Quote Quote  
  17. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Thanks. And thanks for the trim info.
    Quote Quote  
  18. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    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?

    Thanks
    Quote Quote  
  19. Originally Posted by unclescoob View Post
    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


    MPEG2Source()
    TFM
    TDecimate
    Crop
    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


    Main
    filter1()
    filter2()
    Trim(0,100)
    a=last

    #Now "a" refers to "Main" with filter1 and filter2 applied . It's been cut to 0-100 .


    Main
    filter3()
    filter4()
    Trim(101,200)
    b=last

    #Now "b" refers to "Main" with filter3 and filter 4 applied. It's been cut to frames 101-200

    a++b


    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)
    Quote Quote  
  20. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Beautiful. I'll give this a shot this afternoon.

    Thanks!!
    Quote Quote  
  21. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    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.
    Quote Quote  



Similar Threads