Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

play music some times produce sigsegv in VideoDecoderFFmpegBase::decode at avcodec_decode_video2 #1420

Open
SGD9919 opened this issue Nov 17, 2022 · 0 comments

Comments

@SGD9919
Copy link

SGD9919 commented Nov 17, 2022

class:
VideoDecoderFFmpegBase

part:
ret = avcodec_decode_video2(d.codec_ctx, d.frame, &got_frame_ptr,sendPacket);

debug:
I use qtcreator find d.codec_ctx is 0x0; I got an qt wanning log Audio Decode failed in console
The problem is random, and it is normal for the music file to play again。

may resolve:
check the codec_ctx is null or return false;

I add those in the decode function;I've been testing it for a while
if(!d.codec_ctx||!d.is_open)
{
qWarning("codec context not ready");
return false;
}

deep problem:

in AVDecoderPrivate at line 99;
codec_ctx = avcodec_alloc_context3(NULL);
in ffmpeg introduce:
/**

  • Allocate an AVCodecContext and set its fields to default values. The
  • resulting struct should be freed with avcodec_free_context().
  • @param codec if non-NULL, allocate private data and initialize defaults
  •          for the given codec. It is illegal to then call avcodec_open2()
    
  •          with a different codec.
    
  •          If NULL, then the codec-specific defaults won't be initialized,
    
  •          which may result in suboptimal default settings (this is
    
  •          important mainly for encoders, e.g. libx264).
    
  • @return An AVCodecContext filled with default values or NULL on failure.
    */
    AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);

this function may return null ,but it is not check by any if code。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant