I managed to write a pure C example, and I am getting something similar to
what I get with NIm:
// $ gcc ex02.c -I/usr/include/mlt-7 -lmlt-7 -o ex02
// Inspired by:
https://stackoverflow.com/questions/62983626/how-to-compile-a-simple-mlt-example-in-c
#include <stdio.h>
#include <unistd.h>
#include <framework/mlt.h>

int main( int argc, char *argv[] )
{
// Initialise the factory
if ( mlt_factory_init( "/usr/lib/mlt-7" ) > 0 )
{
mlt_profile p = mlt_profile_init("hdv_720_50p");
// Create the default consumer
mlt_consumer hello = mlt_factory_consumer( p, "sdl2", NULL );
mlt_properties_set_int(mlt_consumer_properties(hello), "terminate_on_pause",
1);

// Create via the default producer
mlt_producer world = mlt_factory_producer( p, NULL, argv[ 1 ] );

// Create filter
mlt_filter aff = mlt_factory_filter( p, "affine", NULL );

mlt_properties affprop = mlt_filter_properties(aff);
for(int i=0; i<mlt_properties_count(affprop); ++i) {
printf( "%d %s",i, mlt_properties_get_name(affprop, i ) );
printf("\n");
}

// if (mlt_properties_exists(mlt_filter_properties(aff), "background") > 0)
{
// printf("background exists\n");
// }
int res = mlt_service_attach(mlt_producer_service(world), aff);


// Connect the producer to the consumer
mlt_consumer_connect( hello, mlt_producer_service( world ) );

// Start the consumer
mlt_consumer_start( hello );


// Wait for the consumer to terminate
while( !mlt_consumer_is_stopped( hello ) )
sleep( 1 );

// Close the consumer
mlt_consumer_close( hello );

// Close the producer
mlt_producer_close( world );

// Close the factory
mlt_factory_close( );
}
else
{
// Report an error during initialisation
fprintf( stderr, "Unable to locate factory modules\n" );
}

// End of program
return 0;
}

With this example I get:
$ gcc ex02.c -I/usr/include/mlt-7 -lmlt-7 -o ex02
$ ./ex02 example.mp4
0 _events
1 mlt_type
2 in
3 out
4 background
5 _unique_id
6 mlt_service
7 _profile

As I said, I cannot see neither  "transition" nor "use_normalised". What do
I need to do in C language to make them appear?

Kind regards,
José M.

El vie, 31 dic 2021 a las 9:24, José María García Pérez (<
josemaria.alk...@gmail.com>) escribió:

> I think that my problem is that I am not handling properly nested
> properties, but before that I don't see the keys a would expect for the
> "affine" filter:
>
> When I print the keys for the affine filter, I get the following:
>
> _events
> mlt_type
> in
> out
> background
> _unique_id
> mlt_service
> _profile
>
> I am not seeing neither "transition" nor "use_normalised" keys that I
> would expect in accordance with
> https://www.mltframework.org/plugins/FilterAffine/#transition.
>
> Any clue about what might be going on?
>
>
> El jue, 30 dic 2021 a las 19:53, José María García Pérez (<
> josemaria.alk...@gmail.com>) escribió:
>
>> I was expecting a rotated image. The output was the video unmodified.
>>
>> El jue, 30 dic 2021 a las 19:52, Brian Matherly (<
>> brian.mathe...@yahoo.com>) escribió:
>>
>>> > My first attempt wasn't very successful
>>>
>>> What result did you expect, and what was the actual result?
>>>
>>> On Thursday, December 30, 2021, 12:28:42 PM CST, José María García Pérez
>>> <josemaria.alk...@gmail.com> wrote:
>>>
>>>
>>> I wasn't aware about Shotcut doing so. Good to know.
>>>
>>> My first attempt wasn't very successful. I did the following:
>>> # nim c --threads:on -r ex23_loader_video
>>> import mlt
>>> import os
>>> let f = initFactory("/usr/lib/mlt-7")
>>>
>>> # Create the consumer
>>> let p = newProfile("hdv_720_50p")
>>> var sdl = newFactoryConsumer(p, "sdl2")
>>>
>>> sdl["terminate_on_pause"] = 1 # Stop the consumer when finished
>>>
>>> # Create via the default producer
>>> var clip1 = p.newMedia( "./resources/sygic.mp4")
>>>
>>>
>>> var filter = newFactoryFilter(p, "affine")
>>> filter["transition.fill"] = 1
>>> filter["transition.distort"] = 0
>>> filter["transition.rect"] = "339.703 126.468 1430.3 953.532 1"
>>> filter["transition.valign"] = "middle"
>>> filter["transition.halign"] = "center"
>>> filter["transition.threads"] = 0
>>> filter["transition.fix_rotate_x"] = 340.0
>>>
>>> #[
>>> <property name="background">color:#00000000</property>
>>> <property name="mlt_service">affine</property>
>>> <property name="shotcut:filter">affineSizePosition</property>
>>> <property name="transition.fill">1</property>
>>> <property name="transition.distort">0</property>
>>> <property name="transition.rect">339.703 126.468 1430.3 953.532
>>> 1</property>
>>> <property name="transition.valign">middle</property>
>>> <property name="transition.halign">center</property>
>>> <property name="shotcut:animIn">00:00:00.000</property>
>>> <property name="shotcut:animOut">00:00:00.000</property>
>>> <property name="transition.threads">0</property>
>>> <property name="transition.fix_rotate_x">340.304</property>
>>>
>>> ]#
>>> clip1.attach(filter)
>>> clip1 > sdl
>>>
>>> sdl.start # Start the consumer
>>>
>>> while not sdl.stopped:
>>> sleep(1)
>>>
>>> Do you spot something obvious that might be wrong?
>>>
>>> El jue, 30 dic 2021 a las 18:52, Dan Dennedy (<d...@dennedy.org>)
>>> escribió:
>>>
>>> You can use a tool like Shotcut and study it’s XML output to understand
>>> the properties for a filter. The affine filter is called Size, Position &
>>> Rotate. To get the XML use File > Save.
>>>
>>> On Thu, Dec 30, 2021 at 9:47 AM José María García Pérez <
>>> josemaria.alk...@gmail.com> wrote:
>>>
>>> I don't understand how to use the affine filter:
>>> https://www.mltframework.org/plugins/FilterAffine/#transition
>>>
>>> Could you post a basic C example using it? It would be nice to cover
>>> both the static and an animation case.
>>>
>>> I had the following example about using a filter using Nim:
>>> 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.attach( filter )
>>> clip > sdl
>>>
>>> # Start the consumer
>>> sdl.start
>>>
>>> while not sdl.stopped:
>>> sleep(1)
>>> _______________________________________________
>>> Mlt-devel mailing list
>>> Mlt-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/mlt-devel
>>>
>>> _______________________________________________
>>> Mlt-devel mailing list
>>> Mlt-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/mlt-devel
>>>
>>
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to