GSoC/2019/StatusReports/AkhilKGangadharan

From KDE Community Wiki
< GSoC‎ | 2019‎ | StatusReports

Revamping the Titler Tool

Project Overview

Why do it? The titler tool is used to create clips containing text and images, which can be composited over videos. The titler tool renders XML using an MLT module which uses QGraphicsView. QGraphicsView is considered deprecated. Moreover, adding features to the current back end is difficult and is known to be buggy leading to an overall limited and outdated functionality.

How to do it? Use and render QML frames instead of XML as QML, in general, allows creating powerful animations with ease and flexibility which means new features can be added to the titler. Rewrite the tool's backend using QQuickRenderControl to render QML and implement a new QML MLT module which can produce QML frames, and to also create a basic titler which can render basic QML templates


Project Goals

  • Implement an independent QML rendering library
  • Integrate library with MLT and write an MLT producer which produces QML frames
  • Develop a basic UI for the new Titler on Kdenlive which uses the new producer

Project Code

1. QmlRenderer library

https://invent.kde.org/akhilkgangadharan/QmlRenderer

What does the library do?

The library can be used to render QML templates to QImage frames. Parameters that can be manipulated are -

  • FPS
  • Duration
  • DPI
  • Format

The library can be tested using QmlRender, a CLI executable. A sample run:

     ./QmlRender -i "/path/to/input/QML/file.qml" -o "/path/to/output/directory/for/frames"

./QmlRender --help reveals all the available options that may be manipulated.


How does the library do it?

Using QQuickRenderControl, detailed working in Week 2 Blog


How is the library being used?

The library will be doing the heavy lifting - i.e rendering the QML frames to QImages in the new QML MLT producer.

2. QML MLT Producer

MLT fork: https://github.com/akhilam512/mlt/commits?author=akhilam512


Work report

Implement an independent QML rendering library

Week 1 & 2

The first two weeks went into making the QML rendering library ready. I made the library code production-ready and added CLI access to the library.

Blog Posts

Week 3

I worked on writing the test module for the library and implemented unit tests.

Blog Posts

Week 4 & 5

These two weeks went in cleaning up the QmlRenderer library code - - Removing redundant parts of code from initial - Integrating a clean build system involving everything from tests, CLI tool and source code to a single .pro file (My mentor, Vincent, helped a lot in this aspect)

Also began with MLT documentation, started with figuring out the whole structure of MLT.

Integrate library with MLT and write an MLT producer which produces QML frames

Week 6 & 7

I started sniffing around the MLT code base. I had a brief look previously during the community bonding period but this time, I had a deep dive. I understood the components of MLT, the working of the framework in general (producer-consumer, filters, tracks) and in specific, went through the code of producers in MLT as it is relevant to my next task, (i.e. writing a new producer).

Week 7 & 8

I started writing the QML producer. Most of the work went in the wrapper files which deal with the rendering part (and this is where I started integrating my QmlRenderer lib) I was still lacking confidence in doing this part as I was still unclear about the working exactly, so I took a step back and tested the working kdenlivetitle producer with MLT to figure out when and where the producer is actually called. I was still able to get an initial structure for the producer.

Blog Posts

https://kdenlive.org/en/2019/07/month-2-in-making-the-titler-gsoc-19/

Week 9 & 10

There was still a lot of work to be done in the producer's wrapper files and I had to deal with the problems of integration with the library, although initially there were no major hurdles. At times, I needed to refactor the QmlRenderer library source code to provide easy endpoints for the producer to make use of, one example is in the case of loading the QML template - here by default the lib took a QUrl, but the producer (just like in traditional C) takes a character pointer as the entire template and then renders it - a straightforward approach to solve this problem was to overload the method which loaded the QML template in the library source code. Similarly, I had to refactor a lot of code in order to clearly compartmentalize and utilise the library, of course keeping in mind, the codebase.


Week 10 & 11

I started testing the producer using melt (which is a CLI test tool for the MLT framework) and the results were kinda astonishing. I faced a major blocker as I was simply unable to instantiate an object pointer to the QmlRenderer library code, and I spent a lot of time trying out alternative ways to solve this, firstly I attributed it to QOBJECT ownership and somehow the QmlRenderer being destroyed but it was not the case. Next, I attributed it to OpenGL, as threading and OpenGL have never gone well together. The blocker was finally resolved after discussing with my mentor and Kdenlive developers, and it was apparently because I was not instantiating an QApplication for the producer which is necessary for its operation. I resumed testing the producer.


Blog Posts

https://kdenlive.org/en/2019/08/the-titler-revamp-qml-producer-in-the-making/

Week 12

Continued work on the producer. Polished tests for QmlRenderer libs.

What work has been done?

  • A working, tested QmlRenderer library
  • Basic code to the QML MLT producer

What work needs to be done?

  • Full-fledged MLT QML producer
  • Basic titler on Kdenlive side to test

I plan to work on implementing the left out parts of the project along with complete implementation of the titler with a new UI after GSoC period.