我目前正在试验Expression Encoder SDK,但我发现在直播时使用它非常令人困惑。我正在尝试从网络摄像头捕获视频流,用我的程序进行编码,然后将其作为实况流从我的计算机发布,同时还注入脚本命令。我一直在寻找SDK,但我找不到任何与直播流或网络摄像头有关的东西。有几个代码示例提到了如何使用Job类进行编码,但我找到的所有内容都是关于本地编码文件的。
发布于 2009-11-17 15:56:22
还没有尝试过,但是有一个名为Microsoft.Expression.Encoder.Live.LiveJob的类应该支持streamning。我尝试了这个示例,它从我的硬盘上流式传输了一个文件。我想它也应该支持编码视频流。以下是示例代码(适用于编码器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();
}https://stackoverflow.com/questions/1034705
复制相似问题