表达式编码器 SDK 帮助

发布于 2024-07-25 17:35:31 字数 206 浏览 2 评论 0原文

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

I am currently experimenting with the Expression Encoder SDK, but I find it very confusing to use when it comes to live streaming. I am trying to capture a video stream from a webcam, encode with my program and then publish it as a live stream from my computer while also injecting script commands. I've been looking through the SDK but I can't find anything pertaining to live streams or webcams. A few code examples mention how to use the Job class to encode, but all I've found is about encoding files locally.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终难遇 2024-08-01 17:35:31

还没有尝试过,但有一个名为 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();
            }

Havent tried it yet but there is a class called Microsoft.Expression.Encoder.Live.LiveJob that is supposed to support streamning. I tried the sample and it streamed a file from my harddisk. I guess it should support encoding video streams too. Here is the sample code (for 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();
            }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文