Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmanaged crash when incoming video data has no pixel format #256

Open
lisardggY opened this issue Feb 21, 2019 · 1 comment
Open

Unmanaged crash when incoming video data has no pixel format #256

lisardggY opened this issue Feb 21, 2019 · 1 comment

Comments

@lisardggY
Copy link

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.

@lukasf
Copy link
Contributor

lukasf commented Feb 21, 2019

@mcosmin222 We will have to fix this in our fork as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants