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"
|
2012-11-16 15:38:58 -06:00
|
|
|
#include <omp.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
|
|
|
|
|
|
|
|
void FrameReady(int number)
|
|
|
|
|
{
|
|
|
|
|
cout << "Frame #: " << number << " is ready!" << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2012-10-30 18:53:26 -05:00
|
|
|
|
2013-07-31 12:45:47 -05:00
|
|
|
// Chunk writer example
|
|
|
|
|
FFmpegReader *r1 = new FFmpegReader("/home/jonathan/Videos/sintel_trailer-720p.mp4");
|
|
|
|
|
r1->Open();
|
|
|
|
|
ChunkWriter cw(r1, "");
|
|
|
|
|
cw.WriteFrame(r1, 1, 600);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-06 23:36:28 -06:00
|
|
|
TextReader r(720, 480, 10, 10, GRAVITY_TOP_RIGHT, "What's Up!", "Courier", 30, "Blue", "Black");
|
|
|
|
|
r.Open();
|
|
|
|
|
tr1::shared_ptr<Frame> f = r.GetFrame(1);
|
|
|
|
|
f->Display();
|
|
|
|
|
r.Close();
|
|
|
|
|
|
|
|
|
|
return 0;
|
2013-01-25 02:24:18 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
/* TIMELINE ---------------- */
|
2013-02-19 01:29:32 -06:00
|
|
|
Timeline t(1280, 720, Framerate(25,1), 44100, 2);
|
2012-12-06 17:58:51 -06:00
|
|
|
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
// Add some clips
|
2013-02-19 01:29:32 -06:00
|
|
|
Clip c1(new ImageReader("/home/jonathan/Desktop/Template2/video_background.jpg"));
|
|
|
|
|
Clip c2(new FFmpegReader("/home/jonathan/Desktop/Template2/OpenShot Version 1-4-3.mp4"));
|
2013-01-12 14:51:59 -06:00
|
|
|
// Clip c2(new FFmpegReader("/home/jonathan/Videos/sintel_trailer-480p.mp4"));
|
2013-02-19 01:29:32 -06:00
|
|
|
Clip c3(new ImageReader("/home/jonathan/Desktop/Template2/logo.png"));
|
2013-01-12 14:51:59 -06:00
|
|
|
// Clip c4(new ImageReader("/home/jonathan/Desktop/text3.png")); // audio
|
|
|
|
|
// Clip c5(new ImageReader("/home/jonathan/Desktop/text1.png")); // color
|
|
|
|
|
// Clip c6(new ImageReader("/home/jonathan/Desktop/text4.png")); // sub-pixel
|
|
|
|
|
// Clip c7(new ImageReader("/home/jonathan/Desktop/text8.png")); // coming soon
|
|
|
|
|
// Clip c10(new ImageReader("/home/jonathan/Desktop/text10.png")); // time mapping
|
2012-12-03 23:29:30 -06:00
|
|
|
|
|
|
|
|
// CLIP 1 (background movie)
|
2012-11-12 01:25:35 -06:00
|
|
|
c1.Position(0.0);
|
2012-12-03 23:29:30 -06:00
|
|
|
c1.gravity = GRAVITY_LEFT;
|
|
|
|
|
c1.scale = SCALE_CROP;
|
|
|
|
|
c1.Layer(0);
|
2013-02-19 00:51:07 -06:00
|
|
|
//c1.End(16.0);
|
|
|
|
|
//c1.alpha.AddPoint(1, 0.0);
|
|
|
|
|
//c1.alpha.AddPoint(500, 0.0);
|
|
|
|
|
//c1.alpha.AddPoint(565, 1.0);
|
2013-02-19 01:29:32 -06:00
|
|
|
// c1.time.AddPoint(1, 3096);
|
|
|
|
|
// c1.time.AddPoint(180, 3276, LINEAR);
|
|
|
|
|
// c1.time.AddPoint(181, 3276);
|
|
|
|
|
// c1.time.AddPoint(361, 3096, LINEAR);
|
|
|
|
|
// c1.time.AddPoint(362, 3096);
|
|
|
|
|
// c1.time.AddPoint(722, 3276, LINEAR);
|
|
|
|
|
// c1.time.AddPoint(723, 3276);
|
|
|
|
|
// c1.time.AddPoint(903, 2916, LINEAR);
|
|
|
|
|
// c1.time.AddPoint(1083, 3276, LINEAR);
|
2013-02-19 00:51:07 -06:00
|
|
|
c1.time.PrintValues();
|
2012-12-06 17:58:51 -06:00
|
|
|
//return 1;
|
|
|
|
|
|
2012-11-12 01:25:35 -06:00
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
// CLIP 2 (wave form)
|
2013-02-19 01:29:32 -06:00
|
|
|
c2.Position(0.0);
|
|
|
|
|
c2.Layer(1);
|
|
|
|
|
c2.Waveform(true);
|
2013-01-12 14:51:59 -06:00
|
|
|
// c2.alpha.AddPoint(1, 1.0);
|
|
|
|
|
// c2.alpha.AddPoint(150, 0.0);
|
|
|
|
|
// c2.alpha.AddPoint(360, 0.0, LINEAR);
|
|
|
|
|
// c2.alpha.AddPoint(384, 1.0);
|
2013-02-19 01:29:32 -06:00
|
|
|
c2.volume.AddPoint(1, 1.0);
|
|
|
|
|
c2.volume.AddPoint(900, 1.0, LINEAR);
|
|
|
|
|
c2.volume.AddPoint(1000, 0.0, LINEAR);
|
2013-01-12 14:51:59 -06:00
|
|
|
// c2.End(15.0);
|
2013-02-19 01:29:32 -06:00
|
|
|
c2.wave_color.blue.AddPoint(1, 65000);
|
|
|
|
|
c2.wave_color.blue.AddPoint(300, 0);
|
|
|
|
|
c2.wave_color.red.AddPoint(1, 0);
|
|
|
|
|
c2.wave_color.red.AddPoint(300, 65000);
|
2012-11-08 04:35:21 -06:00
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
// CLIP 3 (watermark)
|
2013-02-19 01:29:32 -06:00
|
|
|
c3.Layer(2);
|
2013-01-12 14:51:59 -06:00
|
|
|
// c3.End(50);
|
2013-02-19 01:29:32 -06:00
|
|
|
c3.gravity = GRAVITY_CENTER;
|
|
|
|
|
c3.scale = SCALE_NONE;
|
|
|
|
|
c3.alpha.AddPoint(1, 1.0);
|
|
|
|
|
c3.alpha.AddPoint(150, 0.0);
|
2013-01-12 14:51:59 -06:00
|
|
|
// c3.location_x.AddPoint(1, -5);
|
|
|
|
|
// c3.location_y.AddPoint(1, -5);
|
|
|
|
|
//
|
|
|
|
|
// // CLIP 4 (text about waveform)
|
|
|
|
|
// c4.Layer(3);
|
|
|
|
|
// c4.scale = SCALE_NONE;
|
|
|
|
|
// c4.gravity = GRAVITY_CENTER;
|
|
|
|
|
// c4.Position(1);
|
|
|
|
|
// c4.alpha.AddPoint(1, 1.0);
|
|
|
|
|
// c4.alpha.AddPoint(30, 0.0);
|
|
|
|
|
// c4.alpha.AddPoint(100, 0.0);
|
|
|
|
|
// c4.alpha.AddPoint(130, 1.0);
|
|
|
|
|
// c4.End(5.5);
|
|
|
|
|
//
|
|
|
|
|
// // CLIP 5 (text about colors)
|
|
|
|
|
// c5.Layer(3);
|
|
|
|
|
// c5.scale = SCALE_NONE;
|
|
|
|
|
// c5.gravity = GRAVITY_CENTER;
|
|
|
|
|
// c5.Position(16);
|
|
|
|
|
// c5.alpha.AddPoint(1, 1.0);
|
|
|
|
|
// c5.alpha.AddPoint(30, 0.0);
|
|
|
|
|
// c5.alpha.AddPoint(100, 0.0);
|
|
|
|
|
// c5.alpha.AddPoint(130, 1.0);
|
|
|
|
|
// c5.End(5.5);
|
|
|
|
|
//
|
|
|
|
|
// // CLIP 6 (text about sub-pixel)
|
|
|
|
|
// c6.Layer(3);
|
|
|
|
|
// c6.scale = SCALE_NONE;
|
|
|
|
|
// c6.gravity = GRAVITY_LEFT;
|
|
|
|
|
// c6.Position(24);
|
|
|
|
|
// c6.alpha.AddPoint(1, 1.0);
|
|
|
|
|
// c6.alpha.AddPoint(30, 0.0);
|
|
|
|
|
// c6.alpha.AddPoint(100, 0.0);
|
|
|
|
|
// c6.alpha.AddPoint(130, 1.0);
|
|
|
|
|
// c6.location_x.AddPoint(1,0.05);
|
|
|
|
|
// c6.location_x.AddPoint(130, 0.3);
|
|
|
|
|
// c6.End(5.5);
|
|
|
|
|
//
|
|
|
|
|
// // CLIP 7 (text about coming soon)
|
|
|
|
|
// c7.Layer(3);
|
|
|
|
|
// c7.scale = SCALE_NONE;
|
|
|
|
|
// c7.gravity = GRAVITY_CENTER;
|
|
|
|
|
// c7.Position(18.0);
|
|
|
|
|
// c7.alpha.AddPoint(1, 1.0);
|
|
|
|
|
// c7.alpha.AddPoint(30, 0.0);
|
|
|
|
|
// c7.alpha.AddPoint(100, 0.0);
|
|
|
|
|
// c7.alpha.AddPoint(130, 1.0);
|
|
|
|
|
// c7.End(5.5);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// // CLIP 10 (text about waveform)
|
|
|
|
|
// c10.Layer(3);
|
|
|
|
|
// c10.scale = SCALE_NONE;
|
|
|
|
|
// c10.gravity = GRAVITY_CENTER;
|
|
|
|
|
// c10.Position(1);
|
|
|
|
|
// c10.alpha.AddPoint(1, 1.0);
|
|
|
|
|
// c10.alpha.AddPoint(30, 0.0);
|
|
|
|
|
// c10.alpha.AddPoint(100, 0.0);
|
|
|
|
|
// c10.alpha.AddPoint(130, 1.0);
|
|
|
|
|
// c10.End(5.5);
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
// Add clips
|
2012-11-17 03:13:00 -06:00
|
|
|
t.AddClip(&c1);
|
2013-02-19 01:29:32 -06:00
|
|
|
t.AddClip(&c2);
|
|
|
|
|
t.AddClip(&c3);
|
2012-12-06 17:58:51 -06:00
|
|
|
//t.AddClip(&c4);
|
|
|
|
|
//t.AddClip(&c5);
|
|
|
|
|
//t.AddClip(&c6);
|
2013-01-12 14:51:59 -06:00
|
|
|
//t.AddClip(&c7);
|
|
|
|
|
//t.AddClip(&c10);
|
2012-12-03 23:29:30 -06:00
|
|
|
/* ---------------- */
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
|
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-02-19 01:29:32 -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-02-19 01:29:32 -06:00
|
|
|
w.SetVideoOptions(true, "mpeg4", Fraction(25,1), 1280, 720, Fraction(1,1), false, false, 30000000);
|
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-02-19 01:29:32 -06:00
|
|
|
for (int frame = 1; frame <= 1000; frame++)
|
2012-10-29 01:47:39 -05:00
|
|
|
{
|
2012-12-03 22:55:46 -06:00
|
|
|
tr1::shared_ptr<Frame> f = t.GetFrame(frame);
|
2012-10-29 01:47:39 -05:00
|
|
|
if (f)
|
|
|
|
|
{
|
2013-01-13 10:54:53 -06:00
|
|
|
//if (frame >= 62)
|
2013-02-19 00:51:07 -06:00
|
|
|
//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
|
|
|
|
|
cout << "queue frame " << frame << " (" << f->number << ", " << f << ")" << endl;
|
|
|
|
|
w.WriteFrame(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write Footer
|
|
|
|
|
w.WriteTrailer();
|
|
|
|
|
|
|
|
|
|
// Close writer & reader
|
|
|
|
|
w.Close();
|
|
|
|
|
|
|
|
|
|
// Close timeline
|
|
|
|
|
t.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
|
|
|
}
|
|
|
|
|
|