dshow video capture starts late (9 sec)
Summary
video starts as if it was already scrolled 9 sec
Minimal project and steps to reproduce
- Start video capture
- The video capture starts late by approx. 9 sec
Code snippet
//Initialization code---
_libVLC = new LibVLC(new string[] { "--no-snapshot-preview", "--no-osd", "--avcodec-hw=d3d11va", "--no-video-title", "--no-audio" });
_mediaPlayer = new MediaPlayer(_libVLC);
_mediaPlayer.EnableHardwareDecoding = true;
_mediaPlayerRecord = new MediaPlayer(_libVLC);
_mediaPlayerRecord.EnableHardwareDecoding = true;
Capture snippet
//Capture code
private void StartVideoRecording()
{
string dshowfps = $":dshow-fps=30";
using (Media _recordMedia = new Media(_libVLC, "dshow://", FromType.FromLocation))
{
_recordMedia.AddOption($":dshow-vdev=Virtual Camera");
{
// diff
_recordMedia.AddOption(dshowfps);
}
List<string> options = Win32Utils.ParseStringOptions(":no-audio|:live-caching=300|:dshow-size=1280x1024|:dshow-aspect-ratio=5:4|:dshow-adev=none|:avcodec-hw=d3d11va", new char[] { '|' });
if (options == null || options.Count == 0)
{
sLogger.Log($"Record option: No Media Options added", Category.Warn);
}
else
{
foreach (string item in options)
{
_recordMedia.AddOption(item);
sLogger.Log($"Record option: {item} added", Category.Debug);
}
}
string destination = Path.Combine(AssemblyDirectory, "AttemptVideo_1.wmv");
string transcode = "#transcode{{vcodec=h264,vb=1500,fps=30,scale=0,acodec=none,ab=128,channels=2,threads=4,high-priority=true}}";
sLogger.Log($"Record option: {transcode} added", Category.Debug);
//string transcode = "#transcode{{vcodec=h264,vb=1500,fps=30,scale=0,acodec=none,ab=128,channels=2,threads=4,high-priority=true}}";
// Only recording mp4 using h264
_recordMedia.AddOption(":sout=" + transcode + ":std{access=file,dst=" + destination + "}");
if (!_mediaPlayerRecord.Play(_recordMedia))
{
MessageBox.Show("Error in Recording...");
}
_mediaPlayerRecord.Playing += _mediaPlayerRecord_Playing;
}
}
private void _mediaPlayerRecord_Playing(object sender, EventArgs e)
{
StartVideoPreview();
_mediaPlayerRecord.Playing -= _mediaPlayerRecord_Playing;
}
private bool StartVideoPreview()
{
bool bResult = false;
if (this._VideoParameters == null)
return bResult;
string dshowfps = $":dshow-fps=30";
// For Capture live feed from Camera device
using (Media _previewMedia = new Media(_libVLC, "dshow://", FromType.FromLocation))
{
_previewMedia.AddOption($":dshow-vdev=Virtual Camera");
{
// diff
_previewMedia.AddOption(dshowfps);
}
List<string> options = Win32Utils.ParseStringOptions(":no-audio|:live-caching=300|:dshow-size=1280x1024|:dshow-aspect-ratio=5:4|:dshow-adev=none|:avcodec-hw=d3d11va", new char[] { '|' });
if (options == null || options.Count == 0)
{
sLogger.Log($"Preview option: No Media Options added", Category.Warn);
}
else
{
foreach (string item in options)
{
_previewMedia.AddOption(item);
sLogger.Log($"Preview option: {item} added", Category.Debug);
}
}
if (!_mediaPlayer.Play(_previewMedia))
{
MessageBox.Show("Error in Previewing...");
}
}
bResult = true;
return bResult;
}
Playback snippet
//Playback code----
string inVideoOutputPath = Path.Combine(AssemblyDirectory, "AttemptVideo_1.wmv");
if (!_mediaPlayer.IsPlaying)
{
using (var media = new Media(_libVLC, new Uri(inVideoOutputPath)))
{
List<string> options = Win32Utils.ParseStringOptions(":file-caching=1|:avcodec-fast");
if (options == null || options.Count == 0)
{
sLogger.Log($"Playback option: No Media Options added", Category.Warn);
}
else
{
foreach (string item in options)
{
media.AddOption(item);
sLogger.Log($"Playback option: {item} added", Category.Debug);
}
}
if (!_mediaPlayer.Play(media))
{
MessageBox.Show("Error in Playing...");
}
}
}
What is the current bug behavior?
The video capture starts late by approx. 9 sec
What is the expected correct behavior?
The video capture should start recording immediately so that there is no clipping at start.
Does it work on other plaforms? Does it work with the official VLC apps?
NA
Relevant logs and/or screenshots
[2021-09-15T16:40:49,044-04:00] [20] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] dshow:ConnectFilters: No crossBar routes found (incompatible pin types)
[2021-09-15T16:40:49,167-04:00] [24] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] dshow:ConnectFilters: No crossBar routes found (incompatible pin types)
[2021-09-15T16:40:50,236-04:00] [19] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] drawable:unsupported control query 3
[2021-09-15T16:40:52,213-04:00] [39] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] mp4:i_length <= 0
[2021-09-15T16:41:01,158-04:00] [39] [ERROR] [Framework.Application.Presentation.VLCWrapper] -- [Error] direct3d11:SetThumbNailClip failed: 0x800706f4
[2021-09-15T16:41:01,608-04:00] [38] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:no more input streams for this mux
[2021-09-15T16:43:36,165-04:00] [22] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] mp4:unknown box type cenc (incompletely loaded)
[2021-09-15T16:43:36,170-04:00] [42] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] mp4:elst box found
[2021-09-15T16:43:36,170-04:00] [24] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] mp4:STTS table of 362 entries
[2021-09-15T16:43:36,170-04:00] [42] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] mp4:CTTS table of 361 entries
[2021-09-15T16:43:36,220-04:00] [37] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] d3d11va:not enough decoding slices in the texture (6/24)
[2021-09-15T16:43:36,240-04:00] [42] [ERROR] [Framework.Application.Presentation.VLCWrapper] -- [Error] main:buffer deadlock prevented
[2021-09-15T16:43:36,412-04:00] [44] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 62 ms)
[2021-09-15T16:43:36,417-04:00] [6] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 33 ms)
[2021-09-15T16:43:36,616-04:00] [39] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 66 ms)
[2021-09-15T16:43:36,616-04:00] [41] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 32 ms)
[2021-09-15T16:43:36,666-04:00] [40] [ERROR] [Framework.Application.Presentation.VLCWrapper] -- [Error] main:buffer deadlock prevented
[2021-09-15T16:43:36,878-04:00] [20] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 35 ms)
[2021-09-15T16:43:37,129-04:00] [33] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 53 ms)
[2021-09-15T16:43:37,129-04:00] [33] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 19 ms)
[2021-09-15T16:43:37,179-04:00] [38] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] drawable:unsupported control query 3
[2021-09-15T16:43:37,376-04:00] [41] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 33 ms)
[2021-09-15T16:43:37,627-04:00] [26] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 51 ms)
[2021-09-15T16:43:37,627-04:00] [24] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 17 ms)
[2021-09-15T16:43:37,878-04:00] [39] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 35 ms)
[2021-09-15T16:43:38,130-04:00] [37] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 54 ms)
[2021-09-15T16:43:38,130-04:00] [33] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 20 ms)
[2021-09-15T16:43:38,381-04:00] [36] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 38 ms)
[2021-09-15T16:43:38,629-04:00] [29] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 53 ms)
[2021-09-15T16:43:38,629-04:00] [22] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 19 ms)
[2021-09-15T16:43:38,876-04:00] [26] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 33 ms)
[2021-09-15T16:43:39,127-04:00] [20] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 51 ms)
[2021-09-15T16:43:39,127-04:00] [39] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 17 ms)
[2021-09-15T16:43:39,379-04:00] [19] [WARN ] [Framework.Application.Presentation.VLCWrapper] -- [Warning] main:picture is too late to be displayed (missing 36 ms)
[2021-09-15T16:43:39,857-04:00] [28] [ERROR] [Framework.Application.Presentation.VLCWrapper] -- [Error] direct3d11:SetThumbNailClip failed: 0x800706f4
Environment
- OS:
- Version
- Device:
- LibVLC version and architecture
- LibVLCSharp version
OS: Windows 64 bit Version Win10, Device: Virtual Camera LibVLC version and architecture 3.0.11.0 LibVLCSharp version 3.4.9.0 LibVLCSharp.WPF 3.4.9.0