win-dshow: Use FFmpeg for MJPEG decompression
Measured lower CPU usage and latency than default DirectShow filter. Tested with Logitech BRIO camera at 4K, 30 FPS.master
parent
37f663a789
commit
0e7eec8f2d
|
@ -418,8 +418,6 @@ static inline video_format ConvertVideoFormat(VideoFormat format)
|
|||
return VIDEO_FORMAT_UYVY;
|
||||
case VideoFormat::HDYC:
|
||||
return VIDEO_FORMAT_UYVY;
|
||||
case VideoFormat::MJPEG:
|
||||
return VIDEO_FORMAT_YUY2;
|
||||
default:
|
||||
return VIDEO_FORMAT_NONE;
|
||||
}
|
||||
|
@ -502,6 +500,11 @@ void DShowInput::OnVideoData(const VideoConfig &config, unsigned char *data,
|
|||
return;
|
||||
}
|
||||
|
||||
if (videoConfig.format == VideoFormat::MJPEG) {
|
||||
OnEncodedVideoData(AV_CODEC_ID_MJPEG, data, size, startTime);
|
||||
return;
|
||||
}
|
||||
|
||||
const int cx = config.cx;
|
||||
const int cy = config.cy;
|
||||
|
||||
|
@ -905,8 +908,7 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
|
|||
placeholders::_3, placeholders::_4,
|
||||
placeholders::_5);
|
||||
|
||||
if (videoConfig.internalFormat != VideoFormat::MJPEG)
|
||||
videoConfig.format = videoConfig.internalFormat;
|
||||
videoConfig.format = videoConfig.internalFormat;
|
||||
|
||||
if (!device.SetVideoConfig(&videoConfig)) {
|
||||
blog(LOG_WARNING, "%s: device.SetVideoConfig failed",
|
||||
|
@ -914,19 +916,6 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (videoConfig.internalFormat == VideoFormat::MJPEG) {
|
||||
videoConfig.format = VideoFormat::XRGB;
|
||||
videoConfig.useDefaultConfig = false;
|
||||
|
||||
if (!device.SetVideoConfig(&videoConfig)) {
|
||||
blog(LOG_WARNING,
|
||||
"%s: device.SetVideoConfig (XRGB) "
|
||||
"failed",
|
||||
obs_source_get_name(source));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DStr formatName = GetVideoFormatName(videoConfig.internalFormat);
|
||||
|
||||
double fps = 0.0;
|
||||
|
|
Loading…
Reference in New Issue