How to trim a video with frame precision using FFmpeg?

How to trim a video with frame precision using FFmpeg?

I need to trim videos with a precise end frame, however, ffmpeg seems to cut the video at the nearest first key-frame. So I don’t have enough control over the ending frame. I try to insert key-frame before trimming, but it doesn’t work. These are my command lines: What’s wrong with my command line ? Thanks for your answer

How long is a 15 second cut in FFmpeg?

This will produce a 15 second cut from 0:45 to 1:00. This is because when -ss is given as an output option, the discarded time is still included in the total time read from the input, which -t uses to know when to stop.

Why is the discarded time included in FFmpeg?

This is because when -ss is given as an output option, the discarded time is still included in the total time read from the input, which -t uses to know when to stop. Whereas if -ss is given as an input option, the start time is seeked and not counted, which is where the confusion comes from.

When to use re-encoding or copy in FFmpeg?

Re-encoding is the default if you do not specify copy. For example: When re-encoding you may also wish to include additional quality-related options or a particular AAC encoder. For details, see ffmpeg’s x264 Encoding Guide for video and AAC Encoding Guide for audio. Also, the -t option specifies a duration, not an end time.

How often can you stop a video in FFmpeg?

If there are 30 frames per second in the video, you can only stop after one of those frames. That means your options are only every 1/30th of a second roughly. If the format is group of pictures based it may be limited when it can end as well depending on the formats ability to end a group of pictures early.

Why are group of pictures used in FFmpeg?

If the format is group of pictures based it may be limited when it can end as well depending on the formats ability to end a group of pictures early. (A group of pictures is used in formats where some frames are stored as changes from other related frames rather than full images.)

What’s the best way to start and end FFmpeg?

To start at 3s and end at 8s use -t 5. If you are using a current version of ffmpeg you can also replace -t with -to in the above command to end at the specified time. Try using this. It is the fastest and best ffmpeg-way I have figure it out:

Where is the SS option in ffmpeg command line?

Here is my ffmpeg command line : I’m aware that the position of the -ss option in the command line matters: here, it is supposed to give me all the accuracy FFmpeg can offer. I know I’m probably trying to cut my video neither on a I-frame, nor on P- or B-frames.