59

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
Marcel Ray
  • 1,011

5 Answers5

66

Try:

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

I think the input parameter is supposed to be first.

Gareth
  • 19,080
Dave
  • 818
  • 7
  • 7
31

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

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

UPDATE: Updated ordering of -i and -ss parameters per Dave's answer, which I've accepted for credit.

Marcel Ray
  • 1,011
13

Use -ss and -to before -i like this:

ffmpeg -ss 00:01:10 -to 00:02:10 -i input -c copy output
4

It sounds like there might be additional codec parameters required for video, but this worked to trim the first 5s off an mp3 file for me (similar to Bora Savkars Answer, though his solution output the part I wanted to trim instead of the file I wanted, minus the first 5s)

ffmpeg -ss 00:00:05 -i input -c copy output

https://ffmpeg.org/ffmpeg.html

sote_cire
  • 41
  • 1
0

Using -vcodec copy was also causing me to have a poorly functioning video at the point of the trim.

ffmpeg -i nick.mp4 -ss 52 -vcodec libx264 0 -acodec copy nick4.mp4

Is what I was able to use to accomplish a properly working video trimmed where I wanted it. (Thanks to Karl Wilbur for the hint in one of the comments to an answer)

Anthony
  • 143
  • 1
  • 6