Link to home
Start Free TrialLog in
Avatar of kevinvw1
kevinvw1

asked on

ffmpeg accurate timing with video/audio extraction

I am trying to extract very small pieces of a .mp4 file using ffmpeg.

I am using ffmpeg at the command line for this.

I am using win32 static build, build on 3/14/2014.
(Does ffmpeg for linux work better than ffmpeg for windows?)

An example extract command is -
ffmpeg -ss 20.05 -i robert2.mp4 -t 0.1 -c copy output2.mp4

In this example I am trying to start at a position of 20.05 seconds and extract .1 seconds of video.

the problem is that ffmpeg seems to be aligning itself to certain boundaries.

So it doesn't seem to matter whether I tell it to start at 20.0 seconds or 20.5 seconds, it still seems to start at the same point.

I have also tried using frames -
ffmpeg -i robert2.mp4 -ss 14.6 -frames:v 20 output3.mp4

Using frames seems to be very accurate, but the audio and the video don't seem to sync properly.

Does anyone know how to get ffmpeg to give me very accurate small extractions?

I need to go down to < .1 second resolution.  Also, I need the audio to properly extract and sync as well.

Or is there a better command line tool for this?

I am willing to pay for a  tool (within reasonable cost) as long as I can use it at the command line and/or with scripting and as long as it is accurate and efficient.

Thanks, Kevin.
ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevinvw1
kevinvw1

ASKER

Yes!  It was the key frames.  I re-encoded using a key frame interval of 2 -

ffmpeg -i robert2.mp4 -g 2 robert3.mp4

The video went from 2 megs to 14 megs, but now I can accurately edit it on 2 frame intervals which is about 1/15 of second.

Thanks a million!

Kevin.
Glad I could help!