On Sat, Nov 20, 2021 at 2:01 PM José María García Pérez <
josemaria.alk...@gmail.com> wrote:

> There are a few things under the hood:
> 1. I have several `connect` functions which have different type signatures:
>     - For filter:
> https://github.com/mantielero/mlt.nim/blob/51245b9fea6ad1555687ff9229c66ca17a6d3ffb/src/lib/filter.nim#L5-L8
>     - For consumer:
> https://github.com/mantielero/mlt.nim/blob/51245b9fea6ad1555687ff9229c66ca17a6d3ffb/src/lib/consumer.nim#L30-L33
> For this functions, I just map: `mlt_filter_connect` with the equivalent
> signature.
>

Oh, that is designed more for use in multitrack scenarios, but I guess that
works. I kind of forgot about it, because it is mainly used by
mlt_field_plant_filter(), which is the more commonly used function in
multitrack command lines, for example, `melt -filter`.


> 2. Given that they work with Service, I just create a number of
> converters. In nim converters, are used to change type automatically. You
> can see for example the following which coverts from Producer to Service
> automatically:
>
> https://github.com/mantielero/mlt.nim/blob/51245b9fea6ad1555687ff9229c66ca17a6d3ffb/src/lib/producer.nim#L8-L10
> This enables using a `Producer` directly with the `connect` function
> without the need of getting previously the Service (that is done
> implicitly).
> 3. I just create the `>` operators in a way that for me make more sense
> visually: from the producer to the consumer. They just call `connect`.
>
> I have wrapped the `mlt_service_attach` function (I wasn't aware of it).
> So now, the following works as well:
>

This corresponds to the `melt -attach` option, and Shotcut uses only this
approach even in multitrack scenarios - attaching to clips, consumer, and
playlists that represent tracks.


> ```
> clip.attach( filter )
> clip > sdl
> ```
>
> https://github.com/mantielero/mlt.nim/blob/master/examples/ex05_filter_frei0r_attach.nim
>
>
> PS: sorry if the wording is not right. I am not a pro developer.
> Regards,
> José M.
>
> El sáb, 20 nov 2021 a las 20:34, Dan Dennedy (<d...@dennedy.org>) escribió:
>
>> Thanks for sharing that. Read more below...
>>
>> On Sat, Nov 20, 2021 at 8:54 AM José María García Pérez <
>> josemaria.alk...@gmail.com> wrote:
>>
>>> I implemented some examples in the Nim programming language. Nim
>>> compiles into C (among other languages).
>>>
>>> I like that it gives you the feeling of python despite it is using
>>> actual types.
>>>
>>> The code looks as follows:
>>> ```
>>> import mlt, os
>>> var f = initFactory()
>>>
>>> # Create the default consumer
>>> var p = newProfile()
>>> var sdl = newFactoryConsumer(p, "sdl2")
>>>
>>> # Create via the default producer
>>> var clip = newFactoryProducer(p, resource =
>>> "avformat:/home/jose/Descargas/sygic.mp4")
>>>
>>> var filter = newFactoryFilter(p, "frei0r.pixeliz0r")
>>> filter["BlockSizeX"] = 0.1
>>> filter["BlockSizeY"] = 0.2
>>>
>>> clip > filter
>>> filter > sdl
>>>
>>>
>>
>> So, the > operator is mapped to both mlt_service_connect_producer() and
>> mlt_service_attach()? I do not understand how the sdl consumer is
>> connecting to the filter because the filter should be *attached* to the
>> producer, and the consumer *connected* to the producer.
>>
>>
>>
>>> # Start the consumer
>>> sdl.start
>>>
>>> while not sdl.stopped:
>>> sleep(1)
>>> ```
>>> As I said, it compiles to C. If compiled in release mode, the executable
>>> only takes 115kb.
>>>
>>> This is just a starting point. You can see some more examples here:
>>> https://github.com/mantielero/mlt.nim/tree/master/examples
>>>
>>> Regards,
>>> José María
>>>
>>>
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to