Use Shift-[\]
to open the MMP
config dialog
Use Ctrl-[H]
to open a [H]elp panel
This article demonstrates the difference between using or not using keyframes (introduced in v5.0.0
) to set the start of your segments and the different decisions FFmpeg
has to therefore make to determine the cut points.
You can download the entire ready-made video editing project here (23MB): talkinghead.zip
MMP
Audio & Video Timeline Editor
using Ctrl-[E]
[F]
MMP
will report keyframes on
in the notification area (bottom right corner) and the progress bar will briefly flash fluorescent purple to indicate that keyframes are now on.
You can now follow along with this article.
Our example video to be edited 1) features Ilan Sredni of Palindrome Consulting:
In the Audio & Video Timeline Editor
and the accompanying Segments & Streams Panel
you will see that ten segments have been created at various points along the Timeline
and that five of the segments (those without the trashcan icon) will be included in the Export
.
You will also notice that in the bottom right corner of the Segments & Streams Panel
it is estimated that the resulting video will be approximately 32 seconds long.
For most of this example editing session we won't be particularly concerned with the finished video; we are more interested in what FFmpeg
is going to do to make our desired cuts and produce the five exported segments, included in the zip file.
With keyframes turned on, when you play the video or drag the vertical cursor to the start of segment 2 (or use [Tab]
to move the cursor and the playback forward one second at a time to the start of segment 2), the vertical cursor immediately changes color depending on the proximity of the underlying prior keyframe nearest to that point (for a detailed explanation of the vertical cursor's keyframe color coding, see keyframes)
In this case, for the start of segment 2, the cursor changes to yellow. This indicates that the nearest prior keyframe is between 0.5 seconds and 1.0 seconds before the point in the video that we're looking at.
Yellow indicates that we might get away with starting the segment here, but it also warns that we might not. It all depends on how close prior to that location FFmpeg
is able to set its seek point
.
As you can see, in this particular case, we were successful - the 3-second segment we created almost exactly matches what was exported:
In actual fact, FFmpeg
has made the cut just prior to the start of segment 2, probably on the proximate keyframe indicated by the yellow cursor, which conveniently includes the start of the sentence, “At Palindrome Consulting…”.
As it turns out, that's what we want. In other cases it might not be so convenient and we might actually pick up a syllable or two from the end of the previous sentence.
If you skip back a couple of seconds (Ctrl-[Tab]
x 2) and start playback (right-click on the video), you'll see that “At Palindrome Consulting…” starts a fraction before the start of Segment 2.
Positioning the cursor at the start of Segment 3 the vertical cursor changes to a fluorescent purply color indicating the nearest prior key frame is less than 0.5 seconds before this point in the video. This tells us that ffmpeg
is likely to be able to make the cut exactly where we want it, clipping the sentence, “Just like nature, not all clouds are created equal.”
This turns out to be spot on, and the 3-second exported segment plays exactly as it does in the Timeline Editor
.
If you want clean cuts like this throughout, use the “purple patch” keyframes to define the start of your segments.
This will also increase the accuracy of the estimated duration of the final video shown in the bottom right corner of the Segments & Streams Panel
.
Furthermore, if you then use Ctrl-[S]
to skip excluded segments during playback of the Timeline
, what gets played will more accurately correspond to the final video created by FFmpeg
.
Normally, you wouldn't have two adjacent included segments like we have here with Segments 2 and 3. Depending on where FFmpeg
makes the cut for each segment you can end up with repeated frames as the end of one segment overlaps with the beginning of the next. Typically, you would merge adjacent included segments: [M]
to [M]erge the selected segment with the one to its right; [N]
to [N]erge the selected segment with the one to its left.
However, in our example we're actually ok because FFmpeg
was able to start segment 3 on a purple keyframe. If you Export
the video you'll see that there's a clean break between segments 2 and 3, and no overlap.
The start of Segment 5 shows a white vertical cursor. This is the worst place to start for clean edits (for rough edits it's perfectly fine).
A white cursor says the most recent keyframe is more than a second prior to this point in the video.
According to the Timeline
we've clipped the ~7-second phrase, “We've seen businesses try to adopt cloud solutions, that don't line up with their needs and goals…”.
However, this is what FFmpeg
created:
We actually have a 12-second (it's actually nearly 12.5 seconds) exported segment that starts a whole five seconds before where we defined the start of our segment.
So…what's occurring?2)
Firstly, it's important to understand that timings in the Audio & Video Timeline Editor
are very good but they're also approximate. To keep things straightforward, MMP
rounds all audio and video timestamps up or down to the nearest whole second. Using the fractional parts of the available timings (which are recorded to six decimal places) would have added a whole level of complexity to MMP
and to the Audio & Video Timeline Editor
that simply isn't justified for a general-purpose media player and a “rough cut” editor.
Bearing that in mind, if you examine the .key
file, you will see that there are keyframes at 26.707667s and at 32.041000s.
So, it's easy to see what has happened: allowing for the rounding down to 32s, our nearest keyframe is not the one at 32.041000s but the previous one at 26.707667s, 5 seconds earlier.
In this case, FFmpeg
has not been able to make the cut any closer to our 32s mark and has gone right the way back to the previous keyframe at 26.707667s.
And because MMP
and FFmpeg
work together to make sure the segment will be at least our desired length of 7 seconds from our desired starting point, we've got the whole of our desired 7 seconds from the starting point we set plus the prior 5 seconds since the previous keyframe, making a total of [just over] 12 seconds.
If you bump the cursor ([Tab]
) to the 33s mark, the cursor changes to yellow because the keyframe at 32.041000s is now within range.
The solution is to actually start segment 5 at 33s so that, in this case, FFmpeg
will only go back to the keyframe at 32.041000s.
This is easy:
Timeline
or in the Segments & Streams Panel
[L]
to [L]engthen the excluded Segment 4 by 1 secondExport
the Timeline
talkinghead.seg05.mp4
in a new copy of MMP
(simply open the segment from your file explorer software as normal)
This has corrected the problem:
We've still ended up with slightly more than the current 6s duration for Segment 5, but that's ok as we've now successfully clipped the phrase, “We've seen businesses try to adopt cloud solutions, that don't line up with their needs and goals…” without the preceding 5 seconds we originally had.
As with Segment 2, Segment 7 starts on a purple keyframe; the exported segment is very slightly (but acceptably so) over our desired duration of 6s, and the exported segment very closely matches what the Timeline
plays: “The cloud takes some of your existing IT infrastructure and eliminates it from your office”:
Positioning the cursor at the start of Segment 9 changes it to yellow, indicating that the keyframe is just prior to this location, so our exported segment will probably also start a fraction early: somewhere between 0.5 and 1.0 seconds early.
In the Timeline
, Segment 9 starts with the words, “Your email server…”.
The exported segment starts a fraction before with, “For example, your email server…“
With this particular video, with the way it's been encoded, we are stuck with including, “For example…” as that's from the keyframe at 48.082667s.
The next keyframe isn't until 53.374333s, and the way FFmpeg
is having to decide on seek points
for this particular video, it isn't going to be able to make a cut between the two keyframes.
With other videos, FFmpeg
can certainly make cuts at places between keyframes. In fact, getting FFmpeg
to re-encode this video might allow us to eliminate the “For example…”.
But that is beyond the scope of this particular article.
MMP: Minimalist Media Player
is an excellent and powerful all-in-one audio & video media player and Image & Thumbnail Browser
.
The audio and video editing capabilities are very powerful despite not providing the non-linear, frame-by-frame editing present in high-end editing software.
As has been demonstrated by the above examples, some very fine editing can be achieved using the Audio & Video Timeline Editor
in conjunction with FFmpeg
's powerful toolset.
On top of that, exporting your edits to a new video is fast and lossless - no re-encoding of the video takes place.
This is something that high-end software doesn't provide, unfortunately - they always re-encode the video taking up your valuable time and potentially reducing the picture quality.
With MMP
, the quality of your edited video exactly matches that of your original video: FFmpeg
simply does a copy/paste from the original to your edited version.
Nice!