VideoHelp Forum

Try DVDFab and copy Ultra HD Blu-rays and DVDs! Or rip iTunes movies and music! Download free trial !
+ Reply to Thread
Results 1 to 20 of 20
Thread
  1. Hi everyone,

    I'm capturing VHS tapes with Virtualdub (into Loseless HufYuv file). Each tape has multiple events in it, so I have to separate a single big video into multiple smaller videos. I do that with VirtualDub - and because VirtualDub was the only tool I worked with up until now, I also used it to masked overscan noise (basically cropping the bad information on the sides, and applying black boarders around to retain the original resolution. So while saving a single event from a single file - I would have masked it - both on the same run.

    However, this had it flaws, because if the video had 5-6 events, I had to do 6 separated actions, because as far as I know - VirtualDub can only cut a single section (you can't select multiple parts and save them all in one go into multiple video files).

    I'm working with AviSynth now - and this getting more complex, because while I retain the original resolution of the Loseless files, I crop those on the lossy file. So I find myself playing with crop() command multiple times, until I manage to crop the black bars perfectly. I was wondering if perhaps there's a better way to improve this workflow. Maybe a single AviSynth script that Cut a section from Video file, mask it - save the masked results (keeping huffyuv loseless), and then use the save pixel count used for the masking to crop the file.

    Thanks!
    Quote Quote  
  2. You could add chapter markers into the existing video file. That would let you access each section without having to break up the original capture into multiple smaller videos. I think VirtualdubMod can do this. It is basically the same interface you've already learned, so other than downloading it, there isn't any new work or learning involved.

    [edit]I just opened my copy of VirtualdubMod and the Streams --> Video Chapter does what you want. You can add all the chapters at once if you have a file that contains the positions of each chapter you want to add.

    [edit2]More info here:

    How do I put chapters in an avi file?
    Quote Quote  
  3. Thank you! I will be checking this! It doesn't solve all the problems I have because some big events like a trip will be across couple of videos (and then I still need to cut them off and re-attach to a big single video). But I will check how chapters work!

    I also checking the Trim() method in Avisynth and a way to first save HuffYuv file before the mpeg.
    Quote Quote  
  4. Originally Posted by Okiba View Post
    I'm working with AviSynth now - and this getting more complex
    It should be getting easier.
    So I find myself playing with crop() command multiple times, until I manage to crop the black bars perfectly. I was wondering if perhaps there's a better way to improve this workflow.
    Use the Trim command to save out a section to be worked on, Crop to remove the black bars and AddBorders to add back fresh black, perhaps more evenly distributed.

    If you're saying the crop values vary even within the same video, there are ways around that as well.
    Maybe a single AviSynth script that Cut a section from Video file...
    Trim
    ...mask it...
    Crop followed by AddBorders. Or do it in a single step using the LetterBox command.
    ...save the masked results (keeping huffyuv loseless)
    File->Save as Avi (after choosing the HuffYUV codec in Video->Compression). And remember to set Video for Fast recompress when using an AviSynth script.

    ...and then use the save pixel count used for the masking to crop the file.
    I don't know what that means.
    Quote Quote  
  5. Thank you manono. So let's go on the workflow for a second, it might makes more sense:

    I have a long sing HuffYuv Loseless file with 3 events on it.

    - I need to split it into three parts (so as you suggested, Trim(1, 5), Trim (5,10), Trim (11,20)).
    - I want to mask it (so Crop and add borders).

    There is where I started to get confused. I have an .avs script with the above information. I should open it the avs script IN VirtualDub? wouldn't "File->Save as Avi" will save a single file and not three, and don't I need it to use Full Recompose because I'm Cropping/adding bars?

    Then when I have 3 HuffYuv Loseless Avi files - I want use FFMPEG to create x264 version. It means I need to write a complete new script - don't I? because now what runs the script is FFMPEG and not VirtualDub? And this script will Crop the black bars added during masking - so It means I need to know the specific values used in Masking. I wondered if I can do it all in a single script to save information sharing between two scripts.

    Thanks!
    Quote Quote  
  6. Originally Posted by Okiba View Post
    I have an .avs script with the above information. I should open it the avs script IN VirtualDub?
    If you wish. Or VDub2. Or, if it's ready for the final encode, in whatever program you like that accepts AviSynth scripts. I use RipBot264 to make MP4s. VDub2 can also encode for your final format. If there's further work to be done than you might want to make another lossless AVI.
    wouldn't "File->Save as Avi" will save a single file and not three,
    Yes, if a part of the entire video is trimmed off. If you're saying you want to encode all 3 parts at the same time, then create 3 different trimmed AviSynth scripts, open them sequentially in VDub and set up the encode for each, followed by having it encode them one after the other.
    and don't I need it to use Full Recompose because I'm Cropping/adding bars?
    With an AviSynth script, always use Fast recompress in VDub, unless you're also using VDub filters at the same time (why would you?)
    ...because now what runs the script is FFMPEG and not VirtualDub?
    I don't use ffmpeg so someone else can help with that. I know it accepts AviSynth scripts as input.
    And this script will Crop the black bars added during masking...
    I was suggesting cropping away the original black followed by adding it back using AddBorders. The idea is to maintain the original aspect ratio. I thought that's what you wanted, although I could easily be mistaken.
    ...so It means I need to know the specific values used in Masking.
    Yes, of course.
    I wondered if I can do it all in a single script...
    Cropping and adding borders (or using the Letterbox command to do both at the same time)? Yes, of course. It's a simple matter to add multiple filters into an AviSynth script.
    ...to save information sharing between two scripts.
    If creating 3 different scripts you create a template for all three with the Trim, Crop, and AddBorders commands and then edit each of the three to change the values for each. That's how I'd do it anyway.

    I may not be understanding you clearly, though, and perhaps someone else can answer the questions better.
    Quote Quote  
  7. Originally Posted by Okiba View Post
    VirtualDub can only cut a single section (you can't select multiple parts and save them all in one go into multiple video files).
    You can remove all the sections you don't want (mark-in, mark-out, Edit -> Cut, repeat). Then save what's left.
    Quote Quote  
  8. then create 3 different trimmed AviSynth scripts, open them sequentially in VDub and set up the encode for each, followed by having it encode them one after the other.
    That's what I was missing. I know AviSynth support variables. So I can for example:

    Code:
    a = aviSource("E:\a.avi")
    b = aviSource("E:\b.avi")
    c = aviSource("E:\c.avi")
    Or I can use a single file, trim it into multiple instance. However, It seems like the consumers of those AviSynth scripts - FFMPEG, VirtaulDub etc - just process a single video. So It seems that if I want to mainstream all the work to AviSynth (including Cropping, Masking, Triming etc) - I need to have a AviSynth script, per event (if a single file contains many events I want to split into multiple files).

    Feel free to correct me if I'm wrong
    Thanks you both!
    Quote Quote  
  9. To select segments from a single file, all filtered the same, and append the segments:
    Code:
    AviSource("filename.avi") # get a single source
    Filters() # whatever filtering you want
    
    a = Trim(0, 999) # frames 0 to 999 frames
    b = Trim(2000, 2999) # frames 2000-2999
    c = Trim(5000,0) # frames 5000 to the end
    
    a++b++c # append the segments in the order a b c
    To select segments from a single file, filter them differently, appended in a different order:

    Code:
    AviSource("filename.avi") # get a single source
    
    a = Trim(0, 999) # first 100 frames
    b = Trim(2000, 2999) # frames 2000-2999
    c = Trim(5000,0) # frames 5000 to the end
    
    a = a.Filters1() # Filters1 is symbolic for whatever filtering you want for segment 1
    b = b.Filters2() # Filters2 is symbolic for different filtering for segment 2
    c = c.Filters3() # Filters3 is symbolic for different filtering for segment 3
    
    c++b++a # append them in a different order
    If you want to save each segment as a different file you can use use multiple scripts or edit the script to output the segment you want:

    Code:
    AviSource("filename.avi") # get a single source
    
    a = Trim(0, 999) # first 100 frames
    b = Trim(2000, 2999) # frames 2000-2999
    c = Trim(5000,0) # frames 5000 to the end
    
    a = a.Filters1() # Filters1 is symbolic for whatever filtering you want for segment 1
    b = b.Filters2() # Filters2 is symbolic for different filtering for segment 2
    c = c.Filters3() # Filters3 is symbolic for different filtering for segment 3
    
    # select which segment you want to output
    return(b)
    Then open the script in an editor, save the segment. Change the script, re-open it in the editor, save the segment...

    Keep in mind that AviSynth uses the name "last" when you don't specify a stream name. So a sequence like:

    Code:
    AviSource("filename.avi")
    Filters()
    is the equivalent of:

    Code:
    last = AviSource("filename.avi")
    last = Filters(last)
    return(last)
    Quote Quote  
  10. Thank you jagabo. But just to make sure I understand again - you can have a single return per AviSyth script. So I can't return 3 values, and have a single FFMPEG command save 3 separated files? I'll have to use 3 AviSynth scripts.
    Quote Quote  
  11. Originally Posted by Okiba View Post
    Thank you jagabo. But just to make sure I understand again - you can have a single return per AviSyth script. So I can't return 3 values, and have a single FFMPEG command save 3 separated files? I'll have to use 3 AviSynth scripts.
    Yes, a script can only have a single output -- ie, the editor sees the script as a single video. To output separate video files you need multiple scripts. I added a script to the earlier post to help with that.
    Quote Quote  
  12. Thank you for confirming it. I wonder:

    Code:
    a = Trim(0, 999) # first 100 frames
    b = Trim(2000, 2999) # frames 2000-2999
    c = Trim(5000,0) # frames 5000 to the end
    
    return c
    Versus:

    Code:
    c = Trim(5000,0) # frames 5000 to the end
    
    return c
    I wonder if they will take the same time to run? because only the result object being executed? I'll try when home
    Thank you jgabo and manono. This helped me clear couple of things I wasn't clear about!
    Quote Quote  
  13. Originally Posted by Okiba View Post
    Thank you for confirming it. I wonder:

    Code:
    a = Trim(0, 999) # first 100 frames
    b = Trim(2000, 2999) # frames 2000-2999
    c = Trim(5000,0) # frames 5000 to the end
    
    return c
    Versus:

    Code:
    c = Trim(5000,0) # frames 5000 to the end
    
    return c
    I wonder if they will take the same time to run? because only the result object being executed?
    Yes, they will take the same time. AviSynth will see than only c is being used so the a and b segments will not be processed.
    Quote Quote  
  14. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Excuse, the interruption, but I think we're forgetting the changing nature of "Last" in those suggestions.

    Shouldn't the trimming be more like:
    Code:
    source = AviSource("filename.avi") # get a single source
    
    a = Trim(source, 0, 999) # first 100 frames
    b = Trim(source, 2000, 2999) # frames 2000-2999
    c = Trim(source, 5000,0) # frames 5000 to the end
    Otherwise it would keep trying to successively trim, with rolling frame numbers. In this instance, it would error on successive trims, as Last would only have 1000 frames left after the 1st trim.

    Scott
    Quote Quote  
  15. Originally Posted by Cornucopia View Post
    Excuse, the interruption, but I think we're forgetting the changing nature of "Last" in those suggestions.
    That's a really good suggestions.

    I had to learn programming in the 1960s, with paper tape and then, later, cards. With FORTRAN and all those old languages, you had to explicitly declare and type all variables. When implied variables and untyped variables began to appear, it made it easier for really simple programs, but almost always led down paths to puzzling outcomes like what you are pointing out.
    Last edited by johnmeyer; 4th Oct 2020 at 11:37. Reason: typo
    Quote Quote  
  16. Originally Posted by Cornucopia View Post
    Excuse, the interruption, but I think we're forgetting the changing nature of "Last" in those suggestions.

    Shouldn't the trimming be more like:
    Code:
    source = AviSource("filename.avi") # get a single source
    
    a = Trim(source, 0, 999) # first 100 frames
    b = Trim(source, 2000, 2999) # frames 2000-2999
    c = Trim(source, 5000,0) # frames 5000 to the end
    Otherwise it would keep trying to successively trim, with rolling frame numbers. In this instance, it would error on successive trims, as Last would only have 1000 frames left after the 1st trim.
    No. The implicit use of last in my script is identical to the explicit use of source in your script. Neither is changed by the Trim() operation.
    Quote Quote  
  17. Originally Posted by Cornucopia View Post
    Excuse, the interruption, but I think we're forgetting the changing nature of "Last" in those suggestions.

    Shouldn't the trimming be more like:
    Code:
    source = AviSource("filename.avi") # get a single source
    
    a = Trim(source, 0, 999) # first 100 frames
    b = Trim(source, 2000, 2999) # frames 2000-2999
    c = Trim(source, 5000,0) # frames 5000 to the end
    Otherwise it would keep trying to successively trim, with rolling frame numbers. In this instance, it would error on successive trims, as Last would only have 1000 frames left after the 1st trim.

    Scott
    This would keep trying to successively trim

    Code:
    AviSource("filename.avi") # get a single source
    
    Trim(0, 999)
    Trim(2000, 2999)
    Trim(5000, 0)
    but assigning variables doesn't update "Last".
    Quote Quote  
  18. Okiba,
    The CropResize function in my signature has the ability to clean borders, and it also has a cropping preview if that helps, so you could do something like this to preview the cropping for each segment.

    There's three types of cropping preview (CPreview = 1, 2 or 3). The picture below barely needs cropping, but to demonstrate....
    The first two numbers are normally used for resizing, hence being zero, and the next four numbers are the usual cropping.

    Code:
    # GCropResize specifies global arguments for each CropResize instance
    
    GCropResize(CleanBorders=true, CPreview=1)
    
    A = Trim(0,999).CropResize(0,0, 12,4,-8,-2)
    B = Trim(2000,2999).CropResize(0,0, 12,8,-26,-24)
    C = Trim(5000,0).CropResize(0,0, 16,4,-8,-12)
    
    A ++ B ++ C
    If you open the script in VirtualDub, you can use F2 to reload it after you adjust the cropping.

    Image
    [Attachment 55258 - Click to enlarge]


    Once you're happy, remove the CPreview argument and CropResize will add borders for the original resolution while placing the picture in the centre.

    Code:
    GCropResize(CleanBorders=true)
    
    A = Trim(0,999).CropResize(0,0, 12,4,-8,-2)
    B = Trim(2000,2999).CropResize(0,0, 12,8,-26,-24)
    C = Trim(5000,0).CropResize(0,0, 16,4,-8,-12)
    
    A ++ B ++ C
    Image
    [Attachment 55259 - Click to enlarge]


    You could also use auto-cropping, in which case the cropping you specify for each CropResize instance would just be any extra cropping required to remove whatever the auto-cropping missed. When auto-cropping is enabled via the global GCropResize function, the same auto-cropping is applied to the whole video. The GCropResize function automatically creates global variables specifying the video dimensions before auto-cropping, so each CropResize instance can still add the borders required to output the original dimensions.

    Code:
    GCropResize(CleanBorders=true, AutoC=true, CPreview=1)
    
    A = Trim(0,999).CropResize(0,0, 0,0,-0,-0)
    B = Trim(2000,2999).CropResize(0,0, 2,2,-4,-0)
    C = Trim(5000,0).CropResize(0,0, 0,2,-0,-2)
    
    A ++ B ++ C
    Quote Quote  
  19. Ohhh, the preview options looks very cool! Because I don't yet trust Auto-cropping on some videos, this is much more intuitive then trying 20 pixel, see there's still black bar, try 22 pixel etc etc. Thanks!
    Quote Quote  
  20. It also has the advantage of not changing the video dimensions while the preview is enabled, so if you're using Trim() to append segments while cropping them differently, you don't have to worry about Avisynth complaining that the frame sizes don't match. And of course once you disable the preview, borders will be added to each segment for the original dimensions, so they'll still be the same.
    Quote Quote  



Similar Threads