【问题标题】:Passing ffmpeg stream to c# window将ffmpeg流传递给c#窗口
【发布时间】:2016-10-04 08:30:09
【问题描述】:

是否可以将 FFMPEG 视频流传递到 C# 窗口?现在它在新窗口中作为新进程打开,我只是想将它传递给我自己的 SessionWindow。 此时我像这样执行ffplay:

public void ExecuteCommandSync(String command, String args)
{
    try
    {
        System.Diagnostics.ProcessStartInfo procStartInfo =
         new System.Diagnostics.ProcessStartInfo("\"" + command + "\"", args);

        procStartInfo.RedirectStandardOutput = true;
        procStartInfo.UseShellExecute = false;

        procStartInfo.CreateNoWindow = true;

        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo = procStartInfo;
        proc.Start();

        string result = proc.StandardOutput.ReadToEnd();

        Debug.WriteLine(result);
    }
    catch (Exception objException)
    {

    }
}

private void button2_Click(object sender, EventArgs e)
{
    String runPlay = @"C:\FFMPEG\bin\ffplay.exe";
    String Random = "udp://127.0.0.1:1234";

    this.ExecuteCommandSync(runPlay, Random);
}

PS。我不想使用 Windows Media Player,因为我希望这个应用看起来像远程桌面一样工作。

【问题讨论】:

    标签: c# ffmpeg stream setparent


    【解决方案1】:

    看起来我找到了答案。

     Process ProcFFplay = new Process();
            ProcFFplay.StartInfo.FileName = @"C:\FFMPEG\bin\ffplay.exe";
            ProcFFplay.StartInfo.Arguments = @"-probesize 32 udp://192.168.88.228:12340";
            ProcFFplay.StartInfo.CreateNoWindow = true;
            ProcFFplay.StartInfo.RedirectStandardOutput = true;
            ProcFFplay.StartInfo.UseShellExecute = false;
            ProcFFplay.EnableRaisingEvents = true;
            ProcFFplay.OutputDataReceived += (o, k) => Debug.WriteLine(k.Data ?? "NULL", "ffplay");
            ProcFFplay.ErrorDataReceived += (o, k) => Debug.WriteLine(k.Data ?? "NULL", "ffplay");
            ProcFFplay.Exited += (o, k) => Debug.WriteLine("Exited", "ffplay");
            ProcFFplay.Start();
            Thread.Sleep(4500);//this is time which you need to wait to get first frames approximately
            SetParent(ProcFFplay.MainWindowHandle, this.panel1.Handle);
            MoveWindow(ProcFFplay.MainWindowHandle, -5, -30, 1200, 800, true); //these parameteres may look weird but you hide top "stripe" using them.
    

    享受吧。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-09
      • 2010-12-16
      • 2010-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      相关资源
      最近更新 更多