Unmanaged crash when incoming video data has no pixel format
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- audio-video-rtc, desktop
Research direction
Start at UncompressedVideoSampleProvider::AllocateResources and inspect the sws_getContext call when avVideoCodecCtx->pix_fmt is AV_PIX_FMT_NONE. Determine how this invalid pixel format should be reported to the C# caller, then verify that the corrupt stream produces a handled error instead of an unmanaged memory violation.
Written by the indexing model from the issue text.
Description
I'm writing an app that connects to various RTSP video camera feeds, and every once in a while, a corrupt video stream (which also fails to show on raw ffmpeg or VLC) would not only fail, but also crash my UWP app with an uncatchable memory violation error.
When debugging, I noticed that this error occurred when FFmpeg failed to correctly identify the pixel format for the incoming string, leading the avVideoCodecCtx->pix_fmt set to AV_PIX_FMT_NONE (i.e. -1). When this is passed to sws_getContext in UncompressedVideoSampleProvider::AllocateResources, it spawns the "attempt was made to access invalid memory" error I ultimately get in my C# code.
For now, I've forked the library and added an explicit check, before the call to AllocateResources, which throws an exception (that can be handled by my C# code) that the feed is invalid, and that's a good enough solution for me. However, it might not be the correct general-purpose handling for the library.
I can create a PR for my fix, but I'm guessing you would prefer to fix it some other way. In any case, cleaner error handling (whether via exception or HRESULT) is probably required for these scenarios.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 319
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/FFmpegInterop
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
microsoft/FFmpegInterop#330 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 25/100
microsoft/FFmpegInterop#327 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoft/FFmpegInterop#324 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
microsoft/FFmpegInterop#323 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
microsoft/FFmpegInterop#278 ·
All issues in microsoft/FFmpegInterop
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100