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?
+ Reply to Thread
Results 1 to 7 of 7
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 Selurusers currently on my ignore list: deadrats, Stears555
Here's a batch file that uses ffmpeg to trim by frame numbers:
@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
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.
This is awsome Jagabo. Thanks!
@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:
[Attachment 57986 - Click to enlarge]
Frame 0 from the cut video:
[Attachment 57987 - Click to enlarge]
Frame 250 from original:
[Attachment 57988 - Click to enlarge]
Ahhhh. Very clear explanation as your usual . It
make perfect sense now. Great explanation. Thanks.