question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MediaPlayer in FrameServer mode - sometimes returns blank frames

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
jtorjocommented, Apr 15, 2020

@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.

0reactions
bpulliamcommented, Jun 30, 2023

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MediaPlayer.IsVideoFrameServerEnabled Property
When frame server mode is enabled, the media player does not render video content. Instead, your app should register for the VideoFrameAvailable event...
Read more >
OpenCV VideoCaptures sometimes returns blank frames
I am using the following code for capturing video frames from a USB webcam using openCV3 in MS VC++ 2012. But the problem...
Read more >
How avoid black/blank frames? | Page 2
Blank frames appear at the juncture of two scenes. ... Sometimes there is also a small gap in the audio which can only...
Read more >
I rendered a 2000+ frame AVI movie with Blender Render ...
Things can go wrong during rendering - sometimes frames are dropped - and that's why it considered best practice to render stills and...
Read more >
[Guide] Using DMFS on Windows7 64bit (with Sony Vegas ...
This is a short guide to explain how to setup DMFS (DebugMode FrameServer) up and get using it, to enjoy the wind-fast rendering ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found