MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / main

Function main

examples/ExampleHtml.cpp:28–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26using namespace openshot;
27
28int main(int argc, char* argv[]) {
29
30 QGuiApplication app(argc, argv);
31
32 std::string html_code = R"html(<p><span id="red">Check out</span> this HTML!</p>)html";
33
34 std::string css_code = R"css(
35 * {font-family:sans-serif; font-size:18pt; color:#ffffff;}
36 #red {color: #ff0000;}
37 )css";
38
39// Create a reader to generate an openshot::Frame containing text
40QtHtmlReader r(1280, // width
41 720, // height
42 -16, // x_offset
43 -16, // y_offset
44 GRAVITY_BOTTOM_RIGHT, // gravity
45 html_code, // html
46 css_code, // css
47 "#000000" // background_color
48 );
49
50 r.Open(); // Open the reader
51
52 r.DisplayInfo();
53
54 /* WRITER ---------------- */
55 FFmpegWriter w("cppHtmlExample.mp4");
56
57 // Set options
58 //w.SetAudioOptions(true, "libmp3lame", r.info.sample_rate, r.info.channels, r.info.channel_layout, 128000);
59 w.SetVideoOptions(true, "libx264", Fraction(30000, 1000), 1280, 720, Fraction(1, 1), false, false, 3000000);
60
61 w.info.metadata["title"] = "testtest";
62 w.info.metadata["artist"] = "aaa";
63 w.info.metadata["album"] = "bbb";
64 w.info.metadata["year"] = "2015";
65 w.info.metadata["description"] = "ddd";
66 w.info.metadata["comment"] = "eee";
67 w.info.metadata["comment"] = "comment";
68 w.info.metadata["copyright"] = "copyright OpenShot!";
69
70 // Open writer
71 w.Open();
72
73 for (long int frame = 1; frame <= 100; ++frame)
74 {
75 std::shared_ptr<Frame> f = r.GetFrame(frame); // Same frame every time
76 w.WriteFrame(f);
77 }
78
79 // Close writer & reader
80 w.Close();
81 r.Close();
82
83 // Set a timer with 0 timeout to terminate immediately after
84 // processing events
85 QTimer::singleShot(0, &app, SLOT(quit()));

Callers

nothing calls this directly

Calls 7

FractionClass · 0.85
OpenMethod · 0.45
DisplayInfoMethod · 0.45
SetVideoOptionsMethod · 0.45
GetFrameMethod · 0.45
WriteFrameMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected