-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfilterplayer.cpp
112 lines (80 loc) · 2.91 KB
/
filterplayer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
Taken from http://ubuntuforums.org/showthread.php?p=7370184
Adapted fixing crashes & cleanup by Harry van Haaren 2013
Filtering added by Harry van Haaren, 2013
MLT++ Filter Player Example
g++ filterplayer.cpp -I/usr/include/mlt -I/usr/include/mlt++ -lmlt++ -lmlt -o filterplayer
Usage: filterplayer <file>
*/
// this filterplayer is based on simpleplayer.cpp, if you haven't looked at that
// yet, do so before looking here. These comments only explain the increment
// between the files.
// So we add a greyscale filter, the new video chain now looks like this:
// producer -> filter -> consumer
// the consumer still requests data, but does so from the filter, and the filter
// in turn requests data from the producer.
// See this link for a full list of filter plugins available
// http://www.mltframework.org/bin/view/MLT/PluginsFilters
#include <iostream>
#include <unistd.h>
#include <Mlt.h>
using namespace std;
int main( int argc, char *argv[] )
{
Mlt::Repository *repository;
// initialise the factory
repository = Mlt::Factory::init();
if ( not repository )
{
cout << "Unable to locate factory modules" << endl;
}
Mlt::Profile *profile;
Mlt::Consumer *consumer;
Mlt::Filter *filter;
Mlt::Producer *producer;
profile = new Mlt::Profile();
// Create the default consumer
consumer = new Mlt::Consumer( *profile,"sdl");
// try out some different filters?
filter = new Mlt::Filter ( *profile, "greyscale");
//filter = new Mlt::Filter ( *profile, "invert");
//filter = new Mlt::Filter ( *profile, "tcolor");
//filter = new Mlt::Filter ( *profile, "threshold");
// the pixeliz0r filter has two properties:
// BlockSizeX
// BlockSizeY
// we can set them trough the generic .set( "name" , value ); method
// that belongs to "Service", implemented trough the Properties class.
// char*, int, double and void* are the datatypes allowed.
// check the filters metadata as to what it expects for each name
// http://www.mltframework.org/bin/view/MLT/FilterFrei0r-pixeliz0r
if ( false ) // change to true to enable filter
{
filter = new Mlt::Filter ( *profile, "frei0r.pixeliz0r");
filter->set( "BlockSizeX", 0.1 );
filter->set( "BlockSizeY", 0.1 );
}
if ( !filter )
cout << "Error creating filter! " << endl;
else
cout << "Filter created successfully" << endl;
// Create via the default producer
producer = new Mlt::Producer( *profile,NULL, argv[ 1 ] );
filter->connect( *producer );
// Connect the producer to the consumer
consumer->connect(*filter);
// Start the consumer
consumer->start();
// Wait for the consumer to terminate
while( !consumer->is_stopped() )
sleep( 1 );
// Close the consumer
delete(consumer);
// Close the producer
delete(producer);
// Close the filter
delete(filter);
// Close the factory
Mlt::Factory::close();
return 0;
}