Bug 505407 - [Feature Request] Use Timeline or Clip Markers to split clip into pieces
Summary: [Feature Request] Use Timeline or Clip Markers to split clip into pieces
Status: REPORTED
Alias: None
Product: kdenlive
Classification: Applications
Component: Timeline & Editing (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: Jean-Baptiste Mardelle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-10 02:43 UTC by lucartc
Modified: 2025-06-10 02:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lucartc 2025-06-10 02:43:55 UTC
It would be nice if there was a way of cutting a video using certain moments know previously.
Some use cases:

- I want to make a video where the image is synchronized with a music beat. So, I can use an audio
  processing program to give me a list of beat moments, and I'll cut the video in these moments, which will
  be imported as markers. But doing it by pressing Alt+Right and Shift+R would take a long time.
  An automated way of doing it would be better.

- I have some video pre-processing program that gives me certain key points based on certain metrics - e.g.
  funny moments from a podcast or movie - and I want to use this data to generate clips of key moments and
  discard the rest.

I've searched for related requests, and I've found these:
https://bugs.kde.org/show_bug.cgi?id=388122
https://bugs.kde.org/show_bug.cgi?id=486249
https://bugs.kde.org/show_bug.cgi?id=501704

I've checked some of the tasks existent, and I could come with a solution based on `scenesplittask.cpp`. The user will be able to choose between using timeline or clip markers. He'll also be able to choose the category and if he wants to keep even or odd clips - or both. There's also an option to add the resulting clips as subclips under the main clip's tree.

To do this, i've basically used zones. I read the desired Markers' frames and used them to create zones from
the original clip. These zones are then put into timeline with `insertZone()` and - if the user wants - they are added as subclips using `loadSubclips`.

The problem is: iterating a list of zones and calling insertZone in each of them doesn't seem to work well. It
seems that it overload and crash the app, and I don't know exactly where. Maybe the GUI thread gets too busy when it inserts a certain amount of zones into timeline, but I'm not sure where the bottleneck is. I thought that it was overloading the TaskManager's thread pool, but it doesn't seem to be it since I've tracked the tasks being executed, and no task seems to be run during the insertion.

The way I solved the crash caused by this bottleneck was delaying each zone insertion by some miliseconds, with QThread::msleep. It's not an elegant solution, since it's a blocking solution, but since AbstracktTask runs in a separate thread, using it souldn't block the main thread, and since I've used it I didn't have more crash problems.

There are certainly non-blocking ways of doing the same thing, but it seems to me that such solutions would need first to use some signal related to UI events, so that it may know when the UI is overloaded - and shouldn't receive more timeline insert requests - and when it is ready to do it.

Since I'm not very familiar with C/C++ and certainly not very familiar with QT, some suggestions would be welcome. Also, opinions about the viability of implementing this feature currently are welcome. I've seem some discussions about using only Markers and abandoning Guides, and this feature may make this and other changes more complicated.

You may check the code at https://invent.kde.org/lucartc/kdenlive/-/tree/work/masssplittask?ref_type=heads
in files:
- src/jobs/markersplittask.h
- src/jobs/markersplittask.cpp