I need to trim the just the first 1 or 2 seconds off of a series of FLV recordings of varying, unspecified lengths. I've found plenty of resources for extracting a specified duration from a video (e.g. 30 second clips), but none for continuing to the end of a video.

Both of these attempts just yield a copied version of the video, sans desired trimming:

ffmpeg -ss 2 -vcodec copy -acodec copy -i input.flv output.flv

ffmpeg -ss 2 -t 120 -vcodec copy -acodec copy -i input.flv output.flv

The thought on the second one was: perhaps if I specified a length beyond what was possible, it'd just go to the end. No dice.

I know it's not an issue with codecs or using seconds instead of timecode since the following worked a charm:

ffmpeg -ss 2 -t 5 -vcodec copy -acodec copy -i input.flv output.flv

Any other ideas? I'm open to using other (Windows-based) command line tools, however am strongly favoring ffmpeg since I'm already using it for thumbnail creation and am familiar with it.

If it helps, my videos will all be under 2 minutes.

UPDATE:

I've switched over to using Mencoder (http://www.mplayerhq.hu/) since it looks like ffmpeg won't accomplish this without some additional hackery.

The Mencoder syntax to accomplish what I set out to do is:

mencoder.exe -ss 2 -oac copy -ovc copy input.flv -o output.flv
link|improve this question
feedback

3 Answers

Looks like you'll have to do the math yourself. ffmpeg has some features for getting the length of a video stream. You may have to write a script to parse the output and read the stream length, then use it to extract the desired portion.

link|improve this answer
Unfortunately, after some more digging and feedback through other avenues, it looks like I'll either have to do what you suggest or try another tool (VLC, VirtualDub and mencoder have all been suggested). – marcelebrate Mar 16 '11 at 6:34
feedback
up vote 0 down vote accepted

Turns out this command will trim the video from 2 seconds on, as expected:

ffmpeg -ss 2 -vcodec copy -acodec copy -i input.flv output.flv

The issue was with the keyframe interval in input.flv. It was set to 5 seconds, which yielded 3 seconds worth of black frames at the beginning of the video (5 - 2 = 3). I've since changed my keyframe interval to 1 second, though 2 seconds would probably also yield the desired results in my case.

link|improve this answer
feedback

Try:

ffmpeg -i input.flv -ss 2 -vcodec copy -acodec copy output.flv

I think the input parameter is supposed to be first.

link|improve this answer
Thanks for the response. The parameter ordering I used above provides the same result, so I don't think it's the order. After giving up on ffmpeg, my keyframe interval was causing issues with other tools. After revisiting this just now, it was the keyframe interval after all. It was set to 5 seconds before and I've since set it to 1 second. At 5 seconds, both your command and the ones I tried above yielded black space at the beginning (3 seconds worth, unsurprisingly). At 1 second, it works as expected. – marcelebrate Apr 12 '11 at 17:05
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.