User Tools

Site Tools


video:keyframes

Use Shift-[\] to open the MMP config dialog
Use Ctrl-[H] to open a [H]elp panel

video keyframes

A powerful new feature in v5.0.0 (keyframes) helps you decide where to make cuts

controls in brief

In the Audio & Video Timeline Editor

Control Action
[F] toggle 1) the use of video Key[F]rames on and off

KeyFrames

During video editing, you can turn on keyframes to help you decide where to begin a segment so that it only includes the portion of the video that you want.

keyframes have no bearing on the end of segments. MMP and FFmpeg will always work to ensure that your exported segment is at least your desired length and includes the n-seconds of content that you want


To enable the keyframes functionality, you will need to unpack ffprobe.exe from the release .zip file and include it in the same folder as the MMP executable.

It's also recommended that you unpack the most recently supplied versions of ffmpeg.exe, libmpv-2.dll and MediaInfo.dll

With the Audio & Video Timeline Editor open, you can toggle keyframes on and off with the [F]rames key.

ffprobe

When you turn on keyframes, MMP will run ffprobe in the background and create a .key file listing all the keyframes in the video.

Depending on the video, this process can take anywhere from a couple of seconds to a few minutes.



For example, a 10-minute, 4K, 60fps animation, encoded using the VP9 codec, could have roughly 60 keyframes every second. That's over 38,000 keyframes that ffprobe needs to identify and list. That will take some time. Especially given the processing required for the VP9 codec. Even on a high-spec development machine it takes 6-7 minutes.

On the other hand, a 110-minute, 720×480, 23.976fps, .mp4 video might have a keyframe every 10 seconds. That's only about 1,300 keyframes and only takes a couple of seconds to produce.



When ffprobe has finished creating the .key file for your video, MMP will report keyframes on in the notification area (bottom right corner) and the progress bar will briefly flash a fluorescent purply color.

You don't have to wait for ffprobe to finish. You can start your editing and make use of the keyframes when they become available.

FFmpeg cuts

When MMP instructs FFmpeg to make a cut and extract a segment of the video, FFmpeg has to find a suitable seek point at which to make the cut.
The seek point will always be before your desired cut point. The question is, how far before?

As a general principle, FFmpeg will be able to determine a seek point somewhere between the previous keyframe and your desired cut point and will try to make it as close to your desired cut point as the video content (and the codec used to encode the video) will allow:

  • Sometimes, FFmpeg is able to make the cut exactly where you want it.
  • Other times, FFmpeg must include a few seconds prior to your desired cut point.
  • On other occasions, FFmpeg will be forced to go all the way back to the previous keyframe, wherever that may be.

Prior to v2.1, FFmpeg always used keyframes as its seek points.
Since v2.1, FFmpeg has greatly improved its ability to create a seek point nearer to the desired location away from the previous keyframe.
MMP currently ships with FFmpeg v7.1.1.

The good news is that if you desire a segment that is 10 seconds long from a particular point, MMP and FFmpeg will always deliver at least that.
Given the above caveats though, FFmpeg might have to include additional content to give you your desired 10 seconds.

If you are only making rough cuts and you aren't concerned with how the different segments stitch together and transition between segments in the edited video, then you can be fairly confident that your defined segments will be in the exported video. However, always check your edits: both MMP and FFmpeg will be using whole-second-based approximations.

Color Coded Vertical Cursor

If you want to make somewhat more refined cuts so that they stitch together and transition nicely, the keyframe functionality can help.

With keyframes turned on and the .key file ready, MMP will identify the location of each keyframe using the color of the Audio & Video Timeline Editor vertical cursor.

The color of the vertical cursor answers the following question:
If I create a new segment here, what's the likelihood of prior content (prior to this exact point) being included in the exported segment?

Color coding has no bearing on the end of segments. MMP and FFmpeg will always work to ensure that your exported segment is at least your desired length and includes the n-seconds of content that you want

As the video plays, or as you drag the vertical cursor along the Timeline, or you move the cursor forwards/backwards by 1 second using [Tab] and Ctrl-[Tab], the color will change to match the keyframe locations.

white cursor


This is the vertical cursor's default color. White indicates that the previous keyframe is more than 1.0 seconds prior to this point.
There is a strong likelihood that FFmpeg will have to include content prior to this point in order to ensure that the part of the video you're looking at will be included in your exported segment.

In a 4K animation with 60 keyframes per second, you are unlikely to ever see a white cursor. With such a video, turning on keyframes is largely pointless (except maybe to confirm that they're not required), as the start of every segment you create will be so close to the prior keyframe that exported segments will likely start exactly where you want them to. (see the purple cursor below)

yellow cursor


A yellow cursor indicates that the current point in the video is between 0.5 seconds and 1.0 seconds after the previous keyframe. Depending on how FFmpeg is able to determine its seek point you might get away with creating the segment here and fmpeg might not have to include prior content in order to make the cut at this point. You will need to check the exported segment to see what FFmpeg has done, hence the yellow “warning”.

purple cursor


A purple cursor shows that this point in the video is less than 0.5 seconds after the most recent keyframe. This is the optimum point at which to create a segment if you want a clean cut - the “purple patch”, if you will.

In a 4K animation with 60 keyframes per second, you will likely only ever see a purple cursor. The distances between most keyframes will only be measured in 100ths of a second, maybe 0.01 to 0.02 seconds. Not enough for even a yellow cursor. This means that wherever you want to start a segment is likely to be almost the exact point FFmpeg is able to determine its seek point. The resulting n-seconds of exported footage will match almost exactly with your defined segment, maybe give or take an intermediate frame or two.

Of course, it's also entirely possible, especially if it's not a particularly long video, that if the keyframes are spaced out, e.g. 8-10 seconds apart, that you might not see a single yellow or purple cursor because of the rounding to the nearest second that's occurring. In these cases, even though you're forced to make only rough-cut edits, you can at least be confident that the point in the video you're looking at will be included in the exported video if you create a new segment at that point because the nearest keyframe must be at least 1 second prior.

Skip Excluded Segments

Using keyframes to determine the start of your segments will make using Ctrl-[S] to skip excluded segments during playback an even more accurate representation of how the exported video will play.

Estimated Export Time

Using keyframes and starting segments at purple points will also mean that the estimated length of your exported video (shown in the bottom right corner of the Segments & Streams Panel) will very closely match the length of the video that FFmpeg creates, often exactly.



See the topic Video Editing Example showing how using keyframes can make a difference to your editing and how FFmpeg determines its seek points when you dont

1)
toggle: press once to set; press again to unset
video/keyframes.txt · Last modified: