Skip to content
Snippets Groups Projects
Commit 2fda4b2d authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

media decoder: deal with particularities in ffpmeg's avrational


Change-Id: I913ba3783f499d47ace745740443f24849b288b0
Reviewed-by: default avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent e4fa8338
Branches
Tags
No related merge requests found
...@@ -85,13 +85,27 @@ int MediaDecoder::openInput(const DeviceParams& params) ...@@ -85,13 +85,27 @@ int MediaDecoder::openInput(const DeviceParams& params)
ss << params.width << "x" << params.height; ss << params.width << "x" << params.height;
av_dict_set(&options_, "video_size", ss.str().c_str(), 0); av_dict_set(&options_, "video_size", ss.str().c_str(), 0);
} }
#ifndef _WIN32
// on windows, framerate setting can lead to a failure while opening device if (params.framerate) {
// despite investigations, we didn't found a proper solution #ifdef _WIN32
// we let dshow choose the framerate, which is the highest according to our experimentations // On windows, certain framerate settings don't reduce to avrational values
if (params.framerate) // that correspond to valid video device formats.
// e.g. A the rational<double>(10000000, 333333) or 30.000030000
// will be reduced by av_reduce to 999991/33333 or 30.00003000003
// which cause the device opening routine to fail.
// So we treat special cases in which the reduction is imprecise and adjust
// the value, or let dshow choose the framerate, which is, unfortunately,
// NOT the highest according to our experimentations.
auto framerate{ params.framerate.real() };
if (params.framerate.denominator() == 333333)
framerate = (int)(params.framerate.real());
if (params.framerate.denominator() != 4999998)
av_dict_set(&options_, "framerate", ring::to_string(framerate).c_str(), 0);
#else
av_dict_set(&options_, "framerate", ring::to_string(params.framerate.real()).c_str(), 0); av_dict_set(&options_, "framerate", ring::to_string(params.framerate.real()).c_str(), 0);
#endif #endif
}
if (params.offset_x || params.offset_y) { if (params.offset_x || params.offset_y) {
av_dict_set(&options_, "offset_x", ring::to_string(params.offset_x).c_str(), 0); av_dict_set(&options_, "offset_x", ring::to_string(params.offset_x).c_str(), 0);
av_dict_set(&options_, "offset_y", ring::to_string(params.offset_y).c_str(), 0); av_dict_set(&options_, "offset_y", ring::to_string(params.offset_y).c_str(), 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment