2009-06-23 25 views
2

我目前正在使用Expression Encoder SDK進行試驗,但是我發現在直播時使用它非常容易混淆。我試圖從網絡攝像頭捕獲視頻流,使用我的程序進行編碼,然後將其作爲來自我的計算機的實時流發佈,同時還要注入腳本命令。我一直在瀏覽SDK,但找不到與直播或網絡攝像頭有關的任何內容。幾個代碼示例提到如何使用Job類進行編碼,但我發現的所有內容都是關於在本地編碼文件的。使用Expression Encoder SDK的幫助

回答

2

尚未嘗試過,但有一個名爲Microsoft.Expression.Encoder.Live.LiveJob的類應該支持流式傳輸。我嘗試過這個示例,它從我的硬盤中傳輸了一個文件。我想它應該也支持編碼視頻流。這裏是示例代碼(對於編碼器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(); 
      } 
+0

我進一步查看類LiveJob,並且有多個選項可添加實況視頻和音頻設備。所以這絕對是你正在尋找的類 有關進一步的參考,看看這篇文章:http://social.expression.microsoft.com/Forums/en-US/encoder/thread/c575c5be-99dc-4473-bdc8 -25e59f1a91b3 – shake 2009-11-17 08:51:14

相關問題