2013-09-12 23:41:49 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
2015-02-07 16:48:43 -06:00
|
|
|
* @brief Source file for Example Executable (example app for libopenshot)
|
2013-09-12 23:41:49 -05:00
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
2019-06-09 08:31:04 -04:00
|
|
|
* @ref License
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* LICENSE
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2019-06-11 06:48:32 -04:00
|
|
|
* Copyright (c) 2008-2019 OpenShot Studios, LLC
|
2014-03-29 18:49:22 -05:00
|
|
|
* <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/>.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
2014-07-11 16:52:14 -05:00
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* as published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* 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
|
2014-07-11 16:52:14 -05:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-09-12 23:41:49 -05:00
|
|
|
*
|
2014-07-11 16:52:14 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-12 23:41:49 -05:00
|
|
|
*/
|
2011-10-11 08:44:27 -05:00
|
|
|
|
2012-07-19 15:03:55 -05:00
|
|
|
#include <fstream>
|
2011-10-11 08:44:27 -05:00
|
|
|
#include <iostream>
|
2017-08-20 17:37:39 -05:00
|
|
|
#include <memory>
|
2015-02-07 16:48:43 -06:00
|
|
|
#include "../../include/OpenShot.h"
|
2017-08-20 17:37:39 -05:00
|
|
|
#include "../../include/CrashHandler.h"
|
2013-11-17 15:12:08 -06:00
|
|
|
|
2011-10-11 08:44:27 -05:00
|
|
|
using namespace openshot;
|
|
|
|
|
|
2015-06-01 00:20:14 -07:00
|
|
|
|
2017-08-01 01:19:07 -05:00
|
|
|
int main(int argc, char* argv[]) {
|
2016-02-23 00:27:03 -06:00
|
|
|
|
2019-04-28 14:03:45 -05:00
|
|
|
Settings *s = Settings::Instance();
|
|
|
|
|
s->HARDWARE_DECODER = 2; // 1 VA-API, 2 NVDEC
|
2019-06-04 13:42:46 -05:00
|
|
|
s->HW_DE_DEVICE_SET = 0;
|
2019-04-28 14:03:45 -05:00
|
|
|
|
2019-09-13 07:48:57 -04:00
|
|
|
std::string input_filepath = TEST_MEDIA_PATH;
|
|
|
|
|
input_filepath += "sintel_trailer-720p.mp4";
|
|
|
|
|
|
|
|
|
|
FFmpegReader r9(input_filepath);
|
2018-03-04 03:10:59 -06:00
|
|
|
r9.Open();
|
|
|
|
|
r9.DisplayInfo();
|
2016-02-23 00:27:03 -06:00
|
|
|
|
2018-03-04 03:10:59 -06:00
|
|
|
/* WRITER ---------------- */
|
2019-09-13 07:48:57 -04:00
|
|
|
FFmpegWriter w9("metadata.mp4");
|
2016-02-23 00:27:03 -06:00
|
|
|
|
2018-03-04 03:10:59 -06:00
|
|
|
// Set options
|
|
|
|
|
w9.SetAudioOptions(true, "libmp3lame", r9.info.sample_rate, r9.info.channels, r9.info.channel_layout, 128000);
|
|
|
|
|
w9.SetVideoOptions(true, "libx264", r9.info.fps, 1024, 576, Fraction(1,1), false, false, 3000000);
|
2015-09-28 22:05:50 -05:00
|
|
|
|
2018-03-04 03:10:59 -06:00
|
|
|
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!";
|
2015-09-28 22:05:50 -05:00
|
|
|
|
2018-03-04 03:10:59 -06:00
|
|
|
// Open writer
|
|
|
|
|
w9.Open();
|
|
|
|
|
|
|
|
|
|
for (long int frame = 1; frame <= 100; frame++)
|
|
|
|
|
{
|
|
|
|
|
//int frame_number = (rand() % 750) + 1;
|
|
|
|
|
int frame_number = frame;
|
|
|
|
|
std::shared_ptr<Frame> f = r9.GetFrame(frame_number);
|
|
|
|
|
w9.WriteFrame(f);
|
2017-08-20 17:37:39 -05:00
|
|
|
}
|
2015-06-01 00:20:14 -07:00
|
|
|
|
2018-03-04 03:10:59 -06:00
|
|
|
// Close writer & reader
|
|
|
|
|
w9.Close();
|
|
|
|
|
|
|
|
|
|
// Close timeline
|
|
|
|
|
r9.Close();
|
|
|
|
|
|
|
|
|
|
cout << "Completed successfully!" << endl;
|
2015-02-05 00:06:07 -06:00
|
|
|
|
2017-08-01 01:19:07 -05:00
|
|
|
return 0;
|
2019-09-13 07:48:57 -04:00
|
|
|
}
|