-
Notifications
You must be signed in to change notification settings - Fork 1
/
mlt_avantika_title.cpp
85 lines (68 loc) · 1.78 KB
/
mlt_avantika_title.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
//
// Created by user on 4/23/23.
//
#include "cxxopts.hpp"
#include <Mlt.h>
#include <iostream>
#if defined(__cplusplus)
extern "C" {
#endif
#include <SDL2/SDL.h>
#if defined(__cplusplus)
};
#endif
using namespace Mlt;
using namespace std;
void play(const string &pango_file_path) {
Profile profile;
Producer producer(profile, NULL, pango_file_path.c_str());
Consumer consumer(profile, NULL, nullptr);
consumer.set("real_time", 1);
consumer.set("terminate_on_pause", 1);
consumer.connect(producer);
consumer.start();
while (!consumer.is_stopped()) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
producer.set("done", 1);
consumer.stop();
break;
}
}
}
}
int main(int argc, char **argv) {
char *mlt_repository = getenv("MLT_REPOSITORY");
if (mlt_repository == nullptr) {
std::cout << "MLT_REPOSITORY is not set" << std::endl;
exit(1);
}
char *mlt_data = getenv("MLT_DATA");
if (mlt_data == nullptr) {
std::cout << "MLT_DATA is not set" << std::endl;
exit(1);
}
Factory::init(mlt_repository);
try {
cxxopts::Options options("mlt_avantika_title", "MLT avantika title");
options.add_options()("f,filename", "Pango filename",
cxxopts::value<string>());
auto result = options.parse(argc, argv);
string pango_file_path;
if (result.count("filename")) {
pango_file_path = result["filename"].as<string>();
}
if (pango_file_path.empty()) {
std::cerr << "pango file path invalid\n";
return -1;
}
play(pango_file_path);
} catch (const cxxopts::exceptions::exception &e) {
std::cout << "error parsing options: " << e.what() << std::endl;
exit(1);
}
Factory::close();
return 0;
}