2019-08-12 08:58:24 -04:00
|
|
|
/**
|
|
|
|
|
* @file
|
2019-08-14 10:22:29 -04:00
|
|
|
* @brief Source file for QtHtmlReader Example (example app for libopenshot)
|
2019-08-12 08:58:24 -04:00
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
2019-08-14 10:22:29 -04:00
|
|
|
* @author FeRD (Frank Dana) <ferdnyc@gmail.com>
|
2019-08-12 08:58:24 -04:00
|
|
|
*
|
|
|
|
|
* @ref License
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* LICENSE
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2008-2019 OpenShot Studios, LLC
|
|
|
|
|
* <http://www.openshotstudios.com/>. 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 <http://www.openshot.org/>.
|
|
|
|
|
*
|
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <memory>
|
2019-08-12 11:54:13 -04:00
|
|
|
#include <QGuiApplication>
|
2019-08-13 17:21:15 -04:00
|
|
|
#include <QTimer>
|
2019-08-12 08:58:24 -04:00
|
|
|
|
2020-08-07 00:49:36 -04:00
|
|
|
#include "../../include/OpenShot.h"
|
|
|
|
|
#include "../../include/CrashHandler.h"
|
|
|
|
|
|
2019-08-12 08:58:24 -04:00
|
|
|
using namespace openshot;
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
|
|
2019-08-13 17:21:15 -04:00
|
|
|
QGuiApplication app(argc, argv);
|
2019-08-12 08:58:24 -04:00
|
|
|
|
2019-08-25 23:54:28 -04:00
|
|
|
std::string html_code = R"html(<p><span id="red">Check out</span> this HTML!</p>)html";
|
2019-08-14 12:18:49 -04:00
|
|
|
|
2019-08-25 23:54:28 -04:00
|
|
|
std::string css_code = R"css(
|
|
|
|
|
* {font-family:sans-serif; font-size:18pt; color:#ffffff;}
|
|
|
|
|
#red {color: #ff0000;}
|
|
|
|
|
)css";
|
|
|
|
|
|
|
|
|
|
// Create a reader to generate an openshot::Frame containing text
|
|
|
|
|
QtHtmlReader r(1280, // width
|
|
|
|
|
720, // height
|
|
|
|
|
-16, // x_offset
|
|
|
|
|
-16, // y_offset
|
|
|
|
|
GRAVITY_BOTTOM_RIGHT, // gravity
|
|
|
|
|
html_code, // html
|
|
|
|
|
css_code, // css
|
|
|
|
|
"#000000" // background_color
|
|
|
|
|
);
|
2019-08-13 17:21:15 -04:00
|
|
|
|
|
|
|
|
r.Open(); // Open the reader
|
|
|
|
|
|
|
|
|
|
r.DisplayInfo();
|
2019-08-12 08:58:24 -04:00
|
|
|
|
|
|
|
|
/* WRITER ---------------- */
|
2019-08-14 12:18:49 -04:00
|
|
|
FFmpegWriter w("cppHtmlExample.mp4");
|
2019-08-12 08:58:24 -04:00
|
|
|
|
|
|
|
|
// Set options
|
2019-08-14 12:18:49 -04:00
|
|
|
//w.SetAudioOptions(true, "libmp3lame", r.info.sample_rate, r.info.channels, r.info.channel_layout, 128000);
|
2019-08-25 23:54:28 -04:00
|
|
|
w.SetVideoOptions(true, "libx264", Fraction(30000, 1000), 1280, 720, Fraction(1, 1), false, false, 3000000);
|
2019-08-12 08:58:24 -04:00
|
|
|
|
2019-08-14 12:18:49 -04:00
|
|
|
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!";
|
2019-08-12 08:58:24 -04:00
|
|
|
|
|
|
|
|
// Open writer
|
2019-08-14 12:18:49 -04:00
|
|
|
w.Open();
|
2019-08-12 08:58:24 -04:00
|
|
|
|
2019-08-25 23:54:28 -04:00
|
|
|
for (long int frame = 1; frame <= 100; ++frame)
|
2019-08-12 08:58:24 -04:00
|
|
|
{
|
2019-08-13 17:21:15 -04:00
|
|
|
std::shared_ptr<Frame> f = r.GetFrame(frame); // Same frame every time
|
2019-08-14 12:18:49 -04:00
|
|
|
w.WriteFrame(f);
|
2019-08-12 08:58:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Close writer & reader
|
2019-08-14 12:18:49 -04:00
|
|
|
w.Close();
|
2019-08-12 08:58:24 -04:00
|
|
|
r.Close();
|
|
|
|
|
|
2019-08-13 17:21:15 -04:00
|
|
|
// Set a timer with 0 timeout to terminate immediately after
|
|
|
|
|
// processing events
|
|
|
|
|
QTimer::singleShot(0, &app, SLOT(quit()));
|
2019-08-12 08:58:24 -04:00
|
|
|
|
2019-08-13 17:21:15 -04:00
|
|
|
// Run QGuiApplication to completion
|
|
|
|
|
return app.exec();
|
2019-08-12 08:58:24 -04:00
|
|
|
}
|