This project is read-only.

Getting Started

Setting up your project

Step 1. Install the Azure Media Capture SDK Visual Studio Extension (vsix).
step1.png
Step 2. Create a Windows 8.1 store app, Windows Phone 8.1 app, or Universal app using your programming language of choice. C++, JavaScript, and .NET are all supported. In this example, we will choose a C# Windows 8.1 store app.
step2.png
Step 3. Add a reference to the SDK to your project. In Visual Studio Solution Explorer, right click on ‘Reference’ select ‘Add Reference’, browse to Windows 8.1 > Extensions and select ‘Microsoft Azure Media Capture Client SDK’
step3.png
Step 4. Change your default build configuration to x86, x64, or ARM depending on the platform you want to develop against. Note: you can target all 3 when you build your app for deployment.
step4.png
Step 5. Add the appropriate capabilities to your app to ensure it can access the webcam and microphone.
Double click on Package.appxmanifest in your project, go to the Capabilities tab, and check “Microphone” and “Webcam”.
step5.png
Your project should now be ready to code.

Capturing & previewing media

If desired, add a CaptureElement to your page to allow the user to preview the video as it is being recorded.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <CaptureElement x:Name="captureElement"/>
</Grid>

Create a new instance of the MediaCapture object, initialize it, pass it to the CaptureElement, and start previewing.
MediaCapture mediaCapture;

async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    mediaCapture = new MediaCapture();
    await mediaCapture.InitializeAsync();
    captureElement.Source = mediaCapture;
    await mediaCapture.StartPreviewAsync();
}

If you run the app, you should see whatever your webcam is seeing on your screen.
Next, we need to initialize the Azure Media Capture SDK with a set of profiles used to capture with and encode to. You can construct these profiles yourself or you can use the EncodingProfileHelper static object to construct default profiles for you based on your camera’s native capabilities.
// Initialize the SDK
captureSession = new CaptureSession();
EncodingProfileHelper.InitializeCaptureSession(captureSession, mediaCapture.AudioDeviceController, mediaCapture.VideoDeviceController, VideoEncodingPreferences.SingleBitrate, null);

Last, we just need to start recording to your Azure live ingest service.
await captureSession.StartAsync(mediaCapture, new Uri("http://channelname.accountname.channel.mediaservices.windows.net/ingest.isml"), "test");
  • The URL provided above needs to be changed to one specific to your Azure account.
  • The last parameter is just an identifier for the stream and can be set to anything.

When you are ready to stop recording, simply call:
await captureSession.StopAsync();

When you run your app, it should now automatically start recording to the cloud. You can test your stream by playing the appropriate Azure Media Services preview or program URL in a video player.
Here is the code above in its entirety:
public sealed partial class MainPage : Page
{
    MediaCapture mediaCapture;
    CaptureSession captureSession;

    public MainPage()
    {
        this.InitializeComponent();
        this.Loaded += MainPage_Loaded;
        this.Unloaded += MainPage_Unloaded;
    }

    async void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        // Initialize MediaCapture and CaptureElement
        mediaCapture = new MediaCapture();
        await mediaCapture.InitializeAsync();
        captureElement.Source = mediaCapture;
        await mediaCapture.StartPreviewAsync();

        // Initialize the SDK
        captureSession = new CaptureSession();
        EncodingProfileHelper.InitializeCaptureSession(captureSession, mediaCapture.AudioDeviceController, mediaCapture.VideoDeviceController, VideoEncodingPreferences.SingleBitrate, null);
        await captureSession.StartAsync(mediaCapture, new Uri("http://channelname.accountname.channel.mediaservices.windows.net/ingest.isml"), "test");
    }

    async void MainPage_Unloaded(object sender, RoutedEventArgs e)
    {
        await captureSession.StopAsync();
    }
}

Last edited Aug 20, 2014 at 10:56 PM by timgreenfield, version 3