locked
Can I capture video device and audio device to a wmv file at the same time use media foundation, what should I do. RRS feed

  • Question

  • I know how to capture a video device or audio device to file, but I want to know how to capture video device and audio device to a file at the same time use media foundation.

    I had tried to use IMFSinkWriter to write two streams to the file, but failed.
    Friday, October 23, 2009 9:21 AM

Answers

  • You shouldn't need to create a custom media sink since transcoding topologies support one video and one audio stream. The only problem you might be having is, if you're following the tutorial that goes over how to convert an MP3 to WMA, you'll notice that the archtecture of the example only supports a single Media Source. You have two Media Sources since you are capturing from a Video Device and an Audio Device.

    I haven't created a Transcoding application yet but I think the best way to go in your situation is to try the following:

    -Create a Sink Activation object or a Sink Writer which has the output characteristics/Media Types configured for the output file. i.e. setup two streams in the Sink. Stream 0 for your Video Media Type and Stream 1 for the Audio Media Type
    -Create both of your Media Sources from the capture devices
    -Encapsulate both Media Sources as Source TopologyNodes and the Media Sink as a Sink Node
    -Connect the output pin of the Video Source node to the Stream 0 pin of the Sink Node.
    -Connect the output pin of the Audio Source node to the Stream 1 pin of the Sink Node.
    -Now that you have your Partial Topology, use the TopoLoader to automatically configure any required Decoders/Encoders for each stream.
    -Assign the Full Topology to your Media Session and you're ready to go.

    I could be wrong about a few things here but I believe this to be the best approach for transcoding two sources of different media types into a single sink.
    Saturday, October 24, 2009 1:19 AM

All replies

  • What have you tried exactly? Media Session and TopoLoader? What's your Media Source configuration? Are you manually creating Transforms? etc etc
    Friday, October 23, 2009 9:24 AM
  • I had used 

    IMFCollection
    MFCreateTranscodeTopology

    to build a topology, and it worked, but the record file's duration is always 0.

    If I manually build a topology, should I need to create a custom media sink?
    What the topology should be?
    Friday, October 23, 2009 9:35 AM
  • You shouldn't need to create a custom media sink since transcoding topologies support one video and one audio stream. The only problem you might be having is, if you're following the tutorial that goes over how to convert an MP3 to WMA, you'll notice that the archtecture of the example only supports a single Media Source. You have two Media Sources since you are capturing from a Video Device and an Audio Device.

    I haven't created a Transcoding application yet but I think the best way to go in your situation is to try the following:

    -Create a Sink Activation object or a Sink Writer which has the output characteristics/Media Types configured for the output file. i.e. setup two streams in the Sink. Stream 0 for your Video Media Type and Stream 1 for the Audio Media Type
    -Create both of your Media Sources from the capture devices
    -Encapsulate both Media Sources as Source TopologyNodes and the Media Sink as a Sink Node
    -Connect the output pin of the Video Source node to the Stream 0 pin of the Sink Node.
    -Connect the output pin of the Audio Source node to the Stream 1 pin of the Sink Node.
    -Now that you have your Partial Topology, use the TopoLoader to automatically configure any required Decoders/Encoders for each stream.
    -Assign the Full Topology to your Media Session and you're ready to go.

    I could be wrong about a few things here but I believe this to be the best approach for transcoding two sources of different media types into a single sink.
    Saturday, October 24, 2009 1:19 AM