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.
This sample has been updated for Windows 8.1. It now shows how to use the following new media capture features:
- Shows how to capture an image using the new LowLagPhotoCapture and LowLagPhotoControl classes.
- Shows how to capture a sequence of photos using the new LowLagPhotoSequenceCapture and LowLagPhotoSequenceControl classes.
- Shows how to get thumbnails of captured photos. Thumbnails can be accessed from CapturePhoto.Thumbnail and PhotoCapturedEventArgs.Thumbnail.
- Shows how to select from the front or back microphones on a device. The Panel property on the DeviceInformation.EnclosureLocation class can be checked against Windows.Devices.Enumeration.Panel.Front and Windows.Devices.Enumeration.Panel.Back.
- Shows how to select from the front or back camera on a device. The Panel property on the DeviceInformation.EnclosureLocation class can be checked against Windows.Devices.Enumeration.Panel.Front and Windows.Devices.Enumeration.Panel.Back.
- audio: record to a RAW stream and check to see if raw stream recording is allowed
- Use SceneMode
- MediaCapture.Close
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.1 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.1, go to Windows 8.1.
To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.
Note For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft 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 2013 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 2013 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.