mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #5355
sudden6 (2): fix(video): workaround for webcams that provide no fps value fix(video): don't pass invalid pixel format strings to ffmpeg
This commit is contained in:
commit
48e722b535
|
@ -126,8 +126,10 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int fd = deviceOpen(devName, &error);
|
int fd = deviceOpen(devName, &error);
|
||||||
if (fd < 0 || error != 0)
|
if (fd < 0 || error != 0) {
|
||||||
return modes;
|
return modes;
|
||||||
|
}
|
||||||
|
|
||||||
v4l2_fmtdesc vfd{};
|
v4l2_fmtdesc vfd{};
|
||||||
vfd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
vfd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
|
@ -156,10 +158,18 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
|
||||||
|
|
||||||
QVector<float> rates =
|
QVector<float> rates =
|
||||||
getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat);
|
getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat);
|
||||||
|
|
||||||
|
// insert dummy FPS value to have the mode in the list even if we don't know the FPS
|
||||||
|
// this fixes support for some webcams, see #5082
|
||||||
|
if (rates.isEmpty()) {
|
||||||
|
rates.append(0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
for (float rate : rates) {
|
for (float rate : rates) {
|
||||||
mode.FPS = rate;
|
mode.FPS = rate;
|
||||||
if (!modes.contains(mode))
|
if (!modes.contains(mode)) {
|
||||||
modes.append(std::move(mode));
|
modes.append(std::move(mode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vfse.index++;
|
vfse.index++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,8 +191,9 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
|
||||||
av_dict_set(&options, "video_size", videoSize.c_str(), 0);
|
av_dict_set(&options, "video_size", videoSize.c_str(), 0);
|
||||||
av_dict_set(&options, "framerate", framerate.c_str(), 0);
|
av_dict_set(&options, "framerate", framerate.c_str(), 0);
|
||||||
const std::string pixelFormatStr = v4l2::getPixelFormatString(mode.pixel_format).toStdString();
|
const std::string pixelFormatStr = v4l2::getPixelFormatString(mode.pixel_format).toStdString();
|
||||||
const char* pixel_format = pixelFormatStr.c_str();
|
// don't try to set a format string that doesn't exist
|
||||||
if (strncmp(pixel_format, "unknown", 7) != 0) {
|
if (pixelFormatStr != "unknown" && pixelFormatStr != "invalid") {
|
||||||
|
const char* pixel_format = pixelFormatStr.c_str();
|
||||||
av_dict_set(&options, "pixel_format", pixel_format, 0);
|
av_dict_set(&options, "pixel_format", pixel_format, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,11 @@ void AVForm::on_videoModescomboBox_currentIndexChanged(int index)
|
||||||
|
|
||||||
void AVForm::selectBestModes(QVector<VideoMode>& allVideoModes)
|
void AVForm::selectBestModes(QVector<VideoMode>& allVideoModes)
|
||||||
{
|
{
|
||||||
|
if (allVideoModes.isEmpty()) {
|
||||||
|
qCritical() << "Trying to select best mode from empty modes list";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Identify the best resolutions available for the supposed XXXXp resolutions.
|
// Identify the best resolutions available for the supposed XXXXp resolutions.
|
||||||
std::map<int, VideoMode> idealModes;
|
std::map<int, VideoMode> idealModes;
|
||||||
idealModes[120] = VideoMode(160, 120);
|
idealModes[120] = VideoMode(160, 120);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user