Search code examples
c#streaminglibvlc

How to remove a delay in a streaming App


I have developed a streaming client app which has to reproduce the images captured by a cam. My problem is that I'm watching the streaming with a delay of 2secs. I don't know how controll this from my code. Can you help me, please? Here is my code:

 public Form1()
    {
        InitializeComponent();


        vlcControl1 = new Vlc.DotNet.Forms.VlcControl();

        this.vlcControl1.Location = new System.Drawing.Point(225, 65);
        this.vlcControl1.Name = "vlcControl1";
        this.vlcControl1.Size = new System.Drawing.Size(900, 700);
        this.vlcControl1.BackColor = System.Drawing.Color.Black;
        this.vlcControl1.Name = "vlcControl2";
        this.vlcControl1.Spu = -1;
        this.vlcControl1.TabIndex = 0;
        this.vlcControl1.Text = "vlcControl2";
        this.vlcControl1.VlcMediaplayerOptions = null;

        vlcControl1.VlcLibDirectory = new System.IO.DirectoryInfo(ConfigurationManager.AppSettings.Get("pathVLC64").ToString());

        this.Controls.Add(this.vlcControl1);

        ((System.ComponentModel.ISupportInitialize)(this.vlcControl1)).EndInit();

    }
 string uri = ConfigurationManager.AppSettings.Get("urlVideo").ToString();
string[] options = { ":network-caching=1000" };

        vlcControl1.Play(new Uri(uri), options);

}

I have tried changing network-caching parameter but it doesn't work. Thank you so much


Solution

  • Hmm, since you seem to understand basics not gonna include code, what I do is:

    1. I set the player #1 at different SPU
    2. Use new thread with another class to sync start.
    3. Load Media to both players and send sync command to both threads.

    This way playback for both players starts sync. Also, this way you can delay or set the Thread.Sleep(2000); if needed for do further sync.

    Hope this helps, if you need some code example just ask can write some, but including main application -> player #1 -> thread new class -> player #2 functions is quite a bit code to paste.