修复ffmpeg5以上默认不合并帧导致解码失败的bug (#3809 #3794)

FFmpegDecoder 默认合并帧,ffmpeg 5以上不支持将不完整的帧送入解码器中,根据 issue #3794 做出修改
This commit is contained in:
xiongguangjie 2024-08-10 11:09:54 +08:00 committed by GitHub
parent 4d8b000198
commit ba1a88f202
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -439,6 +439,7 @@ FFmpegDecoder::FFmpegDecoder(const Track::Ptr &track, int thread_num, const std:
if (codec->capabilities & AV_CODEC_CAP_TRUNCATED) { if (codec->capabilities & AV_CODEC_CAP_TRUNCATED) {
/* we do not send complete frames */ /* we do not send complete frames */
_context->flags |= AV_CODEC_FLAG_TRUNCATED; _context->flags |= AV_CODEC_FLAG_TRUNCATED;
_do_merger = false;
} else { } else {
// 此时业务层应该需要合帧 // 此时业务层应该需要合帧
_do_merger = true; _do_merger = true;

View File

@ -114,7 +114,8 @@ private:
bool decodeFrame(const char *data, size_t size, uint64_t dts, uint64_t pts, bool live, bool key_frame); bool decodeFrame(const char *data, size_t size, uint64_t dts, uint64_t pts, bool live, bool key_frame);
private: private:
bool _do_merger = false; // default merge frame
bool _do_merger = true;
toolkit::Ticker _ticker; toolkit::Ticker _ticker;
onDec _cb; onDec _cb;
std::shared_ptr<AVCodecContext> _context; std::shared_ptr<AVCodecContext> _context;