5

I have a WPF application for broadcasting video using Microsoft.expression.encoder and framework 4.0, but i got a delay of 15 sec while broadcasting.Is there any suggestion to reduce the delay while broadcasting.

below is the Code

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

}

I am using MediaElement to show the webcam both on my server and client systems.

on Client Side

 try
            {

                theMainWindow.getServerIPAddress();
                IP = theMainWindow.machineIP;
                MediaElement1.Source = new Uri("http://" + IP + ":9090/");
            }
            catch (Exception ex)
            {
            }
Anoop Mohan
  • 329
  • 1
  • 2
  • 13

2 Answers2

2

There is unfortunately no solution (at least as of Jan 2011). According to Microsoft:

"We add a few seconds of delay during the encoding, then there's caching going on at the server level that can add another 5-20 seconds and finally Silverlight also caches for another few seconds of delay."

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

0

You can eliminate some delay in the client by using a PreviewWindow instead of a MediaElement, bypassing the need to encode the stream before displaying it in the client. PreviewWindow is a WinForms control, so this will only work in WPF.

In XAML:

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

Code behind:

var previewWindow = new PreviewWindow(new HandleRef(this.PreviewPanel, this.PreviewPanel.Handle));
_deviceSource.PreviewWindow = previewWindow;
// ..
_job.ActivateSource(_deviceSource);
Dan Garant
  • 723
  • 5
  • 12