User scripts
Closed, ResolvedPublic

Description

Making Kdenlive user-scriptable would allow Kdenlive users to automate some parts of their workflow. While the libraray bin now allows for a kind of template repository, it does not allow for flexibility.

For instance, at this time a user cannot even add a single transition with keyframes to the project bin. (Please correct me if I'm wrong.) But even if the user could, then the template is fixed in length. If I need a differently configured transition I would need to add another library bin template.

In contrast, user scripts would allow for parameterization. For illustration, a user may create a user script that runs on a selected clip. The script then creates an affine transition with the black track according to some user-specified ramp length and fitting with the length of the selected clip. No more fiddling around with keyframes.

User scripts could also allow for updating an existing transition, such as updaring its keyframes.

For this, we will need some (simple) object model for timeline elements, namely clips, transitions, and optionally guides. In addition, certain operations are required, such as querying or setting the begin and end of a clip, adding clips, transitions, as well as some more.

User scripts could be made available through a new pane which lists available user scripts. This pane might also act as a possible script parameter UI to allow for easily parameterized scripts (such as the ramp length example mentioned above).

thediveo created this task.Jul 12 2016, 6:42 PM
jospin added a subscriber: jospin.Aug 22 2016, 8:25 AM

Ok, so as we discuss before I think python is the best choice of language because:

  • It's some kind of standard in the Floss video editing world (Blender use python, Natron use python) and non-Floss (Nuke use python).
  • It has a clear en well documented c api (compared to Ruby for exemple) and a wrapper for Qt (PythonQt).
  • It's a simple and clear language.

What do you think ?

Whatever language, we first need to have an object model, such as:

  • Clip
  • Timeline
  • Project Bin
  • Effect(s)
  • Transition
  • Keyframes
  • Groups (later)

We also need operations, such as Timeline.insert(), Timeline.add(), and so on. This needs to be established to some degree, as this is the difficult part: designing the scripting objects in the proper way so users get what they need for scripting.

I've looked into Python for Qt too, but my impression is that there are different versions floating around, so which one to take? In contrast, JavaScript is directly supported by the Qt developers themselves.

Sure for the object model. If we need to do a refactoring we can do it at the same time. It may also be usefull to collect potential usecases.

Concerning PythonQt, I think the best would be to look how it has been integrated in Krita. But I get your point.
(We can also take the native python c api, but it is a bit less convenient. It may be hard for example to connect signals and slots from c++ to python and vice versa)

Javascript also miss some features compared to Python, for example in scientific computing.
I can use scipy in blender, but it wouldn't be possible in javascript.

jospin added a comment.Feb 1 2017, 7:13 PM

Ok, from the previous café, a few notes:

  • Somebody asked how are scripting abilities embedded in an application. The method is rather simple:
    • You link your application against an interpeter (python, ruby, ...)
    • You create a funtion to run scripts, (setup the vm, compile the script, run the script, close the vm) or to run commands (setup the vm once, compile and run commands when received, close the vm when exiting).
    • You create an importable library (importable in your scripting language, but written in your app language), this is generally the hard part, even if the process has been smoothed out for python, which is quite popular as an embeded scripting language. There's lot of examples of library to automatize embeding in python of c++ function around, like Boost.Python or pybind11 (or even Python qt, even if development seems a bit slower, so I prefer to use pybind11 or the c level api for the moment).
    • Qt script is based on the same principle, except you import the functions directly within c++ instead of having an importable module (you can do that with python or ruby too, but I find it inconvenient).

Another question was +/- Why would we want to let the users script the application ? That's a good question, in fact, I have no answer by myself. I would have liked to be able to automatize some projects creations (in my company, we organize Live Action Role Playing Games, and we wanted to be able to create some video on the flight for the participants), but what other users would want ?

Another this, very usefull in Natron, is the ability to script some parameters. In some cases it's really easier than working with keyframes.

P.S. QtScript has been deprecated in Qt 5.8. So is it really a good idea to go for this one ?

jlskuz closed this task as Resolved.Nov 12 2023, 3:22 PM
jlskuz claimed this task.
jlskuz added a subscriber: jlskuz.

We discussed this topic during the sprint in November 2023. We will continue to track this issue in the roadmap and/or on https://invent.kde.org