This sample demonstrates how to use the MediaCapture API to capture video, audio, and pictures from a capture device, such as a webcam.
Specifically, this sample covers:
- Previewing video from a capture device, such as a webcam, connected to the computer.
- Capturing video from a capture device, such as a webcam, connected to the computer.
- Taking a picture from a capture device, such as a webcam, connected to the computer.
- Enumerating cameras connected to the computer.
- Adding a video effect to a video.
- Recording audio from a capture device connected to the computer.
For more information on capturing video in your app, see Quickstart: capturing a photo or video using the camera dialog and Quickstart: capturing video using the MediaCapture API.
Important
This sample uses the Media Extension feature of Windows 8 to add functionality to the Microsoft Media Foundation pipeline. A Media Extension consists of a hybrid object that implements both Component Object Model (COM) and Windows Runtime interfaces. The COM interfaces interact with the Media Foundation pipeline. The Windows Runtime interfaces activate the component and interact with the Windows Store app.
In most situations, it is recommended that you use Visual C++ with Component Extensions (C++/CX ) to interact with the Windows Runtime. But in the case of hybrid components that implement both COM and Windows Runtime interfaces, such as Media Extensions, this is not possible. C++/CX can only create Windows Runtime objects. So, for hybrid objects it is recommended that you use Windows Runtime C++ Template Library to interact with the Windows Runtime. Be aware that Windows Runtime C++ Template Library has limited support for implementing COM interfaces.
To obtain an evaluation copy of Windows 8, go to Windows 8.
To obtain an evaluation copy of Microsoft Visual Studio 2012, go to Visual Studio 2012.
Related topics
- Windows 8 app samples
- Roadmaps
- Adding multimedia
- Capturing or rendering audio, video, and images
- Designing UX for apps
- Roadmap for apps using C# and Visual Basic
- Roadmap for apps using C++
- Roadmap for apps using JavaScript
- Tasks
- Quickstart: capturing a photo or video using the camera dialog
- Quickstart: capturing video using the MediaCapture API
- Reference
- AddEffectAsync
- ClearEffectsAsync
- MediaCapture
- MediaCaptureSettings
- MediaEncodingProfile
- StartRecordToStorageFileAsync
- Windows.Media.Capture
Operating system requirements
| Client | |
|---|---|
| Server |
Build the sample
- Start Visual Studio Express 2012 for Windows 8 and select File > Open > Project/Solution.
- Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express 2012 for Windows 8 Solution (.sln) file.
- Press F7 or use Build > Build Solution to build the sample.
Run the sample
To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.