blob: 1f929749b76dd16e618f38d8789b043172f65a9a (
plain)
From: "FeRD (Frank Dana)" <ferdnyc@gmail.com>
Date: Thu, 24 Feb 2022 10:34:41 -0500
Subject: [PATCH] FFmpegWriter: Don't use AVPicture (gone in 5.0)
---
src/FFmpegWriter.cpp | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp
index 7a45ab4..fdd0652 100644
--- a/src/FFmpegWriter.cpp
+++ b/src/FFmpegWriter.cpp
@@ -772,7 +772,7 @@ void FFmpegWriter::write_queued_frames() {
// Get AVFrame
AVFrame *av_frame = av_frames[frame];
- // Deallocate AVPicture and AVFrame
+ // Deallocate buffer and AVFrame
av_freep(&(av_frame->data[0]));
AV_FREE_FRAME(&av_frame);
av_frames.erase(frame);
@@ -2035,26 +2035,26 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
if (oc->oformat->flags & AVFMT_RAWPICTURE) {
#endif
// Raw video case.
- AVPacket pkt;
- av_init_packet(&pkt);
+ AVPacket* pkt;
+ av_packet_from_data(
+ pkt, frame_final->data[0],
+ frame_final->linesize[0] * frame_final->height);
- pkt.flags |= AV_PKT_FLAG_KEY;
- pkt.stream_index = video_st->index;
- pkt.data = (uint8_t *) frame_final->data;
- pkt.size = sizeof(AVPicture);
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ pkt->stream_index = video_st->index;
// Set PTS (in frames and scaled to the codec's timebase)
- pkt.pts = video_timestamp;
+ pkt->pts = video_timestamp;
/* write the compressed frame in the media file */
- int error_code = av_interleaved_write_frame(oc, &pkt);
+ int error_code = av_interleaved_write_frame(oc, pkt);
if (error_code < 0) {
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + av_err2string(error_code) + "]", "error_code", error_code);
return false;
}
// Deallocate packet
- AV_FREE_PACKET(&pkt);
+ AV_FREE_PACKET(pkt);
} else
{
|