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>
|
2021-03-31 19:35:58 -04:00
|
|
|
#include "Clip.h"
|
|
|
|
|
#include "Frame.h"
|
|
|
|
|
#include "FFmpegReader.h"
|
|
|
|
|
#include "Timeline.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
|
|
|
|
2021-02-17 19:44:44 -06:00
|
|
|
// Types for storing time durations in whole and fractional milliseconds
|
|
|
|
|
using ms = std::chrono::milliseconds;
|
|
|
|
|
using s = std::chrono::seconds;
|
|
|
|
|
using double_ms = std::chrono::duration<double, ms::period>;
|
2019-04-28 14:03:45 -05:00
|
|
|
|
2021-02-17 19:44:44 -06:00
|
|
|
// FFmpeg Reader performance test
|
|
|
|
|
const auto total_1 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
FFmpegReader r9("/home/jonathan/Videos/sintel_trailer-1080p.mp4");
|
2018-03-04 03:10:59 -06:00
|
|
|
r9.Open();
|
2021-02-17 19:44:44 -06:00
|
|
|
for (long int frame = 1; frame <= 1000; frame++)
|
2018-03-04 03:10:59 -06:00
|
|
|
{
|
2021-02-17 19:44:44 -06:00
|
|
|
const auto time1 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
std::shared_ptr<Frame> f = r9.GetFrame(frame);
|
|
|
|
|
const auto time2 = std::chrono::high_resolution_clock::now();
|
2021-03-31 19:35:58 -04:00
|
|
|
std::cout << "FFmpegReader: " << frame
|
|
|
|
|
<< " (" << double_ms(time2 - time1).count() << " ms)\n";
|
2017-08-20 17:37:39 -05:00
|
|
|
}
|
2021-02-17 19:44:44 -06:00
|
|
|
const auto total_2 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
auto total_sec = std::chrono::duration_cast<ms>(total_2 - total_1);
|
2021-03-31 19:35:58 -04:00
|
|
|
std::cout << "FFmpegReader TOTAL: " << total_sec.count() << " ms\n";
|
2018-03-04 03:10:59 -06:00
|
|
|
r9.Close();
|
|
|
|
|
|
2021-02-17 19:44:44 -06:00
|
|
|
|
|
|
|
|
// Timeline Reader performance test
|
2021-03-31 19:35:58 -04:00
|
|
|
Timeline tm(r9.info);
|
2021-02-17 19:44:44 -06:00
|
|
|
Clip *c = new Clip(&r9);
|
|
|
|
|
tm.AddClip(c);
|
|
|
|
|
tm.Open();
|
|
|
|
|
|
|
|
|
|
const auto total_3 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
for (long int frame = 1; frame <= 1000; frame++)
|
|
|
|
|
{
|
|
|
|
|
const auto time1 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
std::shared_ptr<Frame> f = tm.GetFrame(frame);
|
|
|
|
|
const auto time2 = std::chrono::high_resolution_clock::now();
|
2021-03-31 19:35:58 -04:00
|
|
|
std::cout << "Timeline: " << frame
|
|
|
|
|
<< " (" << double_ms(time2 - time1).count() << " ms)\n";
|
2021-02-17 19:44:44 -06:00
|
|
|
}
|
|
|
|
|
const auto total_4 = std::chrono::high_resolution_clock::now();
|
|
|
|
|
total_sec = std::chrono::duration_cast<ms>(total_4 - total_3);
|
2021-03-31 19:35:58 -04:00
|
|
|
std::cout << "Timeline TOTAL: " << total_sec.count() << " ms\n";
|
2021-02-17 19:44:44 -06:00
|
|
|
tm.Close();
|
|
|
|
|
|
2021-03-31 19:35:58 -04:00
|
|
|
std::cout << "Completed successfully!\n";
|
2015-02-05 00:06:07 -06:00
|
|
|
|
2017-08-01 01:19:07 -05:00
|
|
|
return 0;
|
2019-08-05 02:54:59 -04:00
|
|
|
}
|