Skip to content
Permalink
Browse files

Fix warning about frames left in queue.

Example:
- [libmp3lame @ 0x55b9e7248300] 4 frames left in the queue on closing
  • Loading branch information
denisfa authored and rkitover committed Aug 7, 2019
1 parent f5b1947 commit 6b18c1f9b886a7241c726518665e12373c5c3942
Showing with 17 additions and 0 deletions.
  1. +14 −0 src/common/ffmpeg.cpp
  2. +3 −0 src/common/ffmpeg.h
@@ -450,6 +450,7 @@ void recording::MediaRecorder::Stop()
npts = 0;
if (oc)
{
flush_frames();
// close the output file
if (!(fmt->flags & AVFMT_NOFILE))
{
@@ -623,3 +624,16 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
}
return MRET_OK;
}

// flush last frames to avoid
// "X frames left in the queue on closing"
void recording::MediaRecorder::flush_frames()
{
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
// flush last audio frames
while (avcodec_receive_packet(aenc, &pkt) >= 0)
avcodec_send_frame(aenc, NULL);
}
@@ -111,6 +111,9 @@ class MediaRecorder
MediaRet setup_video_stream(int width, int height);
MediaRet setup_audio_stream();
MediaRet finish_setup(const char *fname);
// flush last frames to avoid
// "X frames left in the queue on closing"
void flush_frames();
};

}

0 comments on commit 6b18c1f

Please sign in to comment.
You can’t perform that action at this time.