From 004e76adbb33477b64986f8c9b2bb11053c7c75b Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Wed, 10 Oct 2012 02:49:34 -0500 Subject: [PATCH] Added an example, trying write a timeline to the FFmpegWriter. Not quite working yet though. --- src/Clip.cpp | 2 -- src/Main.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++---- src/Timeline.cpp | 2 +- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/src/Clip.cpp b/src/Clip.cpp index 3973212b..d4efbee2 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -229,8 +229,6 @@ void Clip::apply_basic_image_processing(Frame* frame, int frame_number) //float scale_x_value = scale_x.GetValue(frame_number); //float scale_y_value = scale_y.GetValue(frame_number); - cout << "rotation_value: " << rotation_value << endl; - // rotate frame if (rotation_value != 0) frame->Rotate(rotation_value); diff --git a/src/Main.cpp b/src/Main.cpp index 2947894b..68a5506e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -15,18 +15,52 @@ void FrameReady(int number) int main() { // Create timeline - Framerate fps(30000,1000); - Timeline t(640, 480, fps); + Framerate fps(24,1); + Timeline t(640, 360, fps); // Add some clips - Clip c1("../../src/examples/test.mp4"); - c1.Layer(2); + Clip c1("/home/jonathan/Videos/sintel-1024-stereo.mp4"); c1.Position(0.0); - c1.rotation.AddPoint(60, 360); + //c1.time.AddPoint(800, 300); + //c1.time.AddPoint(1600, 1); // Add clips t.AddClip(&c1); + + // Create a writer + FFmpegWriter w("/home/jonathan/output.webm"); + w.DisplayInfo(); + + // Set options + w.SetAudioOptions(true, "libvorbis", 44100, 2, 128000, false); + w.SetVideoOptions(true, "libvpx", Fraction(24, 1), 640, 360, Fraction(1,1), false, false, 2000000); + + // Prepare Streams + w.PrepareStreams(); + + // Write header + w.WriteHeader(); + + // Output stream info + w.OutputStreamInfo(); + + for (int frame = 1; frame <= 1600; frame++) + { + Frame *f = t.GetFrame(frame); + + // Write frame + cout << "queue frame " << frame << endl; + w.WriteFrame(f); + } + + // Write Footer + w.WriteTrailer(); + + // Close writer & reader + w.Close(); + + // Request frames for (int x=1; x<=100; x++) t.GetFrame(x); @@ -39,6 +73,32 @@ int main() + + // Create timeline +// Framerate fps(30000,1000); +// Timeline t(640, 480, fps); +// +// // Add some clips +// Clip c1("../../src/examples/test.mp4"); +// c1.Layer(2); +// c1.Position(0.0); +// c1.rotation.AddPoint(60, 360); +// +// // Add clips +// t.AddClip(&c1); +// +// // Request frames +// for (int x=1; x<=100; x++) +// t.GetFrame(x); +// +// // Close timeline +// t.Close(); +// +// cout << "Successfully Finished Timeline DEMO" << endl; +// return 0; + + + //openshot::ImageReader i("/home/jonathan/Apps/videcho_site/media/logos/watermark3.png"); //openshot::Frame* overlay = i.GetFrame(1); //i.DisplayInfo(); diff --git a/src/Timeline.cpp b/src/Timeline.cpp index ba39504f..6c52dcce 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -117,7 +117,7 @@ Frame* Timeline::GetFrame(int requested_frame) throw(ReaderClosed) if (does_clip_intersect) { // Display the clip (DEBUG) - clip->GetFrame(requested_frame)->Display(); + //clip->GetFrame(requested_frame)->Display(); } }