From 0d067b33a316c61ce9ba403545e5af15c32bb1b3 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Wed, 14 Aug 2019 10:22:29 -0400 Subject: [PATCH] new ExampleHtml.py and updated ExampleHtml.cpp --- src/examples/ExampleHtml.cpp | 3 +- src/examples/ExampleHtml.py | 88 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100755 src/examples/ExampleHtml.py diff --git a/src/examples/ExampleHtml.cpp b/src/examples/ExampleHtml.cpp index 96e98e2a..26ec42be 100644 --- a/src/examples/ExampleHtml.cpp +++ b/src/examples/ExampleHtml.cpp @@ -1,7 +1,8 @@ /** * @file - * @brief Source file for Example Executable (example app for libopenshot) + * @brief Source file for QtHtmlReader Example (example app for libopenshot) * @author Jonathan Thomas + * @author FeRD (Frank Dana) * * @ref License */ diff --git a/src/examples/ExampleHtml.py b/src/examples/ExampleHtml.py new file mode 100755 index 00000000..116df0ca --- /dev/null +++ b/src/examples/ExampleHtml.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 + +""" + @file + @brief Python source file for QtHtmlReader example + @author Jonathan Thomas + @author FeRD (Frank Dana) + + @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 . + +import sys +from PyQt5.QtCore import QTimer +from PyQt5.QtGui import QGuiApplication +import openshot + +app = QGuiApplication(sys.argv) + +html_code = "Check out this Text!" + +# Create a QtHtmlReader +r = openshot.QtHtmlReader(720, + 480, + 5, + 5, + openshot.GRAVITY_CENTER, + html_code, + "b { color: #ff0000; }", + "#000000" + ) + +r.Open() # Open the reader + +r.DisplayInfo() # Display metadata + +# Set up Writer +w = openshot.FFmpegWriter("/var/tmp/pyHtmlExample.mp4") + +w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 720, 480, + openshot.Fraction(1, 1), False, False, 3000000) + +w.info.metadata["title"] = "testtest"; +w.info.metadata["artist"] = "aaa"; +w.info.metadata["album"] = "bbb"; +w.info.metadata["year"] = "2015"; +w.info.metadata["description"] = "ddd"; +w.info.metadata["comment"] = "eee"; +w.info.metadata["comment"] = "comment"; +w.info.metadata["copyright"] = "copyright OpenShot!"; + +# Open the Writer +w.Open() + +# Grab 30 frames from Reader and encode to Writer +for i in range(30): + f = r.GetFrame(i) + w.WriteFrame(f) + +# Close out Reader & Writer +w.Close() +r.Close() + +# Set a timer to terminate the app as soon as the event queue empties +QTimer.singleShot(0, app.quit) + +# Run QGuiApplication to completion +sys.exit(app.exec())