MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / GetOrCreateFrame

Method GetOrCreateFrame

src/Timeline.cpp:603–637  ·  view source on GitHub ↗

Get or generate a blank frame

Source from the content-addressed store, hash-verified

601
602// Get or generate a blank frame
603std::shared_ptr<Frame> Timeline::GetOrCreateFrame(std::shared_ptr<Frame> background_frame, Clip* clip, int64_t number, openshot::TimelineInfoStruct* options)
604{
605 std::shared_ptr<Frame> new_frame;
606
607 // Init some basic properties about this frame
608 int samples_in_frame = Frame::GetSamplesPerFrame(number, info.fps, info.sample_rate, info.channels);
609
610 try {
611 // Debug output
612 ZmqLogger::Instance()->AppendDebugMethod(
613 "Timeline::GetOrCreateFrame (from reader)",
614 "number", number,
615 "samples_in_frame", samples_in_frame);
616
617 // Attempt to get a frame (but this could fail if a reader has just been closed)
618 new_frame = std::shared_ptr<Frame>(clip->GetFrame(background_frame, number, options));
619
620 // Return real frame
621 return new_frame;
622
623 } catch (const ReaderClosed & e) {
624 // ...
625 } catch (const OutOfBoundsFrame & e) {
626 // ...
627 }
628
629 // Debug output
630 ZmqLogger::Instance()->AppendDebugMethod(
631 "Timeline::GetOrCreateFrame (create blank)",
632 "number", number,
633 "samples_in_frame", samples_in_frame);
634
635 // Create blank frame
636 return new_frame;
637}
638
639// Process a new layer of video or audio
640void Timeline::add_layer(std::shared_ptr<Frame> new_frame, Clip* source_clip, int64_t clip_frame_number, bool is_top_clip, float max_volume)

Callers

nothing calls this directly

Calls 2

AppendDebugMethodMethod · 0.80
GetFrameMethod · 0.45

Tested by

no test coverage detected