5

I am having a problem using ffmpeg which is driving me a little mad, so I hope someone can help me out.

I have a 13 MPEG-4 .mp4 video of which I am attempting to trim the first two seconds off using ffmpeg and display in an Android app.

From the numerous tuts online i am excecuting the following on the command line

ffmpeg -i untrimmed_video.mp4 -vcodec copy -ss 2 trimmed_video.mp4

with no luck as it outputs a video of 4-seconds length (i have no idea where its getting 4 from), if i change this to 3 i still get a 4 second video, if i set it to 10 i get unplayable output.

if i move the -ss arg to

ffmpeg -vcodec copy -i untrimmed_video.mp4 -ss 2 trimmed_video.mp4 

i get output the same length as the input, same as if i move to the end.

I have tried lots of variations as orders and nothing seems to work, is this a bug, am i doing something wrong?!

please help!!!

1
  • OK, it seems if i leave out the '-vcodec copy' args it works fine. It give a buffer error but still completes, just move the -ss to before -i and all works fine - finally!!!!
    – Dori
    Jun 28, 2011 at 14:26

2 Answers 2

6

I am currently using this command to trim video,

ffmpeg -ss 00:00:00 -t 00:00:04 -i inputFile.mp4 -async 1 -vcodec copy -acodec copy outputFile.mp4

-ss is where it starts the trim, -t is the length of the trim. The above would take the first 4 seconds. The order seems to be important as I've had issues with the audio syncing and had to play with it to get it right.

Source: http://blog.ahfr.org/2008/08/fuckin-ffmpeg.html

2

As you seem to have discovered, order of command line arguments can matter with some programs - this seems to have been such a case. Another option for this would have been to use mencoder with similar command line options, as it too, can do this.

So, for future users wondering about this same question, please confirm that the command that worked for you is:

ffmpeg -ss 2 -i untrimmed_video.mp4 -vcodec copy trimmed_video.mp4 

For Ubuntu users, I've found the gui tool "pitivi" to be really really really nice for editing videos graphically. You have to install it from the Software Centre (or via apt-get). It's fairly reminiscent of iMovie HD, to me anyway. So that's a fairly easy option for cropping videos too, though you'll really want to use ffmpeg if you figure out the correct commands and want to be fast about it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .