Here are Top 5 Ways to reduce Timeline Preview Lag in Shotcut

By | August 28, 2023

Preview lag or choppy playback is a common thing in shotcut that a lot of users complain about. It happens when the system hardware is not powerful enough to play the preview smoothly resulting in stutters in the preview pane when playing.

So i was working with a few 4k videos from my sony zv-e10 camera and found out that even with a single timeline video track and single clip being added to it, the playback was horribly slow to the point of being useless.

The timeline preview will lag for a number of reasons and the most common ones are:

1. You are working with large resolution video clips like 4K or higher.

2. The video clips are encoded with advanced codecs with high profile settings, which makes decoding very slow and time-consuming. For example h.264 High Profile videos will work slower than h.264 Baseline profile videos

3. You have applied filters that require a lot of processing.

There are a couple of simple hacks to quickly fix this, without having to do much work. Shotcut has features in place that allow for optimising the editing process and making the timeline preview more responsive.

1. Preview Scaling

Switch to a lower resolution for preview scaling. This will basically play the preview in the preview box with a lower resolution where the full 4k resolution is not necessary. This will speed up the overall playback a bit.

You can choose a preview scaling option of 360p, 540p or 720p. I used 720p and as a signficant boost in the playback speed.

2. Enable Realtime plaback

Enable Player > Realtime (frame dropping) option. This will ensure that the playback is properply synchronised with real clock time and does not lag behind, and to achieve this, it might even drop some frames if processing takes too long. This will make the playback look a bit jittery, but a lot better than laggy.

3. Select Audio channel mono

During the editing and preview stage select auto channel as mono, since it would be faster than stereo processing. This can speed things up a bit

4. Use Proxy

With proxy use enabled, shotcut will create temporary copies of the main video with lower resolution and lesser quality that would be easier to work with in the editor.

When all the editing has been finalised, in the final rendering process the proxy video shall be replaced by the main video and rendering shall be performance on the original high quality video clips.

Proxy files are generated using hardware encoders like nvenc, as they are fast and there is no need for very high quality in these proxy files.

Manually manage proxy: If you do not want to use the proxy feature of Shotcut then you can manually create a low resolution (fast working) replica of the source video files and work on them, and before the final rendering just replace the source files with the original high resolution files.

This technique works with shotcut as discussed by a user on the official forums over here

The manual proxy method provides greated flexibility over the shotcut's inbuilt proxy feature. Shotcut by default using h264 mp4 format for the proxy files which are still not very editing friendly and even though the playback is faster and better the timeline scrubbing is still very slow.

With manual proxy technique you can choose a codec with settings that allow for very fast decoding and timeline scrubbing, making the editing experience even better. In the next section we take a look at some editing friendly codecs, also known as intermediate (or mezzanine) codecs.

4. Use a editing-friendly video codec

When importing and editing a video in any video editor (like shotcut) the video codec determines how fast the cpu will be able to decode the video, apply the filters and play it in the preview.

Desktop records like OBS Studio produce videos encoded with H.264 and many devices like smartphones and cameras also use the same codec. Codecs like h.264 are complex and take considerable cpu time to decode.

So everytime you try to play the timeline (tracks) to see a preview of your edits, the cpu has to decode the source video using a matching decoder and then play it.

The solution is to use a codec that does minimal encoding and can be decoded faster by the cpu in less time. There are many video editing codecs like mjpeg and prores. These are also known as mezzanine or intermediate file formats. Since they keep the frame images as similar to the original as possible, the compression is minimal resulting in much larger file size.

1. Avid DNxHD Codec

Here is the command to convert a h264/mkv video into a DNxHD/mov video file. We can scale down the resolution from say 4K to 1080p or even lower if we want to use it as a manual proxy.

ffmpeg -hide_banner -y -i .\source.mkv -c:v dnxhd -vf "scale=1920:1080,fps=60,format=yuv422p" -b:v 115M -ss 0 -t 60 .\proxy.dnxhd.mov

2. Motion JPEG (MJPEG) Codec: Motion-JPEG is a video codec that stores the whole video as a series of jpeg images, where each frame is a keyframe that can be rendered without much decoding needed. This makes the editing process faster and smoother, as the cpu has to do less work.

However note that mjpeg is not a proper intermediate codec for post production editing, simply because it does not have a lot of features that modern codecs have like hdr support, 10-bit colors, chroma subsampling, variable bitrate etc. Its extremely primitive in structure.

Mjpeg is not a good codec for recording since it takes up a lot of disk space compared to h.264 and is around 3x larger or even more. An ideal approach would be to record in h.264 and then convert it to mjpeg using a convertor like ffmpeg and then use the mjpeg files in video editors like Shotcut, Davinci Resolv, or Adobe Premiere.

Here is a simple ffmpeg command to convert a h264 mkv video to mjpeg mp4 with best quality.

