| 59 | } |
| 60 | |
| 61 | int main(int argc, char* argv[]) { |
| 62 | const string base = TEST_MEDIA_PATH; |
| 63 | const string video = base + "sintel_trailer-720p.mp4"; |
| 64 | const string mask_img = base + "mask.png"; |
| 65 | const string overlay = base + "front3.png"; |
| 66 | benchmark::BenchmarkOptions options; |
| 67 | const int64_t chroma_bench_frames = 500; |
| 68 | |
| 69 | try { |
| 70 | vector<string> args; |
| 71 | args.reserve(std::max(0, argc - 1)); |
| 72 | for (int i = 1; i < argc; ++i) |
| 73 | args.emplace_back(argv[i]); |
| 74 | options = benchmark::ParseBenchmarkOptions(args); |
| 75 | } catch (const std::exception& e) { |
| 76 | cerr << e.what() << "\n"; |
| 77 | cerr << benchmark::BenchmarkUsage() << "\n"; |
| 78 | return 1; |
| 79 | } |
| 80 | |
| 81 | if (options.show_help) { |
| 82 | cout << benchmark::BenchmarkUsage() << "\n"; |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | // Route benchmark thread settings through libopenshot's Settings singleton, |
| 87 | // matching how an application should configure the library before opening readers. |
| 88 | Settings *settings = Settings::Instance(); |
| 89 | if (options.omp_threads > 0) { |
| 90 | settings->OMP_THREADS = options.omp_threads; |
| 91 | settings->ApplyOpenMPSettings(); |
| 92 | } |
| 93 | if (options.ff_threads > 0) { |
| 94 | settings->FF_THREADS = options.ff_threads; |
| 95 | } |
| 96 | |
| 97 | vector<Trial> trials; |
| 98 | trials.reserve(10); |
| 99 | |
| 100 | trials.emplace_back("FFmpegReader", [&]() { |
| 101 | FFmpegReader r(video); |
| 102 | r.Open(); |
| 103 | read_forward_backward(r); |
| 104 | r.Close(); |
| 105 | }); |
| 106 | |
| 107 | trials.emplace_back("FFmpegWriter", [&]() { |
| 108 | FFmpegReader r(video); |
| 109 | r.Open(); |
| 110 | FFmpegWriter w("benchmark_output.mp4"); |
| 111 | w.SetAudioOptions("aac", r.info.sample_rate, 192000); |
| 112 | w.SetVideoOptions("libx264", r.info.width, r.info.height, r.info.fps, |
| 113 | 5000000); |
| 114 | w.Open(); |
| 115 | for (int64_t i = 1; i <= r.info.video_length; ++i) |
| 116 | w.WriteFrame(r.GetFrame(i)); |
| 117 | w.Close(); |
| 118 | r.Close(); |
nothing calls this directly
no test coverage detected