Page 1 of 1
Unable to capture video correctly using C SHARP.
Posted: 18 Jul 2024 15:55
by alexsher
Hi all! I'm trying to capture video from a capture device. But I get blurry text.
Text only. Video plays fine. With Potplayer it works fine.
Bad in capture resolution 1920x1080. In resolution 3840x2160 everything is fine. Fps 60Hz.
Using the VLC GUI is also bad.But if I use video output via Direct3D9, the picture is normal. But in C Sharp I do this --vout=direct3d9 and the picture is bad.
I use :dshow in C sharp.
What settings should I use?
Re: Unable to capture video correctly using C SHARP.
Posted: 19 Aug 2024 17:51
by alexsher
Everyone is silent
Re: Unable to capture video correctly using C SHARP.
Posted: 26 Aug 2024 06:30
by mfkl
share a minimal code sample we can test
Re: Unable to capture video correctly using C SHARP.
Posted: 26 Aug 2024 13:15
by alexsher
share a minimal code sample we can test
Code: Select all
using LibVLCSharp.Shared;
using LibVLCSharp.WinForms;
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ControlVisionServer
{
public partial class Capture : Form
{
LibVLC libVLC;
MediaPlayer mediaPlayer;
Media mediaSource;
VideoView videoView;
string CaptureDevice;
string Resolution;
public Capture(string captureDevice /* Name from dshow "HDPro 1" */, string hardwarecodec, string vout, string resolution /* ex. 1920x1080x60 */)
{
InitializeComponent();
//HDPro 1 - Chinese HWSPro Capture Card
CaptureDevice = captureDevice;
Resolution = resolution;
/*
vout = "any"
vout = "direct3d11";
vout = "direct3d9";
vout = "directdraw";
vout = "glwin32";
vout = "wingdi";
hardwarecodec = "any";
hardwarecodec = "d3d11va";
hardwarecodec = "dxva2";
hardwarecodec = "nvdec";
hardwarecodec = "none";
*/
string[] option = new string[]
{
"--avcodec-hw=" + hardwarecodec,
"--no-audio",
"--vout=" + vout
};
libVLC = new LibVLC(option);
videoView = new VideoView();
videoView.Dock = DockStyle.Fill;
Controls.Add(videoView);
}
private void Play()
{
string width = Resolution.Split('x')[0];
string height = Resolution.Split('x')[1];
string fps = Resolution.Split('x')[2];
string[] option = new string[]
{
":dshow-vdev=" + CaptureDevice,
":dshow-aspect-ratio=16:9",
":dshow-size=" + width + "x" + height,
":dshow-fps=" + fps,
":live-caching=" + Service.LiveCachingCapture // = 0
};
mediaSource = new Media(libVLC, "dshow://", FromType.FromLocation, option);
mediaPlayer = new MediaPlayer(libVLC);
videoView.MediaPlayer = mediaPlayer;
mediaPlayer.Play(mediaSource);
}
private void Stop()
{
var DisposeMP = mediaPlayer;
videoView.MediaPlayer = null;
mediaPlayer = null;
Task.Run(() =>
{
DisposeMP?.Dispose();
DisposeMP = null;
});
}
private void Capture_Load(object sender, EventArgs e)
{
Play();
}
private void Capture_FormClosing(object sender, FormClosingEventArgs e)
{
Stop();
}
}
}
Re: Unable to capture video correctly using C SHARP.
Posted: 30 Aug 2024 14:56
by alexsher
Acasis 4 HDMI Input 1080P 60FPS 4 Channel PCIe Video Capture Card
Video encoding format: H.264 Main profile (Hardware Compression)
Maybe I need to somehow configure H264?
Re: Unable to capture video correctly using C SHARP.
Posted: 15 Sep 2024 09:47
by alexsher
Re: Unable to capture video correctly using C SHARP.
Posted: 18 Sep 2024 10:30
by mfkl
If you can reproduce with VLC, but not with the d3d9 output, you need to figure out how to use d3d9 with libvlc.
I'd assume --vout=direct3d9 to work (don't use ":" for libvlc constructor). You can troubleshoot more by comparing logs in VLC and your app.
Re: Unable to capture video correctly using C SHARP.
Posted: 18 Sep 2024 15:22
by alexsher
If you can reproduce with VLC, but not with the d3d9 output, you need to figure out how to use d3d9 with libvlc.
I'd assume --vout=direct3d9 to work (don't use ":" for libvlc constructor). You can troubleshoot more by comparing logs in VLC and your app.
Ok, I will try.
Thanks you.