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

When trimming a WMV file using the following syntax:

ffmpeg -i 'INPUTFILE.wmv' -acodec copy -vcodec copy -ss 00:00:45 -t 00:00:15 'OUTPUTFILE.wmv'

One frame of the OUTPUTFILE.wmv file is displayed for about the first second or two (during which time the sound plays normally), and then playback resumes. The "frozen frame" that is displayed is the one on which motion actually begins (not the one 1-2 seconds preceding it) -- that is, there is no "jump" as it goes from the frozen frame to the working video. Instead, it's like I'm un-pausing the video.

Even if I bump the length of the output clip up to one minute long, it still displays it for about a second (so it's not a proportion of the total length of the video).

What is causing this, and how can I fix it?

share|improve this question

The problem is you are just copying from one file to another. Unless you start exactly on one of the key-frames there will be a delay until it reaches a keyframe.

A keyframe is a frame that contains enough data by itself to render the whole frame. Frames in between these keyframes are progressive and only contain (in effect) the changes from the frame before.¹

If you want to avoid this pause then you will need to decode and re-encode each frame individually so that the first frame of the output file is a keyframe.

The sound frames don't suffer from this kind of problem, which is why the sound plays but the video doesn't.

¹ It's actually a lot more complex than this, but this is close enough for now.

share|improve this answer
I get what you're saying -- that is a very helpful explanation, thanks. Can you please explain a little more what you mean by the "need to decode and re-encode each frame individually?" – Doofus Magoo Apr 19 '11 at 19:26
Instead of -vcodec copy you would need to specify something like -vcodec wmv or similar. Not sure off hand what the actual codec would need to be. You may also need to specify such things as bitrates and such for the encoding. – Majenko Apr 19 '11 at 19:28
Ok, thanks! I think you've got me on the right track ("keyframe" or "GOP" was the magic term that's opened up a bunch of relevant Google results). My syntax now looks like "ffmpeg -i 'INPUTFILE.wmv' -b 1636k -acodec wmav2 -vcodec wmv2 -ss 00:00:45 -t 00:00:15 'OUTPUTFILE.wmv" – Doofus Magoo Apr 19 '11 at 19:57

You must log in to answer this question.

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