Format (codec) for editing

to capture my screen and audio, I use OBS project and I record in MKV (H.264/AAC) (2K and 4K)

I wonder if for Shotcut editing it would be better to convert the MKVs to a particular codec so that Shotcut works “better” and therefore taking as few resources as possible

Do you recommend a particular format (codec) for video editing?
Or are all codecs equal? The MKV container is a problem? I ask this question in connection with my feedback on the slowness of the mlts as soon as we make many cuts, the assembly of the mlts as clips…
I am looking for the best workflow and therefore the best formats for editing without sacrificing any audio/video quality

thank you for your feedback, practices, and advice.

There should be no difference in whether you use MKV or MP4, they are both only containers. Once Shotcut has extracted the H.264-encoded video and is processing it it shouldn’t matter what the container was.

It’s like receiving a letter in a blue envelope or a white one. Once you’ve extracted the letter and are reading it, the colour of the envelope is irrelevant.

1 Like

A small or no GOP is better for performance while editing.

thank you for the clarification.
The GOP corresponds to the interval of key frames under OBS?

How to know the GOP of a video? I don’t see this information in the properties of the videos in Shotcut.

The GOP in export is very high on many formats, is it the method of the number of compressed images? Is this value standardized or can it be modified as desired for export?

Yes it is the keyframe internal. This is not easy to obtain because it is usually variable in length per screen change detection. I have a ffprobe script I wrote to report this. I should integrate that into Shotcut Properties especially for my own convenience.

The maximum is not standard except in certain streaming and broadcast scenarios.

It significantly affects the output size. Test a value of 1 and 15 and compare: the speed in Shotcut, the integrity of capture, and the file sizes. I am curious to know your results as I am not an OBS user.

Here is my script. It requires a compatible shell, which makes it incompatible with Windows until you install something like Git for Windows, msys2, or cygwin, etc. You may also need to either add the Shotcut folder to your PATH if you do not have ffmpeg already somewhere in your terminal’s PATH. Basically, command line users should understand these concepts.

1 Like

Hi, thank you for your reply.
I carried out tests under OBS.
Here are the results attached.
I usually capture my screen with a GOP of 120 (at 30 fps, a reference frame every 4 seconds)

The results are impressive (there may be an error in the capture 240…) I tried to make the same captures in 2min30 so as not to distort the size of the files

In Shotcut, my first observation is a great fluidity on the low values ​​as soon as I move the playback line quickly while for the high GOPs, the sweeping of the video has the effect of freezing the video (which is not serious !)

I have to test in depth to see the limit of the GOP with Shotcut, especially on the cuts.
I know that with a lot of cuts at a GOP of 120, for a video longer than 30min the timeline is very slow.

On the other hand, the values ​​0 and 1, the quality of the video is very degraded when playing with VLC! (and in Shotcut too)
comparaison GOP.pdf (13.4 KB)

Thanks for your script. I’ll see if I can use it… I’m not sure I can :frowning:

I modified your script to run in Python for my own purposes, which adds cross-platform compatibility for everyone else. A sample run looks like this when fed with the first 60 seconds of an iPhone video:

ffprobe -select_streams v -show_frames -read_intervals 0%+60 IMG_0001.MOV 2> /dev/null | ./

GOP Length:
 Most common: 30
 Maximum: 30
 Average: 30

P-Frames per GOP:
 Most common: 29
 Maximum: 29
 Average: 29

B-Frames per GOP:
 Most common: 0
 Maximum: 0
 Average: 0

And here is the contents of

#!/usr/bin/env python3

# Requires Python 3.8 or higher

# To get frame stats on an entire video file:
#  Linux:
#   ffprobe -select_streams v -show_frames Video.mp4 2> /dev/null | ./
#  Windows:
#   ffprobe -select_streams v -show_frames Video.mp4 2> Nul | py
# To get frame stats from seconds 30 through 90:
#  Linux:
#   ffprobe -select_streams v -show_frames -read_intervals 30%+60 Video.mp4 2> /dev/null | ./
#  Windows:
#   ffprobe -select_streams v -show_frames -read_intervals 30%+60 Video.mp4 2> Nul | py

import sys
from operator import itemgetter
import statistics

