[FFmpeg-user] Inaccurate trimming with re-encoding

cmharwood89 cmharwoo at umich.edu
Tue Aug 6 19:15:46 CEST 2013

@ James,

Thanks for the referral. I checked out the link and I'll probably use the
filter eventually. For the time being, I'm making-do with time-indexed


Wow, thanks for putting together those slides! That looks like a very
helpful solution. I see the value of changing to 1fps, because I could
essentially use time as a dummy variable for frame number, but I don't
understand how that would allow me to trim at non keyframes. 

>From my (limited) understanding, there simply is no way to trim at a P-frame
without decompressing into a raw format first, trimming at the shiny new
keyframe, and then recompressing back into my desired. Right now, I'm having
pretty good results doing it this way. If I change the framerate to 1fps,
it's not going to redistribute keyframes, right? If I choose a cutting
point, say at frame 300, but the nearest I-frame is at 295, then my output
video will be trimmed at 5 frames/5 seconds from the desired cut-point. 

For reference, my input and desired output are:
h264 codec @59.94 fps, 1920x1080 res; AAC audio codec; MP4 container

h264 codec @59.94 fps, 1920x1080 res; NO AUDIO; AVI container

I want the output video to be encoded with no subjectively observable
losses.  Computing time and disk space are not a concern, but video quality
and accurate trimming are absolutely necessary.

My original problem has been solved (by removing the square brackets
surrounding my millisecond count in the -ss argument), but I'm definitely
interested in making my approach smarter- i.e. avoiding a brute-force
complete encoding of the video. I like the speed and losslessness of
container-only manipulation and cutting at keyframes, and I like the
accuracy of a decompress-then-cut approach. My new challenge is finding a
way to combine the two.

View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Inaccurate-trimming-with-re-encoding-tp4660437p4660526.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.

More information about the ffmpeg-user mailing list