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
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
/* TIMELINE ---------------- */
|
|
|
|
|
Timeline t(720, 420, Framerate(24,1), 48000, 2);
|
2012-11-29 17:28:22 -06:00
|
|
|
t.color.blue.AddPoint(1, 0);
|
|
|
|
|
t.color.blue.AddPoint(300, 65000);
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
// Add some clips
|
2012-12-03 23:29:30 -06:00
|
|
|
Clip c1(new FFmpegReader("/home/jonathan/Videos/sintel_trailer-480p.mp4"));
|
|
|
|
|
Clip c2(new FFmpegReader("/home/jonathan/Videos/sintel_trailer-480p.mp4"));
|
|
|
|
|
Clip c3(new ImageReader("/home/jonathan/Desktop/icon.png"));
|
|
|
|
|
|
|
|
|
|
// 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);
|
2012-12-04 02:21:01 -06:00
|
|
|
c1.End(16.0);
|
|
|
|
|
c1.alpha.AddPoint(1, 0.0);
|
|
|
|
|
c1.alpha.AddPoint(360, 0.0, LINEAR);
|
|
|
|
|
c1.alpha.AddPoint(384, 1.0);
|
2012-11-12 01:25:35 -06:00
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
// CLIP 2 (wave form)
|
2012-11-12 01:25:35 -06:00
|
|
|
c2.Position(0.0);
|
2012-11-29 16:32:48 -06:00
|
|
|
c2.Layer(1);
|
2012-12-03 23:29:30 -06:00
|
|
|
c2.Waveform(true);
|
|
|
|
|
c2.alpha.AddPoint(1, 1.0);
|
|
|
|
|
c2.alpha.AddPoint(100, 0.0);
|
|
|
|
|
c2.volume.AddPoint(1, 0.0);
|
|
|
|
|
c2.volume.AddPoint(300, 0.0, LINEAR);
|
2012-11-08 04:35:21 -06:00
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
// CLIP 3 (watermark)
|
|
|
|
|
c3.Layer(2);
|
|
|
|
|
c3.End(50);
|
|
|
|
|
c3.gravity = GRAVITY_BOTTOM_RIGHT;
|
|
|
|
|
c3.scale = SCALE_NONE;
|
|
|
|
|
c3.alpha.AddPoint(1, 1.0);
|
|
|
|
|
c3.alpha.AddPoint(75, 0.0);
|
|
|
|
|
//c3.location_x = Keyframe(-5);
|
|
|
|
|
//c3.location_y = Keyframe(-5);
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
// Add clips
|
2012-11-17 03:13:00 -06:00
|
|
|
t.AddClip(&c1);
|
2012-12-03 22:55:46 -06:00
|
|
|
t.AddClip(&c2);
|
2012-12-03 23:29:30 -06:00
|
|
|
t.AddClip(&c3);
|
|
|
|
|
/* ---------------- */
|
2012-10-29 01:47:39 -05:00
|
|
|
|
|
|
|
|
|
2012-12-03 23:29:30 -06:00
|
|
|
|
|
|
|
|
/* WRITER ---------------- */
|
2012-10-29 01:47:39 -05:00
|
|
|
FFmpegWriter w("/home/jonathan/output.webm");
|
|
|
|
|
|
|
|
|
|
// Set options
|
2012-12-03 23:29:30 -06:00
|
|
|
w.SetAudioOptions(true, "libvorbis", 48000, 2, 128000);
|
|
|
|
|
w.SetVideoOptions(true, "libvpx", Fraction(24,1), 720, 420, 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();
|
|
|
|
|
|
2012-12-04 02:21:01 -06:00
|
|
|
for (int frame = 1; frame <= 600; 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)
|
|
|
|
|
{
|
2012-12-03 04:51:17 -06:00
|
|
|
//if (frame >= 13)
|
2012-12-03 22:55:46 -06:00
|
|
|
//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
|
|
|
}
|
|
|
|
|
|