A TypeWriter effect for kdenlive and mlt using the TypeWriter library I developed for this purpose
Rafal Lalik
rafallalik at gmail.com
Tue Sep 5 17:23:18 UTC 2017
Hi guys!
I am new here but would like to put my 5 cents into development of
kdenlive and mlt.
What I was seriously missing in kdenlive is typewriter effect. I know
there was simple implementation in kdenlive but now is completely
commented out, and I know that also mlt have some support for it, which
is not used at the moment at all.
So I put it in my hands and I decided to implement a such feature in my
own kdenlive and mlt installations. Now I would like to propose you to
include it into official code.
Here you can find short demo what is the final effect of my code:
https://www.youtube.com/watch?v=I8oyiy3YzBI
There are three main parts of the feature:
1) My own library used to render the text. It provides kind of control
sequences and macros which control rendering of the text per each frame.
This library is available on github here:
https://github.com/rlalik/TypeWriter
and is required for my modifications of mlt.
2) Mlt was modified to use with the TypeWriter library. It uses
information provided by kdenlivetitle producer, though additional
information must be passed there. This is handled by kdenlive.
I had to do some modifications in the kdenlive_wrapper.cpp like
introduce DynamicTextItem class which derives from PlainTextItem and
make small modifications (private to protected) for a few variables in
PlainTextItem to avoid to big overhead.
3) In kdenlive I extended the the xml format by special patterns. Since
use of the control sequences in the dynamic text, usualy the text to
render is very messy. Instead putting the text directly into the scene,
you put a placeholder which is then replaced by proper text (this is
done in mlt). Therefore I added fourth tab in the Title Clip widget
which allows to add, remove and edit patterns.
Since I didn't want to mess up to much with the original code, at the
moment I created inherited classes for TitleWidget and TitleDocument
(TypeWriterWidget and TypeWriterDocument accordingly) which handle it
all. I had to also set two functions in TitleWidget to be virtual, and
small changes in the bin.cpp.
I would however suggest to make it more clean and actually add the
implementation directly to the base classes and get rid of derived
classes in kdenlive. This feature can be built in into kdenlivetitle,
does not interfere with the old format, so all old clips will work as
until now. Since all the logic with replacing placeholders wit patterns
is done in mlt, the feature is completely transparent for kdenlive.
In mlt there are two solutions:
1) either TypeWrite is an external dependency and mlt uses
HADE_TYPEWRITER flag to decide whether compile in the code, or
2) put the library directly into mlt (just four files) but this will
prevent use of current development.
Anyway, TypeWriter is an optional (--enable-tw) feature and will not
interfere with regular installation.
To implement fully the feature one needs both kdenlive and mlt teams to
agree for it.
How does it work
---------------------------------------
Inside the xml document I implemented new nodes having following scheme,
e.g.:
<kdenlivetitle ...>
...
<patterns version="1">
<pattern name="aaa">
<text>E,x,a,m,p,l,e</text>
... additional fields possible in further versions
</pattern>
</patterns>
</kdenlivetitle>
The item part then looks following:
<item ...><content>@{aaa}@</content></item>
which in case that TW is not supported by mlt, will display just @{aaa}@
in the rendered scene.
If mlt uses TW, then 'aaa' will be replaced in consecutive frames with
'Example', letter by letter.
So the patterns part can be implemented in kdenlive, and will be
transparent for mlt, it will eventually not use.
Modified code of kdenlive available here:
https://github.com/rlalik/kdenlive_tw/tree/typewriter
and of mlt:
https://github.com/rlalik/mlt_tw/tree/typewriter
Please tell me your though about it and how would you like to proceed. I
can then eventually merge the code of derived classes in kdenlive into
basic classes and present as a pull request. The code for mlt actually
is already in its final state, could be already present as a pull request.
Regards,
Rafal
More information about the kdenlive
mailing list