Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to get this to work and I'm really close, but something still isn't right.

I have a 14 second clip I'm trying to cut out of a longer mp4 video. I got the video to cut to the right place with this command:

ffmpeg -ss 00:05:13.0 -i ~/videos/trim_me.mp4 -vcodec h264 -acodec copy -t 00:00:14.0 ~/videos/trimmed.mp4

If I didn't specify -vcodec it was starting from an "I-Frame" (I guess) and wasn't the right place. The audio is starting from that spot as well, so I tried setting -acodec the same way:

ffmpeg -ss 00:05:13.0 -i ~/videos/trim_me.mp4 -vcodec h264 -acodec aac -ac 2 -ab 225k -ar 48000 -strict -2 -t 00:00:14.0 ~/videos/trimmed.mp4

Which doesn't really help much. Setting -async 1 makes it take longer, and then the audio does match up, but not until 4 seconds into the video. :/

I'd ideally not like to install anything else and have a commandline solution for this.

share|improve this question
up vote 1 down vote accepted

h264 should work as a codec, but usually defaults to libx264. vcodec ideally should be replaced with the non-deprecated c:v.

The working command was

ffmpeg -i ~/videos/trim_me.mp4 -c:v libx264 -c:a aac -ac 2 -b:a 255k -ar 48000 \
-async 1 -strict -2 -y \
-ss 00:05:13.0 -t 00:00:14.0 ~/videos/trimmed.mp4

Moving the -ss flag as an output flag will ensure that the complete video is transcoded but output only starts at the point specified by -ss. Otherwise, when -ss is placed in front of -i, FFmpeg would just seek to the starting point, which might be inaccurate.

Fixing the -vcodec flag, and putting in -async 1 worked, but only if done together.

share|improve this answer
I took the liberty of explaining why it probably didn't work and why the placement of option matters. Note that the async 1 option is deprecated as well and the asyncts option should be used instead. vcodec is also deprecated. In the future, when asking questions about FFmpeg, please include the full, uncut console output as well. This will help us debug your issue. – slhck Oct 8 '12 at 9:13

You must log in to answer this question.

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