OpenShot Library | libopenshot  0.1.9
Example.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Source file for Example Executable (example app for libopenshot)
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @section LICENSE
7  *
8  * Copyright (c) 2008-2014 OpenShot Studios, LLC
9  * <http://www.openshotstudios.com/>. This file is part of
10  * OpenShot Library (libopenshot), an open-source project dedicated to
11  * delivering high quality video editing and animation solutions to the
12  * world. For more information visit <http://www.openshot.org/>.
13  *
14  * OpenShot Library (libopenshot) is free software: you can redistribute it
15  * and/or modify it under the terms of the GNU Lesser General Public License
16  * as published by the Free Software Foundation, either version 3 of the
17  * License, or (at your option) any later version.
18  *
19  * OpenShot Library (libopenshot) is distributed in the hope that it will be
20  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #include <fstream>
29 #include <iostream>
30 #include <memory>
31 #include "../../include/OpenShot.h"
32 #include "../../include/CrashHandler.h"
33 
34 using namespace openshot;
35 
36 
37 int main(int argc, char* argv[]) {
38 
39  // Create and open reader
40  FFmpegReader r("/home/jonathan/sintel-120fps-crash.mp4");
41  r.Open();
42 
43  // Enable debug logging
44  ZmqLogger::Instance()->Enable(false);
45  ZmqLogger::Instance()->Path("/home/jonathan/.openshot_qt/libopenshot2.log");
47 
48  // Loop a few times
49  for (int attempt = 1; attempt < 10; attempt++) {
50  cout << "** Attempt " << attempt << " **" << endl;
51 
52  // Read every frame in reader as fast as possible
53  for (int64_t frame_number = 1; frame_number < r.info.video_length; frame_number++) {
54  // Get frame object
55  std::shared_ptr<Frame> f = r.GetFrame(frame_number);
56 
57  // Print frame numbers
58  cout << frame_number << " [" << f->number << "], " << flush;
59  if (frame_number % 10 == 0)
60  cout << endl;
61  }
62  }
63  cout << "Completed successfully!" << endl;
64 
65  // Close reader
66  r.Close();
67 
68  return 0;
69 }
std::shared_ptr< Frame > GetFrame(int64_t requested_frame)
void Enable(bool is_enabled)
Enable/Disable logging.
Definition: ZmqLogger.h:103
int main(int argc, char *argv[])
Definition: Example.cpp:37
void Close()
Close File.
This class uses the FFmpeg libraries, to open video files and audio files, and return openshot::Frame...
Definition: FFmpegReader.h:92
void Path(string new_path)
Set or change the file path (optional)
Definition: ZmqLogger.cpp:127
int64_t video_length
The number of frames in the video stream.
Definition: ReaderBase.h:74
static CrashHandler * Instance()
ReaderInfo info
Information about the current media file.
Definition: ReaderBase.h:111
static ZmqLogger * Instance()
Create or get an instance of this logger singleton (invoke the class with this method) ...
Definition: ZmqLogger.cpp:38
This namespace is the default namespace for all code in the openshot library.
void Open()
Open File - which is called by the constructor automatically.