Page 1 of 1

Randomly getting black screen

Posted: 16 Mar 2018 05:27
by neosettler
Greetings,

Opening videos, mostly mp4, renders a black screen sometimes but the audio is playing. After some research, I find out people mentioning using OpenGL output instead of DirectX but I'm not quite sure how to do it using LibVLC 3.0 C++.

It might not be related but the log spits:
main vout display error: Failed to set on top

Using --no-directx-overlay doesn't seem to help. Could anyone save the day?

Thank you,

Re: Randomly getting black screen

Posted: 16 Mar 2018 12:20
by mfkl
I find out people mentioning using OpenGL output instead of DirectX
If you're on Windows, you should probably go with DirectX.
t might not be related but the log spits [...]
It's not.

Have you tried disabling hardware acceleration?
See this for how https://code.videolan.org/videolan/vlc- ... ce.cs#L356

Is the video playing in the VLC-WinRT app?
Is the video playing in the win32 app?

If all fails, please share your graphic card model as well as the sample.

Cheers,

mfkl

Re: Randomly getting black screen

Posted: 18 Mar 2018 07:47
by neosettler
Hello mfkl, thank you for your support. Yes, the video is playing on win32 and I did try disabling the hardware acceleration. (GeForce GTC 980 Ti) I found out that it might be related to the fact that I'm rendering the video off-screen with libvlc_video_set_callbacks because I do not have this issue while playing inside a window.
void VideoLandMovie::CallbackDisplay(void *in_data, void *in_picture)
{
VideoLandMovie *l_movie = reinterpret_cast<VideoLandMovie*>(in_data);
l_movie->SetUpdated(true);
}

void *VideoLandMovie::CallbackLock(void *in_data, void **in_pixels)
{
VideoLandMovie *l_movie = reinterpret_cast<ZVideoLandMovie*>(in_data);
l_movie->Lock();
*in_pixels = l_movie->GetPixels();
return NULL;
}

void VideoLandMovie::CallbackUnLock(void *in_data, void *in_id, void * const *in_pixels)
{
VideoLandMovie *l_movie = reinterpret_cast<VideoLandMovie*>(in_data);
l_movie->Unlock();
}

unsigned VideoLandMovie::CallbackSetup(void **in_data, char *in_chroma, unsigned *in_width, unsigned *in_height, unsigned *in_pitches, unsigned *in_lines)
{
VideoLandMovie *l_movie = reinterpret_cast<VideoLandMovie*>(*in_data);

unsigned l_w = (*in_width);
unsigned l_h = (*in_height);

(*in_pitches) = l_w * l_movie->GetChannelCount();
(*in_lines) = l_h;

if (l_movie->GetChannelCount() == 3)
{
memcpy(in_chroma, "RGB8", 4); /// No BGR8?
}
else if (l_movie->GetChannelCount() == 4)
{
memcpy(in_chroma, "BGRA", 4);
}
l_movie->CreatePixels(l_w, l_h);
return 1;
}

void VideoLandMovie::Open()
{
if (m_VLC_Media != NULL)
{
libvlc_media_release(m_VLC_Media);
m_VLC_Media = NULL;
}
if (m_VLC_Player != NULL)
{
/// VLC will continue to use old callbacks until playback will be stopped.
libvlc_media_player_stop(m_VLC_Player);
libvlc_media_player_release(m_VLC_Player);
m_VLC_Player = NULL;
}
SetEventHandler(&VideoLandMovie::CallbackEvent, this);
libvlc_media_parse(m_VLC_Media);
libvlc_media_player_set_media(m_VLC_Player, m_VLC_Media);
libvlc_video_set_format_callbacks(m_VLC_Player, VideoLandMovie::CallbackSetup, NULL);
libvlc_video_set_callbacks(m_VLC_Player,
VideoLandMovie::CallbackLock,
VideoLandMovie::CallbackUnLock,
VideoLandMovie::CallbackDisplay, this);
}
Is there any cleaning up that I might be missing? Perhaps OpenGL texture doesn't have time to flush itself before opening the next video or something along those lines?

PS: The code tag doesn't work for me.

Side question: What is the equivalent of addOption for LibVCL in C?
CurrentMedia.addOption(!Locator.SettingsVM.HardwareAccelerationEnabled ? ":avcodec-hw=none" : ":avcodec-hw=d3d11va");

Re: Randomly getting black screen

Posted: 19 Mar 2018 07:30
by mfkl
What is the log saying?

It looks to me that you release your media/mediaplayer in the beginning of the Open() function, before even starting playback. Can't say much more without code and logs.
PS: The code tag doesn't work for me.
Not sure what you mean by code tag.
What is the equivalent of addOption for LibVCL in C?
https://www.videolan.org/developers/vlc ... dc88bf9e15

Re: Randomly getting black screen

Posted: 20 Mar 2018 04:44
by neosettler
Hi mfkl, thank you for your support.

code tag =

Code: Select all

...
; the code between these tags does not format properly sometimes, with Windows Edge that is. To prove me wrong... it does work now! ^^

The VLC log doesn't show anything different when the black screen occurs but OpenGL doesn't throw this:
High Type : Error(1281) GL_INVALID_VALUE error generated.Size and/or offset out of range.

My app is fairly complexe and it would be difficult to extract anything relavant here. because of the randomness, it might be the texture generation, mutex locking synchronisation or event wrong OpenGL context. It's quite mind bugling to find the source of the problem and I'm running out of ideas but I'll keep digging. If anything rings a bell, let me know.

PS: I'm wondering why VLC is still relying on the option mechanism for loping a video for instance. Didn't find a way to toggle this feature on and off yet.

Re: Randomly getting black screen

Posted: 20 Mar 2018 07:04
by mfkl
Not sure I can help more with this.
why VLC is still relying on the option mechanism for loping a video for instance. Didn't find a way to toggle this feature on and off yet.
Can use

Code: Select all

--loop
from https://wiki.videolan.org/VLC_command-line_help/ or implement this yourself.