[Cin] Cutting mkv causes video to stop at cut points
Andrea paz
gamberucci.andrea at gmail.com
Sat Nov 26 11:11:40 CET 2022
> Andrea,
> Do you think we should try to add some of Igor's information to the manual? MKV seems to have a lot of differences that cause issues because it is an Open Standard and can be used anyway (as opposed to MP4 which is not for free commerical use).
@Phyllis
OK, I try to write a draft. Can you all check if it is correct or can
be improved?
@IgorBeg
How do you see the I-frames of a media? I have only found one ffprobe
command, but it is not convenient to use. Do you have any resource to
elaborate on the problems of seeking mkv?
-------------- next part --------------
Note on Matroska (mkv) container
Matroska is a universal container, modern and sophisticated and above all Open Source from which follows development with community input and excellent documentation. Also derived from this container is the Webm container used by Google and Youtube, which use the VP8-9 and AV1 codecs. Use within \CGG{} is therefore recommended, however, one may run into seeking problems during playback. The internal structure of matroskas is sophisticated but requires exact use of internal keyframes (I-frame; B-frame and P-frame) otherwise playback on the timeline may be subject to freeze and drop frames. The mkv container format can be problematic if the source encoding is not done well by the program (i.e., OBS). For an easy but accurate introduction of codecs and how they work see:
https://ottverse.com/i-p-b-frames-idr-keyframes-differences-usecases/
To find out the keyframe type (I, P, B) of our media you can use ffprobe:
ffprobe -v error -hide_banner-of default=noprint_wrappers=0 -print_format flat -select_streams v:0 -show_entries frame=pict_type input.mkv
-v error -hide_banner: serve to hide a blob of information that is useless for our purposes.
-of: is an alias for "-print_format" and is used to be able to use "default=noprint_wrappers=0".
-default=noprint_wrappers=0: is used to be able to show the information from the parsed stream that we need.
-print_format flat: is used to display the result of ffprobe according to a "flat" format (you can choose CSV; Json; xml; etc).
-select_streams v:0: is used to choose the first stream (0) in case there are multiple audio and video streams (tracks, in \CGG{}).
-show_entries: shows the type of data collected by ffprobe that we want to display (there are also types: _streams; _formats; _packets and _frames. They are called "specifiers").
frame=pict_type: within the chosen specifier indicates the data to be displayed; in this case pict_type, that is, the keyframe type (I, P, B) of the frame under consideration.
input.mkv: is the media to be analyzed (it can be any container and code).
We thus obtain a list of all frames in the analyzed media and their type. For example:
frames.frame.0.pict_type="I"
frames.frame.1.pict_type="P"
frames.frame.2.pict_type="B"
frames.frame.3.pict_type="B"
frames.frame.4.pict_type="B"
...
We can now turn to the timeline of \CGG{} to see the frames that give problems in playback. Using a codec of type Long GOP, it is probably the rare I-frames that give the freezes.
To find a solution you can use MKVToolNix (https://mkvtoolnix.download/) to correct and insert new keyframes into the mkv file (matroska talks about "cues data"). It can be done even without new encoding. Or you can use the Transcode tool within \CGG{} because during transcoding new keyframes are created that should correct errors.
More information about the Cin
mailing list