• VLC播放RTSP流媒体时延迟1到2秒


    首先感谢  https://stackoverflow.com/questions/38326003/how-to-remove-a-delay-in-a-streaming-app        的说明

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

    就是用 vlcControl1.Play(new Uri(uri), options); 的方式打开。 

    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                tableLayoutPanel1.Dock = DockStyle.Fill;
            }
    
            bool isVedioOPen = false;
            private void button1_Click(object sender, EventArgs e)
            {
                if (!isVedioOPen)
                {
                    isVedioOPen = true;
                    button_vedio.Text = "关闭视频";
                    //vlcControl1.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));
                    //vlcControl1.Play(new Uri("rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"));
                    
                    string[] options = { ":network-caching=300" };
                   
                    vlcControl1.Play(new Uri("rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"), options);
    
                }
                else
                {
                    isVedioOPen = false;
                    button_vedio.Text = "打开视频";
                    vlcControl1.Stop();
                    vlcControl1.Refresh();
                }
            }
    
            private void vlcControl1_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
            {
                var currentAssembly = Assembly.GetEntryAssembly();
                var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
                if (currentDirectory == null)
                    return;
                if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
                    e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"libx86"));
                else
                    e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"libx64"));
    
                if (!e.VlcLibDirectory.Exists)
                {
                    var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                    folderBrowserDialog.Description = "Select Vlc libraries folder.";
                    folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
                    folderBrowserDialog.ShowNewFolderButton = true;
                    if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                    {
                        e.VlcLibDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath);
                    }
                }
            }

    这个事件在这儿。然后在运行路径下,新建lib文件夹,分别支持x86和x64,

    ":network-caching=300"意思是延迟300毫秒,实际效果比之前延迟两秒好很多,肉眼感觉一秒钟没到,视频就跟着镜头和实物更新了。
  • 相关阅读:
    kubectl 命令详解
    codeforce344 C report
    poj3041 建图+最小顶点覆盖(最大匹配数)
    poj1637 混合欧拉回路的判定
    poj1149 最大流好题 难在建图 好题
    targan 算法模板
    poj2186 强连通分量 targan算法的应用
    poj2723 2分 + 2-sat
    poj3061 尺取法
    poj3207 2-sat基础题
  • 原文地址:https://www.cnblogs.com/zhangkun35268/p/7832953.html
Copyright © 2020-2023  润新知