Files
libopenshot/src/Main.cpp

103 lines
2.6 KiB
C++
Raw Normal View History

/**
* @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
#include <fstream>
2011-10-11 08:44:27 -05:00
#include <iostream>
#include <map>
#include <queue>
#include <tr1/memory>
2011-10-11 08:44:27 -05:00
#include "../include/OpenShot.h"
#include "../include/Json.h"
#include <omp.h>
#include <qdir.h>
2011-10-11 08:44:27 -05:00
using namespace openshot;
using namespace tr1;
2011-10-11 08:44:27 -05:00
int main(int argc, char* argv[])
2011-10-11 08:44:27 -05:00
{
// Reader
FFmpegReader r1("/home/jonathan/Videos/sintel_trailer-720p.mp4");
r1.Open();
// FrameMapper
FrameMapper r(&r1, Framerate(100,1), PULLDOWN_NONE);
//r.PrintMapping();
/* WRITER ---------------- */
FFmpegWriter w("/home/jonathan/output.mp4");
// Set options
//w.SetAudioOptions(true, "libvorbis", 48000, 2, 188000);
w.SetAudioOptions(true, "libmp3lame", 44100, 2, 128000);
//w.SetVideoOptions(true, "libvpx", Fraction(24,1), 1280, 720, Fraction(1,1), false, false, 30000000);
w.SetVideoOptions(true, "mpeg4", r.info.fps, 1280, 720, Fraction(1,1), false, false, 3000000);
// Prepare Streams
w.PrepareStreams();
// Write header
w.WriteHeader();
// Output stream info
w.OutputStreamInfo();
//for (int frame = 3096; frame <= 3276; frame++)
for (int frame = 1; frame <= 1500; frame++)
{
tr1::shared_ptr<Frame> f = r.GetFrame(frame);
if (f)
{
//if (frame >= 250)
// f->DisplayWaveform();
//f->AddOverlayNumber(frame);
//f->Display();
// Write frame
cout << "queue frame " << frame << " (" << f->number << ", " << f << ")" << endl;
w.WriteFrame(f);
}
}
// Write Footer
w.WriteTrailer();
// Close writer & reader
w.Close();
// Close timeline
r1.Close();
/* ---------------- */
cout << "Successfully Finished Timeline DEMO" << endl;
return 0;
2011-10-11 08:44:27 -05:00
}