From a4b2af4eb80c1d7c1a81dddf92ab97725c0720ad Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 5 Jun 2025 19:38:53 -0500 Subject: [PATCH] Adding FFmpegWriter into openshot-example executable to test with valgrind heapgrind. --- examples/Example.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/Example.cpp b/examples/Example.cpp index 150ee63a..6c74c0c2 100644 --- a/examples/Example.cpp +++ b/examples/Example.cpp @@ -15,6 +15,7 @@ #include #include "Frame.h" #include "FFmpegReader.h" +#include "FFmpegWriter.h" using namespace openshot; @@ -27,6 +28,22 @@ int main(int argc, char* argv[]) { const long int total_frames = r.info.video_length; + + // Reader + std::stringstream writer_path; + writer_path << TEST_MEDIA_PATH << "sintel_trailer-720p.mp4"; + + /* WRITER ---------------- */ + FFmpegWriter w("/home/jonathan/Downloads/performance-test.mp4"); + + // Set options + w.SetAudioOptions("aac", 48000, 192000); + w.SetVideoOptions("libx264", 1280, 720, Fraction(30,1), 5000000); + + // Open writer + w.Open(); + + // --- Measure forward pass --- auto t0 = std::chrono::high_resolution_clock::now(); for (long int frame = 1; frame <= total_frames; frame++) { @@ -34,7 +51,7 @@ int main(int argc, char* argv[]) { std::cout << "Forward: Requesting Frame #: " << frame << " (" << percent << "%)\n"; std::shared_ptr f = r.GetFrame(frame); - // (optional) preview or process f here + w.WriteFrame(f); } auto t1 = std::chrono::high_resolution_clock::now(); auto forward_ms = std::chrono::duration_cast(t1 - t0).count(); @@ -46,7 +63,7 @@ int main(int argc, char* argv[]) { std::cout << "Backward: Requesting Frame #: " << frame << " (" << percent << "%)\n"; std::shared_ptr f = r.GetFrame(frame); - // (optional) preview or process f here + w.WriteFrame(f); } auto t3 = std::chrono::high_resolution_clock::now(); auto backward_ms = std::chrono::duration_cast(t3 - t2).count(); @@ -55,5 +72,6 @@ int main(int argc, char* argv[]) { std::cout << "Backward pass elapsed: " << backward_ms << " ms\n"; r.Close(); + w.Close(); return 0; }