【问题标题】:Help with Expression Encoder SDK表达式编码器 SDK 帮助
【发布时间】:2009-06-23 19:36:27
【问题描述】:

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

【问题讨论】:

    标签: c# sdk expression-encoder expression-encoder-sdk


    【解决方案1】:

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

    【讨论】:

    • 我进一步研究了 LiveJob 类,有多个选项可以添加实时视频和音频设备。所以这绝对是你要找的类 更多参考,看这篇帖子:social.expression.microsoft.com/Forums/en-US/encoder/thread/…
    • 是的,3.0 中有一个用于流式传输的类,但是当我发布这个 3.0 时,它并不存在。不过,你有点晚了,我用 WME 代替。它没有被管理,但它完成了工作。
    • 对于遇到此问题的其他人,现在有一篇很好的 MSDN mag 文章对此有所帮助,请参阅“实时编码”部分 - msdn.microsoft.com/en-us/magazine/ff714558.aspx
    猜你喜欢
    • 1970-01-01
    • 2011-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-10
    相关资源
    最近更新 更多