Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question

3 Answers 3

up vote 2 down vote accepted

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

ffmpeg -ss 2 -i input.flv -vcodec copy -acodec copy 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.

share|improve this answer
1  
I was having this issue as well. This post did it for me. I bit the bullet and stopped trying to use -vcodec copy -acodec copy for all my editing commands. Re-encoding prevented the black frames from the beginning of my video or not cutting at the right spot (the difference of a second without re-encoding was translating to almost a 5 second difference in the video). So, I ended up replacing -vcodec copy with -vcodec libx264 -crf 0. –  Hendy Oct 25 '13 at 4:54

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.

share|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

Try:

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

I think the input parameter is supposed to be first.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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