MediaPlayer in FrameServer mode - sometimes returns blank frames
See original GitHub issueDescribe the bug
When using MediaPlayer with IsVideoFrameServerEnabled=true
, and handling VideoFrameAvailable, sometimes I get blank frames (basically, the whole screen is black).
Steps to reproduce the bug
I’m writing a class to preview specific video frames. I have a function public get_video_frame_info get_closest_frame(double ms)
, which gives me the closest frame I have cached.
Assuming the user usually travels forward, my cache will load frames ahead - so, when user is requesting a frame, I will start loading the first 3.5 seconds ahead.
I handle the VideoFrameAvailable
, more or less:
var rt = new use_render_target(this);
if (rt.render_target != null) {
using (rt.render_target.CreateDrawingSession())
sender.CopyFrameToVideoSurface(rt.render_target);
// the idea here is not to block the "play thread"
Task.Run(async () => {
var bmp = await SoftwareBitmap.CreateCopyFromSurfaceAsync(rt.render_target);
lock(this)
cache_.Add(new frame_info(pos_ms, bmp));
rt.Dispose();
});
}
Every now and then, I end up having a “blank” frame out of nowhere.
Note: initially I thought this would have something to do with the fact that I’m playing the video while grabbing frames (even though it should not matter), but that is not the case - I’ve changed to code to manually move to the next frame using .StepForwardOneFrame()
.
test_video_frame_grabber_play.zip
I’ve attached a full running example: you just need to copy an .mp4 file with at least 20 seconds of footage into folder ApplicationData.Current.LocalFolder.Path
. Mine is an mp4 of 1920x1080.
I’m saving different frames to disk - you’ll see that some of them have a size of 1023 bytes (blank frames).
Just in case you can’t repro, I’ll give you a link to my .mp4 - I’m not allowed to distribute it.
Windows 10 version | Saw the problem? |
---|---|
November 2019 Update (18363) | Yes |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top GitHub Comments
@weltkante The use_render_target is so I can continue processing frames while I copy them to SoftwareBitmaps (basically, I lock a render target until it’s done copying).
Even if you slightly modify the code to not use Task.Run(), the black frames will still happen.
[edit] stay tuned for my next bug report, it’s much worse than this one.
Closing stale external bug. If you are still seeing this issue, please open a new issue in the Feedback Hub so that it may gather related logs/diagnostics.