2

我目前正在尝试使用 Expression Encoder SDK,但我发现在直播时使用它非常混乱。我正在尝试从网络摄像头捕获视频流,使用我的程序进行编码,然后将其作为实时流从我的计算机发布,同时还注入脚本命令。我一直在查看 SDK,但找不到与直播或网络摄像头有关的任何内容。一些代码示例提到了如何使用Job该类进行编码,但我发现的只是在本地对文件进行编码。

4

1 回答 1

2

还没有尝试过,但是有一个名为 Microsoft.Expression.Encoder.Live.LiveJob 的类应该支持流式传输。我尝试了该示例,它从我的硬盘中传输了一个文件。我想它也应该支持编码视频流。这是示例代码(适用于 Encoder 3.0)

using (LiveJob job = new LiveJob())
            {
                // Create a new file source from the file name we were passed in
                LiveFileSource fileSource = job.AddFileSource(fileToEncode);

                // Set this source to Loop when finished
                fileSource.PlaybackMode = FileSourcePlaybackMode.Loop;

                // Make this source the active one
                job.ActivateSource(fileSource);

                // Create a new windows media broadcast output format so we
                // can broadcast this encoding on the current machine.
                // We are going to use the default audio and video profiles
                // that are created on this output format.
                WindowsMediaBroadcastOutputFormat outputFormat = new WindowsMediaBroadcastOutputFormat();

                // Let's broadcast on the local machine on port 8080
                outputFormat.BroadcastPort = 8080;

                // Set the output format on the job
                job.OutputFormat = outputFormat;

                // Start encoding
                Console.Out.Write("Press 'x' to stop encoding...");
                job.StartEncoding();

                // Let's listen for a keypress to know when to stop encoding
                while (Console.ReadKey(true).Key != ConsoleKey.X)
                {
                    // We are waiting for the 'x' key
                }

                // Stop our encoding
                Console.Out.WriteLine("Encoding stopped.");
                job.StopEncoding();
            }
于 2009-11-17T07:56:21.553 回答