[FFmpeg-user] trim silent mp4 to rounded second?

Moritz Barsnick barsnick at gmx.net
Tue Nov 29 14:03:29 EET 2016


On Mon, Nov 28, 2016 at 14:22:28 -0500, Erik Blankinship wrote:
> For example, I want to trim a video to exactly 12 seconds (from 00:00:00.00
> to 12 seconds).

That may be a challenge...

>     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 407 kb/s, 29.86 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)

If the actual frame rate is 29.86 fps, then you video can be either 358
frames long = 11.989 seconds, or 359 frames long = 12.023 seconds. If
the frame rate really happens to be 29.97, that would be 359 = 11.979
or 360 = 12.012. If it's variable bit rate, it may be even different.

Can you check the timestamps of the first and last frames of your cut
output video? ("ffprobe -show_frames ...")

Of course, those numbers I gave you are closer to 12.000 than what you
(seem to) be getting. Perhaps it has something to do with handling of
non-keyframes when using "-c copy", I don't know.

> By finessing the -tparameter I am able to get it right...

How right is right? What do your actual timestamps show?

(Sorry, I'm not of much help yet.)

Cheers,
Moritz


More information about the ffmpeg-user mailing list