Question

I am currently experimenting with the Expression Encoder SDK, but I find it very confusing to use when it comes to live streaming. I am trying to capture a video stream from a webcam, encode with my program and then publish it as a live stream from my computer while also injecting script commands. I've been looking through the SDK but I can't find anything pertaining to live streams or webcams. A few code examples mention how to use the Job class to encode, but all I've found is about encoding files locally.

Was it helpful?

Solution

Havent tried it yet but there is a class called Microsoft.Expression.Encoder.Live.LiveJob that is supposed to support streamning. I tried the sample and it streamed a file from my harddisk. I guess it should support encoding video streams too. Here is the sample code (for Encoder 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();
            }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top