2012-06-12 19 views
5

Tôi có ứng dụng WPF để phát video bằng Microsoft.expression.encoder và khung 4.0, nhưng tôi bị trễ 15 giây trong khi phát sóng. Có đề xuất nào để giảm độ trễ khi phát sóng .ứng dụng wpf để phát video với độ trễ 15 giây

dưới đây là Bộ luật

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()); 
    } 

} 

Tôi đang sử dụng MediaElement để hiển thị webcam cả trên các hệ thống máy chủ và khách hàng của tôi.

trên Client Side

try 
      { 

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

Kể tìm thấy giải pháp cho điều này? –

+0

KevinCloet: Không, Chưa. –

Trả lời

2

Có thật không may là không có giải pháp (ít nhất là trong tháng 1 năm 2011). Theo Microsoft:

"Chúng tôi thêm một vài giây chậm trễ trong quá trình mã hóa, sau đó có bộ nhớ đệm đang diễn ra ở cấp máy chủ có thể thêm 5-20 giây nữa và cuối cùng Silverlight cũng lưu trữ thêm vài giây nữa."

http://social.expression.microsoft.com/Forums/is/encoder/thread/898b2659-c0d5-4c84-8fba-225f58806f5d

0

Bạn có thể loại bỏ một số chậm trễ trong các khách hàng bằng cách sử dụng một PreviewWindow thay vì một MediaElement, bỏ qua sự cần thiết để mã hóa các dòng trước khi hiển thị nó trong các khách hàng. PreviewWindow là một điều khiển WinForms, do đó, điều này sẽ chỉ hoạt động trong WPF.

Trong XAML:

<WindowsFormsHost> 
    <wf:Panel x:Name="PreviewPanel" /> 
</WindowsFormsHost> 

Mã đằng sau:

var previewWindow = new PreviewWindow(new HandleRef(this.PreviewPanel, this.PreviewPanel.Handle)); 
_deviceSource.PreviewWindow = previewWindow; 
// .. 
_job.ActivateSource(_deviceSource);