# Get all frame information into a list of tuples.
ffprobe_frames = []
for line in map(str.rstrip, sys.stdin):
	if line == '[FRAME]':
		media_type = None
		coded_picture_number = None
		key_frame = None
		pict_type = None

	elif line[0:11] == 'media_type=':
		media_type = line[11:]

	elif line[0:21] == 'coded_picture_number=':
		coded_picture_number = int(line[21:])

	elif line[0:10] == 'key_frame=':
		key_frame = int(line[10:])

	elif line[0:10] == 'pict_type=':
		pict_type = line[10:]

	elif line == '[/FRAME]':
		if media_type == 'video' and coded_picture_number:
			ffprobe_frames.append( (coded_picture_number, key_frame, pict_type) )

# Sort the frames by coded_picture_number.
# For example, some Panasonic cameras write
# two B-frames before the first I-frame,
# and failing to sort will lump frames into
# the wrong GOP when gathering statistics.
sorted_frames = sorted(ffprobe_frames, key=itemgetter(0))

# Gather statistics on the sorted frames.
num_frames_per_gop = []
p_frames_per_gop = []
b_frames_per_gop = []
gop_index = -1
for __, key_frame, pict_type in sorted_frames:
	if key_frame == 1:
		gop_index += 1
		if gop_index >= 0:
			num_frames_per_gop[gop_index] += 1

	if pict_type == 'P':
		if gop_index >= 0:
			p_frames_per_gop[gop_index] += 1

	elif pict_type == 'B':
		if gop_index >= 0:
			b_frames_per_gop[gop_index] += 1

# Print statistics.
print("GOP Length:")
print(" Most common:", statistics.mode(num_frames_per_gop))
print(" Maximum:", max(num_frames_per_gop))
print(" Average:", statistics.mean(num_frames_per_gop))
print("P-Frames per GOP:")
print(" Most common:", statistics.mode(p_frames_per_gop))
print(" Maximum:", max(p_frames_per_gop))
print(" Average:", statistics.mean(p_frames_per_gop))
print("B-Frames per GOP:")
print(" Most common:", statistics.mode(b_frames_per_gop))
print(" Maximum:", max(b_frames_per_gop))
print(" Average:", statistics.mean(b_frames_per_gop))

Heh, except it requires installing Python on Windows :wink:
And your script is different. Mine was not intended for summary stats as I also use it to verify keyframe alignment across streaming renditions (original purpose).

Lol, uglier things have been done to Windows. But point taken, I was not intending this script for general usage. It was mainly for people trying to reverse-engineer a video to quickly figure out simple compression settings. The summary method used in it would not be as effective at tracing varying GOPs, like per-scene encodings.

The best way to effect platform independency would be to use Javascript and wrap it in a small HTML file. Every system has a browser, so, as long as they have ffmpeg there is no problem.

I made recordings with OBS today; I set the keyframe interval to 15 (30fps, so one keyframe every 1/2s)
I’m going to do the editing this week, and I’ll tell you if the timeline is smooth or if it doesn’t change anything. (with build 221022!)

The weight of the file is more important, the quality slightly better but very little for the weight of the file at x5!

I processed the videos with the keyframe interval at 15 (i.e. 1/2s at 30fps). The timeline remains fluid and therefore manipulable over a one-hour rush for a final clip of 35 minutes and therefore many cuts. Compared to previous videos slow from 20 minutes and almost stalling at 30 minutes, this is much better. So my previous videos were with a keyframe interval of 240 (8 seconds) (not 120, 4 seconds as I said before - the value had been changed, hence my question about Shocut not reacting as on previous versions)

The subject, allowed me to understand the compression! GOPs, b-frames, keyframes, p-frames…
I will set OBS to 4 seconds for keyframes. I think it will give a good compromise between quality and file size; and I think it will stay smooth on Shotcut. Also I will make shorter captures (max 30min)

I have to look at your scripts… not yet them time


I changed my OBS settings back to simple settings… and so I have the AMD_HEVC hardware encoder. (no b-frame, dynamic GOP?)
After captures, post production with Shotcut. I did not use a master (mlt as a clip) but only in a single project:

  • 4K 200% @30fps, very good quality MKV (HEVC/AC3)
  • 12 videos of variable duration, total: 1h44min, 2.19Go
  • pictures, simple text
  • markers
  • mlt: 1266 KB

The timeline is smooth…good!!

This topic was automatically closed after 90 days. New replies are no longer allowed.