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

Method write_frame

src/FFmpegWriter.cpp:690–729  ·  view source on GitHub ↗

Write all frames in the queue to the video file.

Source from the content-addressed store, hash-verified

688
689// Write all frames in the queue to the video file.
690void FFmpegWriter::write_frame(std::shared_ptr<Frame> frame) {
691 // Flip writing flag
692 is_writing = true;
693
694 // Create blank exception
695 bool has_error_encoding_video = false;
696
697 // Process audio frame
698 if (info.has_audio && audio_st)
699 write_audio_packets(false, frame);
700
701 // Process video frame
702 if (info.has_video && video_st)
703 process_video_packet(frame);
704
705 if (info.has_video && video_st) {
706 // Does this frame's AVFrame still exist
707 if (av_frames.count(frame)) {
708 // Get AVFrame
709 AVFrame *frame_final = av_frames[frame];
710
711 // Write frame to video file
712 if (!write_video_packet(frame, frame_final)) {
713 has_error_encoding_video = true;
714 }
715
716 // Deallocate buffer and AVFrame
717 av_freep(&(frame_final->data[0]));
718 AV_FREE_FRAME(&frame_final);
719 av_frames.erase(frame);
720 }
721 }
722
723 // Done writing
724 is_writing = false;
725
726 // Raise exception from main thread
727 if (has_error_encoding_video)
728 throw ErrorEncodingVideo("Error while writing raw video frame", -1);
729}
730
731// Write a block of frames from a reader
732void FFmpegWriter::WriteFrame(ReaderBase *reader, int64_t start, int64_t length) {

Callers

nothing calls this directly

Calls 1

ErrorEncodingVideoClass · 0.85

Tested by

no test coverage detected