<div dir="ltr">Dear developers,<div><br></div><div>I just wanted to report a bug inside LibVLC or LibVLCSharp.</div><div><br></div><div>We have developed simple screen recording application using LibVLCSharp. The implementation worked the best from what we tried.</div><div><br></div><div>Here is a code which starts recording the screen:</div><div><br></div><div><div style="background-color:rgb(19,19,20);color:rgb(235,235,235)"><pre style="font-family:"JetBrains Mono",monospace"><span style="color:rgb(237,134,74)">private void </span><span style="color:rgb(255,207,64)">StartRecordScreen</span>()<br>{<br>    <span style="color:rgb(237,134,74)">string </span><span style="color:rgb(255,255,255)">fileName </span>= <span style="color:rgb(84,179,62)">"Record_" </span>+ <span style="color:rgb(255,255,255)">DateTime</span>.<span style="color:rgb(237,148,255)">Now</span>.<span style="color:rgb(255,207,64)">ToString</span>(<span style="color:rgb(84,179,62)">"yyMMdd_HHmmss"</span>) +<br>                      <span style="color:rgb(255,255,255)">Settings</span>.<span style="color:rgb(255,198,109);font-style:italic">GetFileExtension</span>(<span style="color:rgb(237,148,255)">CurrentCodec</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold"><br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(237,134,74)">string </span><span style="color:rgb(255,255,255)">filePath </span>= <span style="color:rgb(255,255,255)">Path</span>.<span style="color:rgb(255,198,109);font-style:italic">Combine</span>(<span style="color:rgb(237,148,255);font-style:italic">TMP_DIR_PATH</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">fileName</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold"><br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(255,207,64)">CreateDirectory</span>(<span style="color:rgb(237,148,255);font-style:italic">TMP_DIR_PATH</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold"><br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(237,134,74)">if </span>(<span style="color:rgb(237,148,255)">media </span>!= <span style="color:rgb(237,134,74)">null</span>)<br>    {<br>        <span style="color:rgb(237,148,255)">mediaPlayer</span>.<span style="color:rgb(255,207,64)">Stop</span>()<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold">        </span><span style="color:rgb(237,134,74)">if </span>(<span style="color:rgb(237,148,255)">media </span>!= <span style="color:rgb(237,134,74)">null</span>)<br>            <span style="color:rgb(237,148,255)">media</span>.<span style="color:rgb(255,207,64)">Dispose</span>()<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold">        </span><span style="color:rgb(237,148,255)">media </span>= <span style="color:rgb(237,134,74)">null</span><span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span>}<br><br>    <span style="color:rgb(237,148,255)">media </span>= <span style="color:rgb(237,134,74)">new </span><span style="color:rgb(255,255,255)">Media</span>(<span style="color:rgb(237,148,255)">libvlc</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(84,179,62)">"screen://"</span><span style="color:rgb(237,134,74);font-weight:bold">, </span><span style="color:rgb(255,255,255)">FromType</span>.<span style="color:rgb(237,148,255);font-style:italic">FromLocation</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(237,148,255)">media</span>.<span style="color:rgb(255,207,64)">AddOption</span>(<span style="color:rgb(84,179,62)">":screen-fps=" </span>+ <span style="color:rgb(237,148,255)">FramesPerSecond</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(237,148,255)">media</span>.<span style="color:rgb(255,207,64)">AddOption</span>(<span style="color:rgb(84,179,62)">":sout=#transcode{vcodec=" </span>+ <span style="color:rgb(237,148,255)">CurrentCodec </span>+ <span style="color:rgb(84,179,62)">",vb=0,scale=0,acodec=none}:file{dst=" </span>+ <span style="color:rgb(255,255,255)">filePath </span>+ <span style="color:rgb(84,179,62)">"}"</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(237,148,255)">media</span>.<span style="color:rgb(255,207,64)">AddOption</span>(<span style="color:rgb(84,179,62)">":sout-keep"</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span><span style="color:rgb(237,134,74);font-weight:bold"><br></span><span style="color:rgb(237,134,74);font-weight:bold">    </span><span style="color:rgb(237,148,255)">mediaPlayer</span>.<span style="color:rgb(255,207,64)">Play</span>(<span style="color:rgb(237,148,255)">media</span>)<span style="color:rgb(237,134,74);font-weight:bold">;<br></span>}</pre></div></div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>Let me know if you have some questions.</div><div><br></div><div>Best regards</div><div>Jiří Picek</div></div>