From 140b5fdad3e0a6bcb3d7c2d58a8478ca5ed8c153 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 12 Aug 2019 08:58:24 -0400 Subject: [PATCH] Add src/examples/ExampleHtml.cpp test program --- src/CMakeLists.txt | 5 +- src/examples/ExampleHtml.cpp | 89 ++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/examples/ExampleHtml.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55a13484..1daacf1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -371,13 +371,16 @@ ENDIF(WIN32) target_link_libraries(openshot ${REQUIRED_LIBRARIES}) -############### CLI EXECUTABLE ################ +############### CLI EXECUTABLES ################ # Create test executable add_executable(openshot-example examples/Example.cpp) # Link test executable to the new library target_link_libraries(openshot-example openshot) +add_executable(openshot-html-test examples/ExampleHtml.cpp) +target_link_libraries(openshot-html-test openshot) + ############### PLAYER EXECUTABLE ################ # Create test executable add_executable(openshot-player Qt/demo/main.cpp) diff --git a/src/examples/ExampleHtml.cpp b/src/examples/ExampleHtml.cpp new file mode 100644 index 00000000..0148b6f7 --- /dev/null +++ b/src/examples/ExampleHtml.cpp @@ -0,0 +1,89 @@ +/** + * @file + * @brief Source file for Example Executable (example app for libopenshot) + * @author Jonathan Thomas + * + * @ref License + */ + +/* LICENSE + * + * Copyright (c) 2008-2019 OpenShot Studios, LLC + * . This file is part of + * OpenShot Library (libopenshot), an open-source project dedicated to + * delivering high quality video editing and animation solutions to the + * world. For more information visit . + * + * OpenShot Library (libopenshot) is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * OpenShot Library (libopenshot) is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with OpenShot Library. If not, see . + */ + +#include +#include +#include +#include "../../include/OpenShot.h" +//#include "../../include/CrashHandler.h" + +using namespace openshot; + +int main(int argc, char* argv[]) { + + // Create a reader to generate an openshot::Frame containing text + QtHtmlReader r(720, // width + 480, // height + 5, // x_offset + 5, // y_offset + GRAVITY_CENTER, // gravity + "Check out this Text!", // html + "#000000" // background_color + ); + r.Open(); // Open the reader + + // XXX: Not implemented + // r.DisplayInfo(); + + /* WRITER ---------------- */ + FFmpegWriter w9("/var/tmp/metadata.mp4"); + + // Set options + //w9.SetAudioOptions(true, "libmp3lame", r.info.sample_rate, r9.info.channels, r9.info.channel_layout, 128000); + w9.SetVideoOptions(true, "libx264", Fraction{30000, 1000}, 720, 480, Fraction(1,1), false, false, 3000000); + + w9.info.metadata["title"] = "testtest"; + w9.info.metadata["artist"] = "aaa"; + w9.info.metadata["album"] = "bbb"; + w9.info.metadata["year"] = "2015"; + w9.info.metadata["description"] = "ddd"; + w9.info.metadata["comment"] = "eee"; + w9.info.metadata["comment"] = "comment"; + w9.info.metadata["copyright"] = "copyright OpenShot!"; + + // Open writer + w9.Open(); + + for (long int frame = 1; frame <= 30; frame++) + { + std::shared_ptr f = r.GetFrame(1); // Same frame every time + w9.WriteFrame(f); + } + + // Close writer & reader + w9.Close(); + + // Close timeline + r.Close(); + + cout << "Completed successfully!" << endl; + + return 0; +}