2012-06-18 82 views
4

我有一個使用Microsoft.expression.encoder和framework 4.0播放視頻的WPF應用程序,但我在廣播時得到了15秒的延遲。是否有任何建議以減少播放時的延遲。下面wpf視頻廣播應用

是我使用的MediaElement展現在我的服務器和客戶端系統的攝像頭兩個密碼

using Microsoft.Expression.Encoder.Live; 
using Microsoft.Expression.Encoder; 

private void button1_Click(object sender, RoutedEventArgs e) 
{ 
    try 
    { 
     EncoderDevice video = null; 
     EncoderDevice audio = null; 
     GetSelectedVideoAndAudioDevices(out video, out audio); 
     StopJob(); 

     if (video == null) 
     { 
      return; 
     } 

     StopJob(); 
     _job = new LiveJob(); 

     if (video != null && audio != null) 
     { 
      //StopJob(); 
      _deviceSource = null; 
      _deviceSource = _job.AddDeviceSource(video, audio); 
      _job.ActivateSource(_deviceSource); 

      // Finds and applys a smooth streaming preset   
      //_job.ApplyPreset(LivePresets.VC1HighSpeedBroadband4x3); 

      // Creates the publishing format for the job 
      PullBroadcastPublishFormat format = new PullBroadcastPublishFormat(); 
      format.BroadcastPort = 9090; 
      format.MaximumNumberOfConnections = 50; 

      // Adds the publishing format to the job 
      _job.PublishFormats.Add(format); 

      // Starts encoding 
      _job.StartEncoding(); 
     } 
     //webCamCtrl.StartCapture(); 
    } 
    catch (Exception ex) 
    { 
     WriteLogFile(this.GetType().Name, "button1_Click", ex.Message.ToString()); 
    } 

} 

在客戶端

try 
      { 

       theMainWindow.getServerIPAddress(); 
       IP = theMainWindow.machineIP; 
       MediaElement1.Source = new Uri("http://" + IP + ":9090/"); 
      } 
      catch (Exception ex) 
      { 
      } 
+0

如果您運行帶寬測試(例如[SpeedTest.net](http://speedtest.net)),您的上傳和下載速度是多少? – Erik

回答

0

你可以propably使用IIS Smooth Streaming的與較低的比特率的材料開始播放,並逐漸增加它作爲您的客戶端緩衝區已滿。 Silverlight內置支持Smooth Streaming,同樣可以在WPF中手工實現(至少在理論上)。

有沒有什麼特別的東西阻止你在客戶端使用SL?