[vlc-devel] Bug in LibVLCSharp

Jirka Picek piceji at gmail.com
Wed Aug 23 13:45:58 UTC 2023


Dear developers,

I just wanted to report a bug inside LibVLC or LibVLCSharp.

We have developed simple screen recording application using LibVLCSharp.
The implementation worked the best from what we tried.

Here is a code which starts recording the screen:

private void StartRecordScreen()
{
    string fileName = "Record_" + DateTime.Now.ToString("yyMMdd_HHmmss") +
                      Settings.GetFileExtension(CurrentCodec);

    string filePath = Path.Combine(TMP_DIR_PATH, fileName);

    CreateDirectory(TMP_DIR_PATH);

    if (media != null)
    {
        mediaPlayer.Stop();
        if (media != null)
            media.Dispose();
        media = null;
    }

    media = new Media(libvlc, "screen://", FromType.FromLocation);
    media.AddOption(":screen-fps=" + FramesPerSecond);
    media.AddOption(":sout=#transcode{vcodec=" + CurrentCodec +
",vb=0,scale=0,acodec=none}:file{dst=" + filePath + "}");
    media.AddOption(":sout-keep");

    mediaPlayer.Play(media);
}


This method is called periodically so it creates equaly long video files.
The bug appeared when we connected to the computer via Remote Desktop. The
application started to generate empty files (160 B) and when we tried to
reconnect then it was not possible and when logged in localy, the Windows
crashed to blue screen.

When I reconnected before the period ended so no new file was created, the
file was shorter for the time I was disconnected when completed but no
problem appeared.

I think the problem would be somewhere inside creating the Media. When the
application tries to create the Media from screen and the Remote Desktop
was disconnected then it could get a pointer to destroyed virtual screen or
pointer to no screen.

When I only lock the account the recording works fine. I saw the picture of
locked screen in the recorded Video. I have not tested to stay long time in
screen with password input, it also was not in the record like when
disconnecting from Remote Desktop, maybe it would cause the same problem.

Let me know if you have some questions.

Best regards
Jiří Picek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20230823/4502f6ea/attachment.htm>


More information about the vlc-devel mailing list