Example.cpp
Go to the documentation of this file.
/**
* @file
* @brief Source file for Example Executable (example app for libopenshot)
* @author Jonathan Thomas <jonathan@openshot.org>
*
* @section LICENSE
*
* Copyright (c) 2008-2014 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>
#include "../../include/OpenShot.h"
#include "../../include/CrashHandler.h"
using namespace openshot;
int main(int argc, char* argv[]) {
// Create and open reader
FFmpegReader r("/home/jonathan/sintel-120fps-crash.mp4");
r.Open();
// Enable debug logging
ZmqLogger::Instance()->Enable(false);
ZmqLogger::Instance()->Path("/home/jonathan/.openshot_qt/libopenshot2.log");
CrashHandler::Instance();
// Loop a few times
for (int attempt = 1; attempt < 10; attempt++) {
cout << "** Attempt " << attempt << " **" << endl;
// Read every frame in reader as fast as possible
for (int64_t frame_number = 1; frame_number < r.info.video_length; frame_number++) {
// Get frame object
std::shared_ptr<Frame> f = r.GetFrame(frame_number);
// Print frame numbers
cout << frame_number << " [" << f->number << "], " << flush;
if (frame_number % 10 == 0)
cout << endl;
}
}
cout << "Completed successfully!" << endl;
// Close reader
r.Close();
return 0;
}
openshot::FFmpegReader::GetFrame
std::shared_ptr< Frame > GetFrame(int64_t requested_frame)
Definition: FFmpegReader.cpp:396
openshot::ZmqLogger::Enable
void Enable(bool is_enabled)
Enable/Disable logging.
Definition: ZmqLogger.h:103
main
int main(int argc, char *argv[])
Definition: Example.cpp:37
openshot::FFmpegReader::Close
void Close()
Close File.
Definition: FFmpegReader.cpp:203
openshot::FFmpegReader
This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame...
Definition: FFmpegReader.h:92
openshot::ZmqLogger::Path
void Path(string new_path)
Set or change the file path (optional)
Definition: ZmqLogger.cpp:127
openshot::ReaderInfo::video_length
int64_t video_length
The number of frames in the video stream.
Definition: ReaderBase.h:74
openshot::CrashHandler::Instance
static CrashHandler * Instance()
Definition: CrashHandler.cpp:38
openshot::ReaderBase::info
ReaderInfo info
Information about the current media file.
Definition: ReaderBase.h:111
openshot::ZmqLogger::Instance
static ZmqLogger * Instance()
Create or get an instance of this logger singleton (invoke the class with this method) ...
Definition: ZmqLogger.cpp:38
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AudioBufferSource.h:45
openshot::FFmpegReader::Open
void Open()
Open File - which is called by the constructor automatically.
Definition: FFmpegReader.cpp:104