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

Method WriteFrame

src/ImageWriter.cpp:85–118  ·  view source on GitHub ↗

Add a frame to the queue waiting to be encoded.

Source from the content-addressed store, hash-verified

83
84// Add a frame to the queue waiting to be encoded.
85void ImageWriter::WriteFrame(std::shared_ptr<Frame> frame)
86{
87 // Check for open reader (or throw exception)
88 if (!is_open) {
89 throw WriterClosed(
90 "The ImageWriter is closed. "
91 "Call Open() before calling this method.", path);
92 }
93
94 // Copy and resize image
95 auto qimage = frame->GetImage();
96 auto frame_image = openshot::QImage2Magick(qimage);
97 frame_image->magick( info.vcodec );
98 frame_image->backgroundColor(Magick::Color("none"));
99 MAGICK_IMAGE_ALPHA(frame_image, true);
100 frame_image->quality(image_quality);
101 frame_image->animationDelay(info.video_timebase.ToFloat() * 100);
102 frame_image->animationIterations(number_of_loops);
103
104 // Calculate correct DAR (display aspect ratio)
105 int new_height = info.height * frame->GetPixelRatio().Reciprocal().ToDouble();
106
107 // Resize image
108 Magick::Geometry new_size(info.width, new_height);
109 new_size.aspect(true);
110 frame_image->resize(new_size);
111
112
113 // Put resized frame in vector (waiting to be written)
114 frames.push_back(*frame_image.get());
115
116 // Keep track of the last frame added
117 last_frame = frame;
118}
119
120// Write a block of frames from a reader
121void ImageWriter::WriteFrame(ReaderBase* reader, int64_t start, int64_t length)

Callers 7

FFmpegWriter.cppFile · 0.45
ImageWriter.cppFile · 0.45
mainFunction · 0.45
ExampleHtml.pyFile · 0.45
mainFunction · 0.45
Example.pyFile · 0.45

Calls 11

WriterClosedClass · 0.85
ColorClass · 0.85
GetImageMethod · 0.80
ToFloatMethod · 0.80
ToDoubleMethod · 0.80
ReciprocalMethod · 0.80
GetPixelRatioMethod · 0.80
resizeMethod · 0.80
AppendDebugMethodMethod · 0.80
getMethod · 0.45
GetFrameMethod · 0.45

Tested by

no test coverage detected