sipsorcery icon indicating copy to clipboard operation
sipsorcery copied to clipboard

'Generic error in an external library' when trying to change the resolution

Open hassan379 opened this issue 2 years ago • 3 comments

hello , thanks for this great library , but i am facing the following error every time when i am trying to change the resolution of the captured frame "Generic error in an external library" , the error come from this line ffmpeg.avcodec_send_frame(_encoderContext, &avFrame).ThrowExceptionIfError(); inside FFmpegVideoEncoder what i am doing , i am capturing the desktop screen and send it through webrtc and when the user is trying to change the resolution of desktop screen from display settings , the application stopped and throw that error after looking inside the code of the FFmpegVideoEncoder , i found out that you tried to fix this error by updating the width and height of the _encoderContext

if (!_isEncoderInitialised)
{
    
    InitialiseEncoder(codecID, width, height, fps);
}
else if (_encoderContext->width != width || _encoderContext->height != height)
{
    _encoderContext->width = width;
    _encoderContext->height = height;
}

but it doesn't seem that fixed the problem , what i have done , i tried to reinitialize the Encoder again with the new width and height , and after that the error is gone but i noticed something , after doing this the video start stuttering and lagging with delay even on local network between 2 PCs and even on the same PC , but if the user didn't change the resolution , it is working fine without any issue , can you tell me what is the problem and why this happen ?

hassan379 avatar Jun 21 '22 20:06 hassan379

Hi @hassan379 ,

This is not yet supported and it's in the "TO DO" list (like hardware update detection - add/remove webcam, monitors, headset, microphone) but I didn't have enough time for the moment.

Don't hesitate to create a PR :)

ChristopheI avatar Jun 22 '22 07:06 ChristopheI

@ChristopheI thanks for your answer , but do you have any idea what can cause this issue ? where should i looking in order to solve this , or how can i debug this so i can fix it ? thanks

hassan379 avatar Jun 22 '22 19:06 hassan379

Perhaps you could try something like this

  • Stop VideoSource used to capture the screen
  • Update the video stream which managed the screen sharing to RecvOnly
  • Start VideoSource to capture the screen until it's ok
  • Then Update the video stream which managed the screen sharing to SendRecv (using the new VideoSource)

ChristopheI avatar Jun 23 '22 13:06 ChristopheI