Log in

View Full Version : Trim N number of frames from end of file?


Lyris
16th April 2013, 14:11
I feel dumb for asking this because I thought it'd be straightforward, but I can't find this anywhere or figure it out.

Say I have 5 movie files and I want to remove the last 100 frames from each with a TRIM() command without calculating the frame numbers myself - how do I do this?

I'd have thought trim(0,-100) would have done it, but that just returns frames 0-100. What am I missing?

Groucho2004
16th April 2013, 14:21
I feel dumb for asking this because I thought it'd be straightforward, but I can't find this anywhere or figure it out.

Say I have 5 movie files and I want to remove the last 100 frames from each with a TRIM() command without calculating the frame numbers myself - how do I do this?

I'd have thought trim(0,-100) would have done it, but that just returns frames 0-100. What am I missing?

Something like Trim(0, FrameCount() - n) should work.

wonkey_monkey
16th April 2013, 14:23
What you need is:

trim(0,framecount-101) # may go whacky if framecount is less than 102

framecount is a property of the implicit last clip so for other uses you may need something like:

a.trim(0,a.framecount-101)

I find trim to have a pretty annoying syntax, as both numbers are inclusive - so trim(0,100) returns 101 frames, not 100 frames. Maybe I'm just used to VirtualDub, where setting an end point exludes the frame you're on. Negative numbers passed to trim are treated as frame counts, not as offsets from the end.

David

Lyris
16th April 2013, 15:37
Thanks! Knew I was missing something obvious!

StainlessS
17th April 2013, 05:02
Yeh, actually trim(0,(FrameCount-1)-100)

FrameCount-1 is the last frame, I think trim is very flexible, although is sometimes annoying when it dont work exactly how you would like.