fix(video): avoid nullptr deref segfault on encode session teardown (#5257)
This commit is contained in:
@@ -418,8 +418,8 @@ namespace video {
|
|||||||
avcodec_encode_session_t(avcodec_encode_session_t &&other) noexcept = default;
|
avcodec_encode_session_t(avcodec_encode_session_t &&other) noexcept = default;
|
||||||
|
|
||||||
~avcodec_encode_session_t() {
|
~avcodec_encode_session_t() {
|
||||||
// Flush any remaining frames in the encoder
|
// Flush any remaining frames in the encoder if the encoder started up (frame num > 0)
|
||||||
if (avcodec_send_frame(avcodec_ctx.get(), nullptr) == 0) {
|
if (avcodec_ctx->frame_num > 0 && avcodec_send_frame(avcodec_ctx.get(), nullptr) == 0) {
|
||||||
packet_raw_avcodec pkt;
|
packet_raw_avcodec pkt;
|
||||||
while (avcodec_receive_packet(avcodec_ctx.get(), pkt.av_packet) == 0);
|
while (avcodec_receive_packet(avcodec_ctx.get(), pkt.av_packet) == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user