From 8201518a4a7c20c820510fa888ca22f5d9612972 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 5 Apr 2016 23:02:48 +0200 Subject: [PATCH] Fix AV_PKT_FLAG_KEY behavior; non-IDR I-frames are not keyframes (they lack SPS information), and all audio frames are keyframes. --- h264encode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/h264encode.cpp b/h264encode.cpp index fbeeba7..f4f6432 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -1605,7 +1605,7 @@ void H264EncoderImpl::save_codeddata(storage_task task) pkt.data = reinterpret_cast(&data[0]); pkt.size = data.size(); pkt.stream_index = 0; - if (task.frame_type == FRAME_IDR || task.frame_type == FRAME_I) { + if (task.frame_type == FRAME_IDR) { pkt.flags = AV_PKT_FLAG_KEY; } else { pkt.flags = 0; @@ -1657,6 +1657,7 @@ void H264EncoderImpl::save_codeddata(storage_task task) avcodec_encode_audio2(context_audio, &pkt, audio_frame, &got_output); if (got_output) { pkt.stream_index = 1; + pkt.flags = AV_PKT_FLAG_KEY; httpd->add_packet(pkt, audio_pts + global_delay, audio_pts + global_delay, HTTPD::DESTINATION_FILE_AND_HTTP); } // TODO: Delayed frames. -- 2.39.2