Microsoft DirectX 8.0 |
Digital Video (DV) capture application.
This sample demonstrates how to build various types of filter graphs for controlling DV camcorders. It also shows how to perform capture, preview, transmit, and device control with a DV camcorder.
Source: (SDK root)\Samples\Multimedia\DirectShow\Capture\DVApp
Executable: (SDK root)\Samples\Multimedia\DirectShow\Bin\DVApp.exe
The DVApp application supports the following modes:
The capture and transmit modes also perform preview. Each of those modes has a No Preview option as well, which disables preview. Capturing without preview is more efficient and can reduce the number of dropped frames. For information about type-1 files versus type-2 files, see Digital Video in DirectShow.
The application starts in preview mode. To select another mode, choose a mode from the Graph Mode menu. For each mode, DVApp builds a filter graph that supports the functionality of that mode. To save the graph as a GraphEdit (.grf) file, select Save Graph to File from the File menu. Quit DVApp before opening the file in GraphEdit.
To capture to a file:
- From the Graph Mode menu, select a DV to File mode (type 1 or type 2, with or without preview).
- From the File menu, choose Set Output File and enter a file name.
- Click Record.
- If the camcorder is in VTR mode, click Play.
- To stop capturing, click Stop.
To transmit from a file to the camcorder:
- From the Graph Mode menu, select a File to DV mode (type 1 or type 2, with or without preview).
- From the File menu, click Set Input File and select a DV file. The file must match the selected mode (type 1 or type 2).
- Click Play.
- To record the data to tape, click Record.
- To stop transmitting, click Stop.
If the camcorder is in VTR mode, the user can control the transport mechanism through the application's VCR-style buttons. To seek the tape, enter the target timecode and click the seek button.
To limit how much data the application captures, choose Capture Size from the File menu.
To check the tape format (NTSC or PAL), choose Check Tape from the Options menu.
To change the size of the preview window, choose Change Decode Size from the Options menu.
The main purpose of this application is to show how to build various DV capture and transmit graphs. Applications can use the ICaptureGraphBuilder2 interface to build preview graphs and type-1 file capture graphs. The other types of DV graph must be built one filter at a time. The DVApp sample uses ICaptureGraphBuilder2 only to build preview graphs.
The following diagram shows the filter graph that captures to a type-1 file:
Interleaved audio-video data is sent from MSDV to the Smart Tee filter. Data from the Smart Tee filter's capture pin is written to a file, while data from the preview pin is sent to the video and audio renderers.
The following diagram shows the filter graph that transmits from a type-2 file to the camcorder:
The AVI Splitter filter parses the AVI file, and the DV Muxer filter multiplexes the two streams, producing an interleaved audio-video stream. The Infinite Pin Tee filter splits the stream into two identical streams. One stream goes to MSDV, while the other goes through the DV Splitter filter for previewing. Other graph configurations might be equivalent.
The application handles device arrival and removal, using two different techniques. For device arrival, the application's message loop responds to WM_DEVICECHANGE messages. For device removal, the application responds to EC_DEVICE_LOST events from the filter graph manager. Either approach works, although the EC_DEVICE_LOST event depends on the existence of the device in the filter graph.
The application only handles one device at a time. If the current device is removed, the application looks for another DV device on the system.
On some DV camcorders, the user must shut off the device when switching it between camera mode and VTR mode, which triggers a device-lost message. The application responds by enabling or disabling the appropriate menu commands. However, if the user toggles rapidly between modes, the camcorder might not generate a device-lost message. You can force the menus to update by choosing Refresh Mode from the Options menu. Some DV camcorders can toggle modes without shutting off, but send a device-lost message only when they switch to VTR mode.
Note Microsoft® Windows® 95 and Microsoft® Windows NT® 4.0 and earlier do not support the data types used for device arrival. In order to compile the application for these platforms, the data types are conditionally included if WINVER is less than 0x500. However, the application does not support device detection on those platforms.
The functionality of the application's Play and Record button depends on the current mode:
The sample application does not perform frame-accurate capture. At various points, the application calls the Sleep function to wait for the device to respond. Newer DV camcorders send a notification when the state of the device changes. Older devices might not support notification; for the purposes of a sample, calling Sleep is a simpler solution. For more information, see Controlling a DV Camcorder.