2013年3月17日 星期日

Broadcasting Screen

1. Hardware A43S
2. OS: Windows 7 x 64
3. Tools: VS 2010, Expression 4 Pro
4. Download Expression SP2  http://www.microsoft.com/zh-tw/download/details.aspx?id=27870
Ref: http://stackoverflow.com/questions/6173914/realtime-stream-from-screencapture-with-microsoft-expression-encoder

5. Notes:
N1. SP1 or SP2 download and upgrade. Restart was required.
N2. Capture screen and then broadcasting into internet.

6. Coding:
LiveJob  job = new LiveJob();    // Create Broadcasting object
Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
EncoderDevice device=null;
for (int i=0; i< devices.Count; i++)
                if (devices[i].Name == "Screen Capture Source") device  = devices[i]; // Select Screen Capture
                                                                                                                        //Source as the input device
if (device != null)
            {
                LiveDeviceSource source = job.AddDeviceSource(device, null);
                source.ScreenCaptureSourceProperties = new ScreenCaptureSourceProperties
                {
                    CaptureCursor = true,
                    CaptureLargeCursor = false,
                    FrameRate = 6,
                    CaptureLayeredWindow = true,
                    Height = 600,
                    Width = 800,
                    Left = 0,
                    Top = 0,
                };
                job.ActivateSource(source);
                // Finds and applys a smooth streaming preset
                job.ApplyPreset(LivePresets.VC1256kDSL16x9);
                // Sets up variable for fomat data
                var format = new PullBroadcastPublishFormat { BroadcastPort = 8080 };
                job.PublishFormats.Add(format);
                var data = job.BufferWindowSize;
                job.StartEncoding();
                Console.Write("Press Enter then to stop the broadcasting.");
                Console.ReadLine();
                job.StopEncoding();
            }
            else
            {
                Console.WriteLine("Can't find Screen Capture Source.");
            }
        }














7. Download

沒有留言:

張貼留言