[FFmpeg-trac] #8550(avformat:closed): Cannot open DShow capture device twice with same settings
FFmpeg
trac at avcodec.org
Wed Mar 4 23:44:26 EET 2020
#8550: Cannot open DShow capture device twice with same settings
-------------------------------------+-------------------------------------
Reporter: uzyfeo | Owner:
Type: defect | Status: closed
Priority: normal | Component: avformat
Version: unspecified | Resolution: invalid
Keywords: | Blocked By:
dshow,win32,mfc |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Changes (by uzyfeo):
* status: new => closed
* resolution: => invalid
Comment:
We tried to compile ffmpeg ourselves from 4.2.2 sources and use it as
static library instead of shared. We compiled it using VS2019 C++ build
tools with debug symbols enabled. After we stepped through code, we found
out cause of the issue, although as of now not its origin.
During first run, when avformat_open_input is called, AVFormatCtx it
initializes has during its passage through dshow_cycle_formats (found in
ffmpeg-4.2.2/libavdevice/dshow.c) value of framerate 0.
After reinitializing capture, it has framerate set to 30.00050 or
something like that. This casues chack in function dshow_cycle_formats at
line
Found out the culprit. Although, further investigation is still pending.
It seems that, for whatever reason, when specifying framerate that should
be used, this value is remembered and passed down until program is closed.
Value is preserved in AVFormatCtx under name framerate. I dont know
particular structure as of right now or exact details of how it got set
and why it did not got reset properly, but will surely have a look in a
bit.
I found the problem after stepping through half of the code, investigating
each failed function call. Value in this structure, when it works as
intended, is 0. When it fails, it fails because this value was set to
30.0035 or something like that, which is just a tad bit above max limit it
checks against.
We never set this value explicitly ourselves in AVFormatContext returned
by avformat_open_input, so this value must have been set somewhere after
that single check and didn't got cleared properly later on or we are
accidentally setting something up we should. As said, no direct
modifications were done on these values.
Function and check where it fails and it should have not is in
ffmpeg-4.2.2/libavdevice/dshow.c at 396.
As ctx->framerate is 0 during first run, this check is not performed.
After first run, this value is set when it most probably shouldn't, and if
it should, that check should take into account floating point errors
properly.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8550#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list