Add a frame to the queue waiting to be encoded.
| 83 | |
| 84 | // Add a frame to the queue waiting to be encoded. |
| 85 | void 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 |
| 121 | void ImageWriter::WriteFrame(ReaderBase* reader, int64_t start, int64_t length) |
no test coverage detected