Unable to capture video correctly using C SHARP.

This forum is about all development around libVLC.
alexsher
New Cone
New Cone
Posts: 6
Joined: 18 Jul 2024 14:59

Unable to capture video correctly using C SHARP.

Postby alexsher » 18 Jul 2024 15:55

Hi all! I'm trying to capture video from a capture device. But I get blurry text. Image Text only. Video plays fine. With Potplayer it works fine.Image
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?

alexsher
New Cone
New Cone
Posts: 6
Joined: 18 Jul 2024 14:59

Re: Unable to capture video correctly using C SHARP.

Postby alexsher » 19 Aug 2024 17:51

Everyone is silent :D

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Unable to capture video correctly using C SHARP.

Postby mfkl » 26 Aug 2024 06:30

share a minimal code sample we can test
https://mfkl.github.io

alexsher
New Cone
New Cone
Posts: 6
Joined: 18 Jul 2024 14:59

Re: Unable to capture video correctly using C SHARP.

Postby alexsher » 26 Aug 2024 13:15

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(); } } }

alexsher
New Cone
New Cone
Posts: 6
Joined: 18 Jul 2024 14:59

Re: Unable to capture video correctly using C SHARP.

Postby alexsher » 30 Aug 2024 14:56

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?

alexsher
New Cone
New Cone
Posts: 6
Joined: 18 Jul 2024 14:59

Re: Unable to capture video correctly using C SHARP.

Postby alexsher » 15 Sep 2024 09:47

:D

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Unable to capture video correctly using C SHARP.

Postby mfkl » 18 Sep 2024 10:30

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.
https://mfkl.github.io

alexsher
New Cone
New Cone
Posts: 6
Joined: 18 Jul 2024 14:59

Re: Unable to capture video correctly using C SHARP.

Postby alexsher » 18 Sep 2024 15:22

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.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests