VideoHelp Forum


Try StreamFab All-in-One and rip streaming video! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hello All,

    I have a number of 1-2 hour AVI files which I would like to segment. The content is NTSC, 29.97. It is compressed as YUY2, 720x480. I use lossless video compression "UtVideo YUV422 BT.601 VCM".

    For each file, I have identified a list of intervals that I would like to keep, i.e., [f_1,f_2], [f_3, f_4], ..., [f_(n-1), f_n], where each f_i is a frame number. The intervals are overlapping but are not necessarily contiguous (there is some content that I don't need).

    I would like to create a separate file for each one of the segments. I know how to do it one at a time using VirtualDub but it is very time consuming since I have many scenes oer take I would like to segment. What is the best way to accomplish this?

    Thanks
    crbd98
    Quote Quote  
  2. If you know a bit about programming/scripting you could:
    a. read up on Virtual Dubs Scripting language
    b. write a program/script in another script that creates a script for Virtual Dub based on your list of frame intervals
    c. progress the Virtual Dub script
    One could also write a script which uses ffmpeg to split the file.

    You could also check if "Cut Assistant", "Lossless-cut" or a similar tools support importing a cut list and then convert your frame list into such a cut list.

    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Here's a batch file that uses ffmpeg to trim by frame numbers:

    Code:
    @echo off
    
    SET /P start=Enter starting frame number: 
    SET /P end=Enter ending frame number: 
    
    set/A startms=%start%*1001/30
    set/A endms=(%end%+1)*1001/30
    
    ffmpeg.exe -y -i "%~dpnx1" -ss %startms%ms -to %endms%ms -c copy "%~dpn1 (%start%-%end%).avi"
    
    pause
    Drag/drop a video file onto the batch file. It will ask for a starting frame number, then and ending frame number. The segment will be trimmed out and saved as a new file. The output will include the starting and ending frame numbers in the name. For example, if the source name is "My Video.avi", and you trim from frame 100 to 200, the output name will be "My Video (100-200).avi". The video will include both the ending frame (so this example will have 101 frames). If you don't want the ending frame include change the endms calculation to "endms=(%end%+0)*1001/30". It should work fine for UT Video Codec and other all-i-frame codecs.

    If you put the batch file in your "Send To" folder you can right click on a video and select Send To -> Batchname, where Batchname is the name of the batch file.

    Note that, as written, the batch file assumes 29.97 fps (30000/1001). You will need to change it for other frame rates. For example, for 25 fps you would change to "set/A startms=%start%*1000/25", and the same for endms.

    If ffmpeg isn't in your search path you will need to specify the entire path to ffmpeg.exe. For example: "C:\Program Files\ffmpeg\bin\ffmpeg.exe", rather than just "ffmpeg".

    I tried a dozen or so different trims and they were all accurate. But they might occasionally be off by 1 frame at the start or end (due to rounding errors in the conversion from frame numbers to milliseconds in the batch file and milliseconds to frame numbers within ffmpeg).
    Last edited by jagabo; 23rd Mar 2021 at 21:09.
    Quote Quote  
  4. This is awsome Jagabo. Thanks!
    -crbd98
    Quote Quote  
  5. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    @Jagabo... What level FFMpeg are you using? When I try your script on a 250 GOP, it freeze frames with image from frame 250, until the next I frame of original at frame 250. I have found this to be the normal action of every FFMpeg version I have used. Am I doing something wrong?


    Frame 100 from original:
    Image
    [Attachment 57986 - Click to enlarge]


    Frame 0 from the cut video:
    Image
    [Attachment 57987 - Click to enlarge]


    Frame 250 from original:
    Image
    [Attachment 57988 - Click to enlarge]
    Quote Quote  
  6. Originally Posted by Budman1 View Post
    Am I doing something wrong?
    Yes, you're doing something wrong: you're using the batch process on an inter-frame codec. To do that you will have to reencode (you can't use (-c copy"). The OP is using an intra-frame codec, all i-frames, so that's not a problem for him.

    Originally Posted by jagabo View Post
    It should work fine for UT Video Codec and other all-i-frame codecs.
    Quote Quote  
  7. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Ahhhh. Very clear explanation as your usual . It
    make perfect sense now. Great explanation. Thanks.
    Quote Quote  



Similar Threads