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

Function main

examples/Example.cpp:25–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23using namespace openshot;
24
25int main(int argc, char* argv[]) {
26 using clock = std::chrono::high_resolution_clock;
27 auto total_start = clock::now();
28
29 const std::string output_dir = "/home/jonathan/Downloads";
30 const std::string input_paths[] = {
31 "/home/jonathan/Videos/3.4 Release/Screencasts/Timing.mp4",
32 "/home/jonathan/Downloads/openshot-testing/sintel_trailer-720p.mp4"
33 };
34 const int64_t frames_to_fetch[] = {175, 225, 240, 500, 1000};
35 const bool use_hw_decode = false;
36
37 std::cout << "Hardware decode: " << (use_hw_decode ? "ON" : "OFF") << "\n";
38 openshot::Settings::Instance()->HARDWARE_DECODER = use_hw_decode ? 1 : 0;
39
40 for (const std::string& input_path : input_paths) {
41 auto file_start = clock::now();
42 std::string base = input_path;
43 size_t slash = base.find_last_of('/');
44 if (slash != std::string::npos) {
45 base = base.substr(slash + 1);
46 }
47
48 std::cout << "\n=== File: " << base << " ===\n";
49
50 auto t0 = clock::now();
51 FFmpegReader reader(input_path.c_str());
52 auto t1 = clock::now();
53 std::cout << "FFmpegReader ctor: "
54 << std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0).count()
55 << " ms\n";
56
57 auto t2 = clock::now();
58 reader.Open();
59 auto t3 = clock::now();
60 std::cout << "FFmpegReader Open(): "
61 << std::chrono::duration_cast<std::chrono::milliseconds>(t3 - t2).count()
62 << " ms\n";
63
64 auto t4 = clock::now();
65 Timeline timeline(1920, 1080, Fraction(30, 1), reader.info.sample_rate, reader.info.channels, reader.info.channel_layout);
66 timeline.SetMaxSize(640, 480);
67 auto t5 = clock::now();
68 std::cout << "Timeline ctor (1080p30): "
69 << std::chrono::duration_cast<std::chrono::milliseconds>(t5 - t4).count()
70 << " ms\n";
71
72 auto t6 = clock::now();
73 Clip c1(&reader);
74 auto t7 = clock::now();
75 std::cout << "Clip ctor: "
76 << std::chrono::duration_cast<std::chrono::milliseconds>(t7 - t6).count()
77 << " ms\n";
78
79 timeline.AddClip(&c1);
80
81 auto t8 = clock::now();
82 timeline.Open();

Callers

nothing calls this directly

Calls 7

FractionClass · 0.85
SetMaxSizeMethod · 0.80
AddClipMethod · 0.80
ThumbnailMethod · 0.80
OpenMethod · 0.45
GetFrameMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected