Migrating tr1 to std, adding C++11 support to build scripts, fixing crash in FFmpegReader (caused by shared_ptr, buffer, and last_video_frame corruption). Much improved stability with this change. Thanks to Craig and Peter for the help!

This commit is contained in:
Jonathan Thomas
2017-08-20 17:37:39 -05:00
parent 564664737a
commit f12ffe692b
84 changed files with 605 additions and 641 deletions

View File

@@ -27,47 +27,43 @@
#include <fstream>
#include <iostream>
#include <tr1/memory>
#include <memory>
#include "../../include/OpenShot.h"
#include "../../include/CrashHandler.h"
using namespace openshot;
using namespace tr1;
int main(int argc, char* argv[]) {
FFmpegReader rTest("/home/jonathan/Videos/sintel_trailer-720p.mp4");
rTest.Open();
/* WRITER ---------------- */
FFmpegWriter w("/home/jonathan/output%05d.jpg");
// Create and open reader
FFmpegReader r("/home/jonathan/sintel-120fps-crash.mp4");
r.Open();
// Set options
w.SetVideoOptions(true, "mjpeg", Fraction(24, 1), 1280, 720, Fraction(1, 1), false, false, 3000000);
// Enable debug logging
ZmqLogger::Instance()->Enable(false);
ZmqLogger::Instance()->Path("/home/jonathan/.openshot_qt/libopenshot2.log");
CrashHandler::Instance();
// w.SetOption(VIDEO_STREAM, "qmin", "2" );
// w.SetOption(VIDEO_STREAM, "qmax", "30" );
// w.SetOption(VIDEO_STREAM, "crf", "10" );
// w.SetOption(VIDEO_STREAM, "rc_min_rate", "2000000" );
// w.SetOption(VIDEO_STREAM, "rc_max_rate", "4000000" );
// w.SetOption(VIDEO_STREAM, "max_b_frames", "0" );
// w.SetOption(VIDEO_STREAM, "b_frames", "0" );
// Loop a few times
for (int attempt = 1; attempt < 10; attempt++) {
cout << "** Attempt " << attempt << " **" << endl;
// Open writer
w.Open();
// Read every frame in reader as fast as possible
for (int frame_number = 1; frame_number < r.info.video_length; frame_number++) {
// Get frame object
std::shared_ptr<Frame> f = r.GetFrame(frame_number);
// Prepare Streams
w.PrepareStreams();
// Print frame numbers
cout << frame_number << " [" << f->number << "], " << flush;
if (frame_number % 10 == 0)
cout << endl;
}
}
cout << "Completed successfully!" << endl;
// Write header
w.WriteHeader();
// Write some frames
w.WriteFrame(&rTest, 500, 505);
// Close writer & reader
w.Close();
rTest.Close();
// Close reader
r.Close();
return 0;
}

View File

@@ -29,7 +29,7 @@
#include <iostream>
#include <map>
#include <queue>
#include <tr1/memory>
#include <memory>
#include "../../include/OpenShot.h"
#include <omp.h>
#include <time.h>
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
int x = 0;
while (true)
{
tr1::shared_ptr<Frame> f = t.GetFrame(x);
std::shared_ptr<Frame> f = t.GetFrame(x);
if (f)
{
if (x != 0 && x % 30 == 0)
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
// Image Reader
// ImageReader r1("/home/jonathan/Pictures/Screenshot from 2013-02-10 15:06:38.png");
// r1.Open();
// tr1::shared_ptr<Frame> f1 = r1.GetFrame(1);
// std::shared_ptr<Frame> f1 = r1.GetFrame(1);
// r1.Close();
// f1->TransparentColors("#8fa09a", 20.0);
// f1->Display();
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
// ImageReader r2("/home/jonathan/Pictures/trees.jpg");
// r2.Open();
// tr1::shared_ptr<Frame> f2 = r2.GetFrame(1);
// std::shared_ptr<Frame> f2 = r2.GetFrame(1);
// r2.Close();
// DecklinkReader dr(1, 11, 0, 2, 16);
@@ -207,7 +207,7 @@ int main(int argc, char *argv[])
// if (x % 30 == 0)
// cout << "30 frames..." << endl;
//
// tr1::shared_ptr<Frame> f = dr.GetFrame(0);
// std::shared_ptr<Frame> f = dr.GetFrame(0);
// if (f)
// {
// //f->Display();