ffmpeg -i 2022-12-10_17-15-57.mkv -vcodec mjpeg -r 60 -q:v 1 output.mjpeg.mkv

This mjpeg encoded mkv wrapped video file will perform much faster in video editors. You can test it out yourself.

A slightly modified version of the same command:

ffmpeg -y -hide_banner -i 2022-12-10_17-15-57.mkv -vcodec mjpeg -r 60 -q:v 1 -ss 0 -t 60 2022-12-10_17-15-57.mjpeg.mkv

Note that with mjpeg codec we have used avi container which seems to be faster in playback compared to mp4, and consumes less cpu power.

In my tests i noted that the cpu usage came download by atleast 15% when using mjpeg instead of h.264 as the video codec. The gains will be even higher when using gpu accelarated video effects.

However keep in mind that most gpu hardware do not support decoding or encoding of mjpeg format, which can be a limiting if you already have a powerful gpu that can easily decode h264 and a video editing software that supports decoding timeline videos using hardware acceleration.

3. Prores Codec: Prores is a codec from Apple and it has many different variants. Its commonly used by Final Cut X, and Adobe Premiere. Performance is similar in both dnxhd and prores, just that prores is more of an apple eco-system product and does not work well on windows.


There are other mezzanine codecs like gopro cineform but those are too out of mainstream and most of the time you should be able to work just fine with dnxhd.

Check out this article:

10 Common Video codecs and How to use them in FFmpeg

Check the current codec: To check the codec and other details about a given video, we can use the ffmpeg or the ffprobe command as shown below

ffmpeg -i 2023-01-23_18-34-33.mkv -hide_banner
ffprobe 2023-01-23_18-34-33.mkv -hide_banner

Below is an example of how the output looks like

$ ffmpeg -i 2023-01-23_18-34-33.mkv -hide_banner
Input #0, matroska,webm, from '2023-01-23_18-34-33.mkv':
  Metadata:
    ENCODER         : Lavf59.27.100
  Duration: 00:16:41.17, start: 0.000000, bitrate: 44930 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn
    Metadata:
      DURATION        : 00:16:41.167000000
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
    Metadata:
      title           : simple_aac_recording
      DURATION        : 00:16:41.130000000
At least one output file must be specified
$

Note that Stream #0:0 is a video stream encoded with h264, and Stream #0:1 is an audio stream encoded with aac

$ ffprobe 2023-01-23_18-34-33.mkv -hide_banner
Input #0, matroska,webm, from '2023-01-23_18-34-33.mkv':
  Metadata:
    ENCODER         : Lavf59.27.100
  Duration: 00:16:41.17, start: 0.000000, bitrate: 44930 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn
    Metadata:
      DURATION        : 00:16:41.167000000
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
    Metadata:
      title           : simple_aac_recording
      DURATION        : 00:16:41.130000000
$

Improved Scrubbing Movement

With editing friendly codecs, scrubbing over the timline will be a lot more responsive. As you move the marker, the visuals in the preview pane will also update fast, if not immediately.

Check the input video

Before you start working with a video file in editors like shotcut, its best to check its details using tools like ffmpeg/ffprobe. Look for specific details like the framerate, bitrate, resolution etc.

Videos with higher resolution and frame-rates have more data in them so consequently have a higher bit-rate if encoded at higher quality settings. Such videos will need more ram and cpu power while decoding slowing down the video editor.

Best would be to convert them to an editing friendly format and work from there on and re-encode them back to something like h.264 or h.265 for delivery. If you are uploading to youtube for instance, you can upload the highest quality file that you can, and youtube will automatically optimise the delivery for a variety of user scenarios.

Why doesn't gpu help

Some of you might have faced this issue, that even if you have a dedicated gpu like rtx3060, the timeline preview will still lag. This is simply because shotcut does not and cannot use the gpu decoder (nvdec in nvidia gpus) to play the timeline.

Videos in the timeline are almost always decoded using the cpu which is why this process does not benefit much from a dedicated gpu. However cpu based decoding is multi-threaded, which means that having more cores will speed up the preview. However this needs hardware upgrade which might not be an option for everyone.

If you are planning to build a new pc or get a laptop for video editing specifically then bear this important factor in mind that the cpu core count is very important to make your editing experience comfortable.

Conclusion

Those were some of the very basic tips on how to speed up timeline in shotcut. The key thing to note, is that you do not need to upgrade your existing hardware for any of the above techniques to work. Just tweak settings and your workflow and the editing process should be a lot more smoother and speedier.

Since shotcut (and ffmpeg) are cross platform, all the methods discussed above should work on both windows and linux (ubuntu or fedora). I have personally used shotcut on ubuntu with any issues. Though gpu support is something that may vary across the two platforms.

Hope that helped you. Let us know your questions in the comments below.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *