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.
views:
1156answers:
1
A:
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();
}
shake
2009-11-17 07:56:21
I looked further into the class LiveJob and there are multiple options to add live video and audio devices. So this is definitely the class you are looking forFor further reference, look at this post:http://social.expression.microsoft.com/Forums/en-US/encoder/thread/c575c5be-99dc-4473-bdc8-25e59f1a91b3
shake
2009-11-17 08:51:14
Yes, there is a class for streaming in 3.0, but when I posted this 3.0 didn't exist. You're a bit late, though, I used WME instead. It's not managed, but it did the job.
Bevin
2009-11-22 21:00:36
Anyway, it's the right answer, so I'll mark it as such.
Bevin
2009-11-22 21:01:42
for others that run across this, there's now a nice MSDN mag article that helps for this, see the 'Live Encoding' section - http://msdn.microsoft.com/en-us/magazine/ff714558.aspx
James Manning
2010-06-17 20:36:47