Cutting mkv causes video to stop at cut points
Hi, I notice that cutting mkv video files neem to cause. The video to hang at cutting points, this happens in both cinelerra as the rendered content. <https://streamable.com/tfzw3m> Known issue? -- Stefan
Known issue? I don't know how to answer it though CinGG has always had problems with the mkv container. Some users have many problems others less so. See, for example: https://www.cinelerra-gg.org/bugtracker/view.php?id=137
Try using "mkvtoolnix" to rewrite the keyframes of the file by doing a new encoding. It didn't actually work for me and the problems remained.
On Wednesday, November 23, 2022 10:16:01 PM CET, Andrea paz wrote:
Known issue? I don't know how to answer it though CinGG has always had problems with the mkv container. Some users have many problems others less so. See, for example: https://www.cinelerra-gg.org/bugtracker/view.php?id=137
Try using "mkvtoolnix" to rewrite the keyframes of the file by doing a new encoding. It didn't actually work for me and the problems remained.
So just remux it to mov? -- Stefan
Stefan, Andrea has the best suggestion as I know nothing about mkv. You might try using Settings->Transcode with a Scale of 1 for at least your editing work. This is just an uneducated guess, but as Andrea pointed out in BT #137 seeking may be the problem -- when you use Transcode with a scale of 1 CinGG adds in "keyframes (a different kind of keyframes than what you expect) which make seeking work better. This is discussed in: https://cinelerra-gg.org/download/CinelerraGG_Manual/Transcode.html To quote from that:
The BIGGEST gain from using this is if you have media that is not seekable , that is, you can play it from the beginning but can not move to another spot and have the audio or video play correctly. A video file with no keyframes makes seeking next to impossible, but then a Transcode generally adds these keyframes. This is particularly useful for the mkv container, which often has seek problems.
On Wed, Nov 23, 2022 at 3:07 PM Andrea paz via Cin < [email protected]> wrote:
Yes, try. I use mov or mxf. -- Cin mailing list [email protected] https://lists.cinelerra-gg.org/mailman/listinfo/cin
Stefan as you know MKV file is a container. Could you write here the info about that file using "MediaInfo" or "ffprobe", please? I downloaded the "sample_1280x720_surfing_with_audio.mkv" from https://filesamples.com/formats/mkv and tested on "CinGG-20221031-x86_64-older_distros.AppImage" in UnbuntuStudio_16.04. It seems to work fine, cutting here or there, but it is an mkv container with h264 inside. If/when you have time, could you try it, in your System and Cinelerra-GG? Thanks! IgorBeg
On Thursday, November 24, 2022 9:31:28 AM CET, Igor BEGHETTO via Cin wrote:
Stefan as you know MKV file is a container. Could you write here the info about that file using "MediaInfo" or "ffprobe", please?
Input #0, matroska,webm, from '2022-11-23 12-58-10.mkv': Metadata: ENCODER : Lavf58.76.100 Duration: 00:04:30.06, start: 0.000000, bitrate: 2653 kb/s Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuvj444p(pc, bt709, progressive), 1920x1080, 30.30 fps, 30 tbr, 1k tbn (default) Metadata: DURATION : 00:04:29.370000000 Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default) Metadata: DURATION : 00:04:30.057000000 This is the output of OBS Studio. -- Stefan
From the mkv documentation (https://matroska.org/technical/diagram.html):
"The Matroska EBML Schema defines eight Top Level Elements: SeekHead ((#seekhead)), Info ((#info)), Tracks ((#track-flags)), Chapters ((#chapters)), Cluster ((#block-structure)), Cues ((#cues)), Attachments ((#attachments-1)), and Tags ((#tags)). The SeekHead Element (also known as MetaSeek) contains an index of Top Level Elements locations within the Segment. Use of the SeekHead Element is RECOMMENDED. Without a SeekHead Element, a Matroska parser would have to search the entire file to find all of the other Top Level Elements. This is due to Matroska’s flexible ordering requirements; for instance, it is acceptable for the Chapters Element to be stored after the Cluster Elements." And this, too: "The Cues Element is used to seek when playing back a file by providing a temporal index for some of the Tracks. It is similar to the SeekHead Element, but used for seeking to a specific time when playing back the file. It is possible to seek without this element, but it is much more difficult because a Matroska Reader would have to ‘hunt and peck’ through the file looking for the correct timestamp. The Cues Element SHOULD contain at least one CuePoint Element. Each CuePoint Element stores the position of the Cluster that contains the BlockGroup or SimpleBlock Element. The timestamp is stored in the CueTime Element and location is stored in the CueTrackPositions Element. The Cues Element is flexible. For instance, Cues Element can be used to index every single timestamp of every Block or they can be indexed selectively." Instead, the ffmpeg documentation states. (https://ffmpeg.org/ffmpeg-formats.html#matroska): "reserve_index_space By default, this muxer writes the index for seeking (called cues in Matroska terms) at the end of the file, because it cannot know in advance how much space to leave for the index at the beginning of the file. However for some use cases – e.g. streaming where seeking is possible but slow – it is useful to put the index at the beginning of the file. If this option is set to a non-zero value, the muxer will reserve a given amount of space in the file header and then try to write the cues there when the muxing finishes. If the reserved space does not suffice, no Cues will be written, the file will be finalized and writing the trailer will return an error. A safe size for most use cases should be about 50kB per hour of video. Note that cues are only written if the output is seekable and this option will have no effect if it is not. cues_to_front If set, the muxer will write the index at the beginning of the file by shifting the main data if necessary. This can be combined with reserve_index_space in which case the data is only shifted if the initially reserved space turns out to be insufficient. This option is ignored if the output is unseekable." Perhaps one should indicate these parameters to CinGG? PS: I did some tests (it had been a long time since I had used mkv) without any problems, as also reported by IgorBeg.
We can also download "problematic" mkv files for testing: https://github.com/ietf-wg-cellar/matroska-test-files
On Thursday, November 24, 2022 9:31:28 AM CET, Igor BEGHETTO via Cin wrote:
I downloaded the "sample_1280x720_surfing_with_audio.mkv" from https://filesamples.com/formats/mkv and tested on "CinGG-20221031-x86_64-older_distros.AppImage" in UnbuntuStudio_16.04. It seems to work fine, cutting here or there, but it is an mkv container with h264 inside. If/when you have time, could you try it, in your System and Cinelerra-GG? Thanks!
The same file "surfing" works with cutting. I can obviously provide my recording if you want to test it. -- Stefan
@ Andrea_paz Thanks! I downloaded "test1.mkv" from https://github.com/ietf-wg-cellar/matroska-test-files and it seems to work good in Cinelerra-GG. @Stefan Thanks for your info file and good "sample_1280x720_surfing_with_audio.mkv" file works for you too. Yes, it might help to see your mkv file to test it on other distros. Can you share that file privately or publicly? (Sorry, my reply, tomorrow, I hope) IgorBeg
On Thursday, November 24, 2022 1:39:22 PM CET, Igor BEGHETTO via Cin wrote:
@Stefan Thanks for your info file and good "sample_1280x720_surfing_with_audio.mkv" file works for you too. Yes, it might help to see your mkv file to test it on other distros. Can you share that file privately or publicly? (Sorry, my reply, tomorrow, I hope)
<http://download.stefan.konink.de/cinelerra-bugs/netex.mkv> -- Stefan
Thanks Stefan for your test file. In Cinelerra-GG, for what I are seeing, the problem is not cutting the video in the Timeline; the video also freezes without cutting anything and playing frome some points. Your video use long GOP (max 250): there are I-frame, B-frame, P-frame. The I-frames are at: I-0001, I-0220, I-0447, I-0697, I-0913, I-1163 and I-1342. Like me, you can do an easy test in Cinelerra-GG. 1. On the Timebar, in the Main Window, change the display from "Frames" to "Hours:minutes:seconds: frames" (use Right Mouse Button on it, see https://cinelerra-gg.org/download/CinelerraGG_Manual/Insertion_Point.html). So you can see "Frames" instead of "Hours:minutes:seconds: frames". 2. Add two labels at 913 and 1163 (you can use "Go to" tool) 3. Move the Insertion Point at 930, for example, and press Play (Numpad-3): it should work fine. 4. Move the Insertion Point at 850, for example, and press Play (Numpad-3): video freezes until it reaches the I-frame (at 913). The same happens for the other I-frames. It seems a problem around some B-frame and P-frame. As Andrea_paz said, the MKV codec format can be problematic if the encoding is not done well by the program (OBS?). I don't use OBS Studio, so I can't try it using other output format codec. Possible solutions: a) As told by Andrea and Phyllis, using Transcode's Cinelerra-GG or an other Convert tool. b) In OBS Studio change the output codec, for example TS (Transport Stream), MOV, MPEG2, or ???. Because your video is yuvj444p h264 High 4:4:4 Predictive, in OBS can you change any parameters of that? For example to yuvj420p and try? IgorBeg PS: other Users have many problems with MKV files from OBS Studio using Commercial NLE (LightWorks is one of them)
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). On Fri, Nov 25, 2022 at 6:01 AM Igor BEGHETTO via Cin < [email protected]> wrote:
Thanks Stefan for your test file. In Cinelerra-GG, for what I are seeing, the problem is not cutting the video in the Timeline; the video also freezes without cutting anything and playing frome some points.
Your video use long GOP (max 250): there are I-frame, B-frame, P-frame. The I-frames are at: I-0001, I-0220, I-0447, I-0697, I-0913, I-1163 and I-1342.
Like me, you can do an easy test in Cinelerra-GG. 1. On the Timebar, in the Main Window, change the display from "Frames" to "Hours:minutes:seconds: frames" (use Right Mouse Button on it, see https://cinelerra-gg.org/download/CinelerraGG_Manual/Insertion_Point.html).
So you can see "Frames" instead of "Hours:minutes:seconds: frames". 2. Add two labels at 913 and 1163 (you can use "Go to" tool) 3. Move the Insertion Point at 930, for example, and press Play (Numpad-3): it should work fine. 4. Move the Insertion Point at 850, for example, and press Play (Numpad-3): video freezes until it reaches the I-frame (at 913).
The same happens for the other I-frames. It seems a problem around some B-frame and P-frame. As Andrea_paz said, the MKV codec format can be problematic if the encoding is not done well by the program (OBS?). I don't use OBS Studio, so I can't try it using other output format codec.
Possible solutions: a) As told by Andrea and Phyllis, using Transcode's Cinelerra-GG or an other Convert tool. b) In OBS Studio change the output codec, for example TS (Transport Stream), MOV, MPEG2, or ???.
Because your video is yuvj444p h264 High 4:4:4 Predictive, in OBS can you change any parameters of that? For example to yuvj420p and try?
IgorBeg
PS: other Users have many problems with MKV files from OBS Studio using Commercial NLE (LightWorks is one of them) -- Cin mailing list [email protected] https://lists.cinelerra-gg.org/mailman/listinfo/cin
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?
Andrea, the mkv.txt file looks real good to me. I will wait to see if IgorBeghetto has any more feedback and then add to the manual. On Sat, Nov 26, 2022 at 3:11 AM Andrea paz <[email protected]> wrote:
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?
Andrea_paz, Wow,... a great article! I agree with Phyllis. Andrea_paz wrote:
How do you see the I-frames of a media? I have only found one ffprobe command, but it is not convenient to use.
I use two scripts by DanDennedy and UseSparingly. Both scripts use ffprobe that have to be installed on your System. I add two compressed file for them. We spoke about in Mailing List around 2019: https://lists.cinelerra-gg.org/pipermail/cin/2019-February/000254.html. IgorBeg
Thank you for the scripts. Do you guys think it is better to upload the scripts in CinGG git and then put the link in the manual or is it better to put the links to the original sources? I attach the latex files which are only missing the links to the 2 scripts.
Andrea, sometimes the original sources get lost. I will put the files where we have put other file like these at: https://cinelerra-gg.org/download/testing/ tomorrow when I boot the desktop and then I will change the links in the .tex file as you provided and check into the manual GIT. On Sun, Nov 27, 2022 at 5:20 AM Andrea paz via Cin < [email protected]> wrote:
Thank you for the scripts. Do you guys think it is better to upload the scripts in CinGG git and then put the link in the manual or is it better to put the links to the original sources? I attach the latex files which are only missing the links to the 2 scripts. -- Cin mailing list [email protected] https://lists.cinelerra-gg.org/mailman/listinfo/cin
participants (4)
-
Andrea paz -
Igor BEGHETTO -
Phyllis Smith -
Stefan de Konink