Crash when using MJPEG in DirectShow UVC WebCams

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Crash when using MJPEG in DirectShow UVC WebCams

Evgeny Sagatov
Hi,
 
Modern webcams are able to get FullHD video. They usually encode it into a YUY2 or MJPEG, but the frame rate is very different.
For example for Creative Live! Cam Sync 1080p and Logitech HD Pro Webcam C920 and many other:
YUY2 1920x1080 5 fps
MJPEG 1920x1080 30 fps
Of course I would like to use MJPEG, but Linphone chooses YUY2 even if I set the priority setting for a high frame rate or 30 fps.
OK, I took Linphone Desktop branch 4.2.4 and edited the file \linphone-desktop\linphone-sdk\mediastreamer2\src\videofilters\msdscap.cc to increase the priority of MJPEG.
 
int DSCapture::selectBestFormat(SharedComPtr<IAMStreamConfig> streamConfig, int count){
int index;
 
_pixfmt=MS_MJPEG; //Just moved MJPEG to the beginning
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_YUV420P;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_YUY2;
index=find_best_format(streamConfig, count, &_vsize,_pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_YUYV;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_RGB24;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) {
_pixfmt=MS_RGB24_REV;
goto success;
}
ms_error("This camera does not support any of our pixel formats.");
return -1;
...
 
I open the video settings window and click the view button.
Linfone selects MJPEG format, displays a black screen for 5 seconds and closes without reporting an error.
I have attached an extended log file for the described startup case: [linphone1.log](https://github.com/BelledonneCommunications/linphone-sdk/files/5621207/linphone1.log)
 
I tried to debug the code myself but was not successful.
 
I can open a MJPEG video stream from my camera in some other programs and see a good FullHD video. For example, the Camera application from Windows 10.
 
Additionally, I want to say that I am using Windows 10 Pro 64 bit with last updates. I compile Linfone according to the official instructions and get binaries that are very similar to the original assembly. If I don't change the code, then the video plays, but 5 frames per second in YUY2. I've tried other video resolutions, but MJPEG doesn't work anyway.
 
Do you have the opportunity to look at MJPEG implementation again or help me fix this bug?
 
Thank you for any help and feedback!

_______________________________________________
Linphone-developers mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/linphone-developers
Reply | Threaded
Open this post in threaded view
|

Re: Crash when using MJPEG in DirectShow UVC WebCams

Evgeny Sagatov
I figured out what the problem. The marker bit for the MJPEG is not set.
 
videodec.c dec_process_frame
 
It was:
else if (s->codec==CODEC_ID_MJPEG && f->desc->id==MS_JPEG_DEC_ID) inm=read_rfc2435_header(s,inm);
 
I changed:
else if (s->codec==CODEC_ID_MJPEG){
 if(f->desc->id==MS_JPEG_DEC_ID) inm=read_rfc2435_header(s,inm);
 else if (f->desc->id == MS_MJPEG_DEC_ID) mblk_set_marker_info(inm, TRUE);
}


01.12.2020, 13:27, "Evgeny Sagatov" <[hidden email]>:
Hi,
 
Modern webcams are able to get FullHD video. They usually encode it into a YUY2 or MJPEG, but the frame rate is very different.
For example for Creative Live! Cam Sync 1080p and Logitech HD Pro Webcam C920 and many other:
YUY2 1920x1080 5 fps
MJPEG 1920x1080 30 fps
Of course I would like to use MJPEG, but Linphone chooses YUY2 even if I set the priority setting for a high frame rate or 30 fps.
OK, I took Linphone Desktop branch 4.2.4 and edited the file \linphone-desktop\linphone-sdk\mediastreamer2\src\videofilters\msdscap.cc to increase the priority of MJPEG.
 
int DSCapture::selectBestFormat(SharedComPtr<IAMStreamConfig> streamConfig, int count){
int index;
 
_pixfmt=MS_MJPEG; //Just moved MJPEG to the beginning
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_YUV420P;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_YUY2;
index=find_best_format(streamConfig, count, &_vsize,_pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_YUYV;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
_pixfmt=MS_RGB24;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) {
_pixfmt=MS_RGB24_REV;
goto success;
}
ms_error("This camera does not support any of our pixel formats.");
return -1;
...
 
I open the video settings window and click the view button.
Linfone selects MJPEG format, displays a black screen for 5 seconds and closes without reporting an error.
I have attached an extended log file for the described startup case: [linphone1.log](https://github.com/BelledonneCommunications/linphone-sdk/files/5621207/linphone1.log)
 
I tried to debug the code myself but was not successful.
 
I can open a MJPEG video stream from my camera in some other programs and see a good FullHD video. For example, the Camera application from Windows 10.
 
Additionally, I want to say that I am using Windows 10 Pro 64 bit with last updates. I compile Linfone according to the official instructions and get binaries that are very similar to the original assembly. If I don't change the code, then the video plays, but 5 frames per second in YUY2. I've tried other video resolutions, but MJPEG doesn't work anyway.
 
Do you have the opportunity to look at MJPEG implementation again or help me fix this bug?
 
Thank you for any help and feedback!

_______________________________________________
Linphone-developers mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/linphone-developers