2013-09-12 23:41:49 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Source file for Main class (example app for libopenshot)
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2008-2013 OpenShot Studios, LLC
|
|
|
|
|
* (http://www.openshotstudios.com). This file is part of
|
|
|
|
|
* OpenShot Library (http://www.openshot.org), an open-source project
|
|
|
|
|
* dedicated to delivering high quality video editing and animation solutions
|
|
|
|
|
* to the world.
|
|
|
|
|
*
|
|
|
|
|
* OpenShot Library is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU 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 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 General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
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>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <queue>
|
2012-10-14 03:43:52 -05:00
|
|
|
#include <tr1/memory>
|
2011-10-11 08:44:27 -05:00
|
|
|
#include "../include/OpenShot.h"
|
2013-07-31 16:18:54 -05:00
|
|
|
#include "../include/Json.h"
|
2012-11-16 15:38:58 -06:00
|
|
|
#include <omp.h>
|
2013-08-02 10:03:41 -05:00
|
|
|
#include <qdir.h>
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
using namespace openshot;
|
2012-10-14 03:43:52 -05:00
|
|
|
using namespace tr1;
|
2011-10-11 08:44:27 -05:00
|
|
|
|
|
|
|
|
|
2013-08-02 09:42:45 -05:00
|
|
|
int main(int argc, char* argv[])
|
2011-10-11 08:44:27 -05:00
|
|
|
{
|
2013-11-06 23:17:35 -06:00
|
|
|
FFmpegReader r2("/home/jonathan/Videos/sintel_trailer-720p.mp4");
|
|
|
|
|
r2.Open();
|
|
|
|
|
SDLPlayer p;
|
|
|
|
|
p.Reader(&r2);
|
|
|
|
|
p.Play();
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-18 12:38:09 -05:00
|
|
|
// Image of interlaced frame
|
2013-11-04 15:16:19 -06:00
|
|
|
// ImageReader ir("/home/jonathan/apps/libopenshot/src/examples/interlaced.png");
|
|
|
|
|
// ir.Open();
|
|
|
|
|
//
|
|
|
|
|
// // FrameMapper to de-interlace frame
|
|
|
|
|
// //FrameMapper fm(&ir, Framerate(24,1), PULLDOWN_NONE);
|
|
|
|
|
// //fm.DeInterlaceFrame(ir.GetFrame(1), true)->Display();
|
|
|
|
|
// Deinterlace de(false);
|
|
|
|
|
// de.GetFrame(ir.GetFrame(1), 1)->Display();
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// return 0;
|
2013-10-18 12:38:09 -05:00
|
|
|
|
|
|
|
|
|
2013-10-17 14:53:00 -05:00
|
|
|
// Reader
|
2013-11-04 15:16:19 -06:00
|
|
|
FFmpegReader r1("/home/jonathan/colors-24-converted-to-29-97-fps-pulldown-advanced.mp4");
|
2013-10-17 17:46:58 -05:00
|
|
|
r1.Open();
|
|
|
|
|
|
|
|
|
|
// FrameMapper
|
2013-11-04 15:16:19 -06:00
|
|
|
FrameMapper r(&r1, Framerate(24,1), PULLDOWN_ADVANCED);
|
|
|
|
|
r.PrintMapping();
|
2012-12-03 23:29:30 -06:00
|
|
|
|
|
|
|
|
/* WRITER ---------------- */
|
2013-02-19 00:51:07 -06:00
|
|
|
FFmpegWriter w("/home/jonathan/output.mp4");
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
// Set options
|
2013-02-19 00:51:07 -06:00
|
|
|
//w.SetAudioOptions(true, "libvorbis", 48000, 2, 188000);
|
2013-11-04 15:16:19 -06:00
|
|
|
//w.SetAudioOptions(true, "libmp3lame", 44100, 2, 128000);
|
2013-02-19 00:51:07 -06:00
|
|
|
//w.SetVideoOptions(true, "libvpx", Fraction(24,1), 1280, 720, Fraction(1,1), false, false, 30000000);
|
2013-10-17 17:46:58 -05:00
|
|
|
w.SetVideoOptions(true, "mpeg4", r.info.fps, 1280, 720, Fraction(1,1), false, false, 3000000);
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
// Prepare Streams
|
|
|
|
|
w.PrepareStreams();
|
|
|
|
|
|
|
|
|
|
// Write header
|
|
|
|
|
w.WriteHeader();
|
|
|
|
|
|
|
|
|
|
// Output stream info
|
|
|
|
|
w.OutputStreamInfo();
|
|
|
|
|
|
2013-02-19 00:51:07 -06:00
|
|
|
//for (int frame = 3096; frame <= 3276; frame++)
|
2013-11-04 15:16:19 -06:00
|
|
|
for (int frame = 1; frame <= 20; frame++)
|
2012-10-29 01:47:39 -05:00
|
|
|
{
|
2013-11-04 15:16:19 -06:00
|
|
|
// tr1::shared_ptr<Frame> f(new Frame(frame, 1280, 720, "#000000", 44100, 2));
|
|
|
|
|
// if (frame % 2 == 0)
|
|
|
|
|
// f->AddColor(1280, 720, "Yellow");
|
|
|
|
|
// else
|
|
|
|
|
// f->AddColor(1280, 720, "Black");
|
|
|
|
|
//
|
|
|
|
|
// f->AddOverlayNumber(f->number);
|
|
|
|
|
// cout << f->number << endl;
|
|
|
|
|
// w.WriteFrame(f);
|
|
|
|
|
|
2013-10-17 14:53:00 -05:00
|
|
|
tr1::shared_ptr<Frame> f = r.GetFrame(frame);
|
2012-10-29 01:47:39 -05:00
|
|
|
if (f)
|
|
|
|
|
{
|
2013-10-17 17:46:58 -05:00
|
|
|
//if (frame >= 250)
|
|
|
|
|
// f->DisplayWaveform();
|
2013-02-19 01:29:32 -06:00
|
|
|
//f->AddOverlayNumber(frame);
|
|
|
|
|
//f->Display();
|
2012-11-20 10:15:39 -06:00
|
|
|
|
2012-10-29 01:47:39 -05:00
|
|
|
// Write frame
|
2013-11-04 15:16:19 -06:00
|
|
|
f->Display();
|
2012-10-29 01:47:39 -05:00
|
|
|
cout << "queue frame " << frame << " (" << f->number << ", " << f << ")" << endl;
|
|
|
|
|
w.WriteFrame(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write Footer
|
|
|
|
|
w.WriteTrailer();
|
|
|
|
|
|
|
|
|
|
// Close writer & reader
|
|
|
|
|
w.Close();
|
|
|
|
|
|
|
|
|
|
// Close timeline
|
2013-10-17 17:46:58 -05:00
|
|
|
r1.Close();
|
2012-12-03 23:29:30 -06:00
|
|
|
/* ---------------- */
|
|
|
|
|
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
cout << "Successfully Finished Timeline DEMO" << endl;
|
|
|
|
|
return 0;
|
2012-10-05 17:05:33 -05:00
|
|
|
|
2011-10-11 08:44:27 -05:00
|
|
|
}
|
|
|
|
|
|