Stop record video UWP
Summary
I trying record video N minutes duration using RTSP, when I use mediaPlayer.Stop() or mediaPlayer.Dispose(), then getting error "An unhandled win32 exception occured in..." Construction try..catch doesn't catch.
Minimal project and steps to reproduce
If I use like below, I don't have exception, but not all files recorded. What I mean, example:
10 files created. But only 8 files recorded, when i closed app. If app is open, then not visible what files are being recorded.
mediaPlayer = null;
mediaPlayer?.Dispose();
LibVLC = null;
LibVLC?.Dispose();
Full example:
while(true)
{
var name = $"{DateTime.Now.ToString("HH\\:mm\\:ss").Replace(":", ".")}.ts";
var storageFileVideo = await storageFolderDate.CreateFileAsync(name);
var LibVLC = new LibVLC();
var mediaPlayer = new MediaPlayer(LibVLC);
using (var media = new Media(LibVLC, new Uri("RTSP address")))
{
media.AddOption($":sout=#file{{dst={storageFileVideo.Path}}}");
media.AddOption(":sout-keep");
mediaPlayer.Play(media);
// await Task.Delay(5000);
//mediaPlayer = null;
//mediaPlayer?.Dispose();
//LibVLC = null;
//LibVLC?.Dispose();
}
}
What is the current bug behavior?
I tried to use mediaPlayer.Stop () ;, ran on two different computers, but the error is the same as above. "An unhandled win32 exception occured in..."
What is the expected correct behavior?
Сorrect operation of the stop method for UWP
Does it work on other plaforms? Does it work with the official VLC apps?
Also i checked in wpf projects (net.core and net.framework) using mediaPlayer.Stop (), everything worked correctly, no need to close the application to write files
Relevant logs and/or screenshots
p2pbsh @p2pbsh · 2 days ago
Can confirm I have encountered exact same issue. Calling mediaPlayer.Stop() whilst playing RTSP stream:
3.2.0 Stream stops correctly
3.3.0 VLC throw unhandled win32 exception
Logs
Stopping stream with 3.2.0
2020-09-10 17:41:04.017 +01:00 [DBG] killing decoder fourcc `h264'
2020-09-10 17:41:04.017 +01:00 [DBG] removing module "avcodec"
2020-09-10 17:41:04.029 +01:00 [DBG] saving a free vout
2020-09-10 17:41:04.030 +01:00 [DBG] removing module "h264"
2020-09-10 17:41:04.030 +01:00 [DBG] removing module "live555"
2020-09-10 17:41:04.030 +01:00 [DBG] reusing provided vout
2020-09-10 17:41:04.036 +01:00 [DBG] Program doesn't contain anymore ES
2020-09-10 17:41:04.044 +01:00 [DBG] removing module "winstore"
2020-09-10 17:41:04.046 +01:00 [DBG] destroying useless vout
2020-09-10 17:41:04.046 +01:00 [DBG] removing module "direct3d11"
2020-09-10 17:41:04.048 +01:00 [DBG] Direct3D11 resources destroyed
2020-09-10 17:41:04.048 +01:00 [DBG] Direct3D11 device adapter closed
2020-09-10 17:41:04.052 +01:00 [DBG] removing module "freetype"
2020-09-10 17:41:04.055 +01:00 [DBG] removing module "yuvp"
2020-09-10 17:41:04.066 +01:00 [DBG] removing module "swscale"
Stopping stream with 3.3.0
2020-09-10 17:34:33.285 +01:00 [DBG] killing decoder fourcc `h264'
2020-09-10 17:34:33.291 +01:00 [DBG] removing module "avcodec"
2020-09-10 17:34:33.311 +01:00 [DBG] saving a free vout
2020-09-10 17:34:33.313 +01:00 [DBG] reusing provided vout
2020-09-10 17:34:33.313 +01:00 [DBG] removing module "h264"
2020-09-10 17:34:33.315 +01:00 [DBG] removing module "live555"
2020-09-10 17:34:33.319 +01:00 [DBG] Program doesn't contain anymore ES
2020-09-10 17:34:33.340 +01:00 [DBG] removing module "winstore"
Something bad happens in removing module winstore, never makes it past there.
Environment
- OS: Windows 10
- Version 1903, 1809
- Device:
- LibVLC version and architecture VideoLAN.LibVLC.UWP 3.3.0
- LibVLCSharp version 3.4.8
Possible fixes
Discussion: libvlc-nuget#9 (closed)