diff --git a/include/FFmpegReader.h b/include/FFmpegReader.h index 5572c30a..b92daffa 100644 --- a/include/FFmpegReader.h +++ b/include/FFmpegReader.h @@ -108,7 +108,6 @@ namespace openshot vector image_rescalers; ReSampleContext *resampleCtx; - Cache final_cache; Cache working_cache; map packets; map frames; @@ -214,6 +213,8 @@ namespace openshot void UpdateVideoInfo(); public: + /// Final cache object used to hold final frames + Cache final_cache; /// Enable or disable seeking. Seeking can more quickly locate the requested frame, but some /// codecs have trouble seeking, and can introduce artifacts or blank images into the video. diff --git a/include/Timeline.h b/include/Timeline.h index 01976d3e..3470a4cf 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -77,6 +77,9 @@ namespace openshot { /// Add an openshot::Clip to the timeline void AddClip(Clip* clip); + /// Remove an openshot::Clip to the timeline + void RemoveClip(Clip* clip); + /// Close the reader (and any resources it was consuming) void Close(); diff --git a/src/DecklinkInput.cpp b/src/DecklinkInput.cpp index 12c2dd12..24f10cb9 100644 --- a/src/DecklinkInput.cpp +++ b/src/DecklinkInput.cpp @@ -216,7 +216,7 @@ omp_set_nested(true); f->AddImage(width, height, "ARGB", Magick::CharPixel, (uint8_t*)frameBytes); // TEST EFFECTS - f->TransparentColors("#216e3c", 10.0); + f->TransparentColors("#4c5442", 10.0); #pragma omp critical (blackmagic_input_queue) { diff --git a/src/DecklinkOutput.cpp b/src/DecklinkOutput.cpp index c023dd7a..54643ef9 100644 --- a/src/DecklinkOutput.cpp +++ b/src/DecklinkOutput.cpp @@ -221,9 +221,9 @@ void DeckLinkOutputDelegate::WriteFrame(tr1::shared_ptr frame) { // Update buffer (which is already linked to the AVFrame: pFrameRGB) castBytes[row] = 0; // alpha - castBytes[row+1] = pixel_packets[packet].red / 255; - castBytes[row+2] = pixel_packets[packet].green / 255; - castBytes[row+3] = pixel_packets[packet].blue / 255; + castBytes[row+1] = pixel_packets[packet].red >> 8; + castBytes[row+2] = pixel_packets[packet].green >> 8; + castBytes[row+3] = pixel_packets[packet].blue >> 8; } #pragma omp critical (blackmagic_output_queue) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index aa88172c..68c19c87 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -295,6 +295,7 @@ void FFmpegReader::UpdateVideoInfo() tr1::shared_ptr FFmpegReader::GetFrame(int requested_frame) throw(ReaderClosed, TooManySeeks) { + //cout << "GET FRAME " << requested_frame << ", last_frame: " << last_frame << endl; // Check for open reader (or throw exception) if (!is_open) throw ReaderClosed("The FFmpegReader is closed. Call Open() before calling this method.", path); @@ -364,13 +365,13 @@ tr1::shared_ptr FFmpegReader::ReadStream(int requested_frame) // Minimum number of packets to process (for performance reasons) int packets_processed = 0; - int minimum_packets = 16; + int minimum_packets = 8; //omp_set_num_threads(1); omp_set_nested(true); #pragma omp parallel { - #pragma omp master + #pragma omp single { // Loop through the stream until the correct frame is found while (true) diff --git a/src/Main_Blackmagic.cpp b/src/Main_Blackmagic.cpp index 1aa35996..39b1eaf4 100644 --- a/src/Main_Blackmagic.cpp +++ b/src/Main_Blackmagic.cpp @@ -16,9 +16,18 @@ int main(int argc, char *argv[]) /* TIMELINE ---------------- */ Timeline t(1920, 1080, Framerate(30,1), 48000, 2); + // Use an image seq + FFmpegReader tr1("/home/jonathan/Videos/sintel/%06d.tif"); + tr1.final_cache.SetMaxBytes(50 * 1920 * 1080 * 4 + (44100 * 2 * 4)); + + FFmpegReader tr2("/home/jonathan/Videos/sintel2/%06d.tif"); + tr2.final_cache.SetMaxBytes(50 * 1920 * 1080 * 4 + (44100 * 2 * 4)); + + Clip c1(&tr1); + // Add some clips - Clip c1(new ImageReader("/home/jonathan/Pictures/moon.jpg")); - //Clip c1(new FFmpegReader("/home/jonathan/Videos/sintel_trailer-720p.mp4")); + //Clip c1(new ImageReader("/home/jonathan/Pictures/moon.jpg")); + DecklinkReader dr(1, 11, 0, 2, 16); Clip c2(&dr); Clip c3(new ImageReader("/home/jonathan/Pictures/mask_small.png")); @@ -27,7 +36,7 @@ int main(int argc, char *argv[]) // CLIP 1 (background image) c1.Position(0.0); c1.scale = SCALE_NONE; - //c1.End(30.0); + //c1.End(60 * 60 * 24); c1.Layer(0); t.AddClip(&c1); @@ -58,7 +67,7 @@ int main(int argc, char *argv[]) c4.alpha.AddPoint(30,1, LINEAR); c4.alpha.AddPoint(60,0); c4.Layer(3); - t.AddClip(&c4); + //t.AddClip(&c4); // Decklink writer DecklinkWriter w(0, 11, 3, 2, 16); @@ -81,6 +90,19 @@ int main(int argc, char *argv[]) // Sleep some //usleep(1000 * 1); + // EXPERIMENTAL + if (x == 300) + { + // Remove clip 1 + tr1.Close(); + //t.RemoveClip(&c1); + + // Use a new image seq + tr2.Open(); + c1.Reader(&tr2); + c1.Position(x / 30); + } + // Go to next frame on timeline if (abs(dr.GetCurrentFrameNumber() - x) > 90) // Got behind... skip ahead some diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 4ebfa24e..2ad37d29 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -44,6 +44,12 @@ void Timeline::AddClip(Clip* clip) SortClips(); } +// Remove an openshot::Clip to the timeline +void Timeline::RemoveClip(Clip* clip) +{ + clips.remove(clip); +} + // Calculate time of a frame number, based on a framerate float Timeline::calculate_time(int number, Framerate rate) {