0

Currently I'm trying to use Windows Media Foundation SDK (C++) to create WMV file on Windows 10.

I was able to create a WMV file, but I have difficulty to add language list object (7C4346A9-EFE0-4BFC-B229-393EDE415C85) into the asf file.

I am using WMSinkWriter to create a file, and how I pass input video/audio data is as following article mentions: https://learn.microsoft.com/en-us/windows/desktop/medfound/tutorial--using-the-sink-writer-to-encode-video

Here's summary of what I'm doing:

  1. Call CoInitializeEx to initialize the COM library.
  2. Call MFStartup to initialize Microsoft Media Foundation.
  3. Create the sink writer.
  4. Send video frames to the sink writer.
  5. Call IMFSinkWriter::Finalize to finalize the output file.
  6. Release the pointer to the sink writer.
  7. Call MFShutdown.
  8. Call CoUninitialize.

There's no much information on the internet since it is old SDK.

If you have any clue, please let me know.

Aki24x
  • 1,058
  • 1
  • 13
  • 28

1 Answers1

0

IMFASFContentInfo interface of the ASF Media Sink can be obtained from the Sink Writer using GetServiceForStream and specifying MF_SINK_WRITER_MEDIASINK like this:

pSinkWriter->GetServiceForStream(MF_SINK_WRITER_MEDIASINK, GUID_NULL, IID_PPV_ARGS(&pContentInfo));

where pContentInfo points to an IMFASFContentInfo.

You should be able to use IMFASFContentInfo to set the language list by using any or all of the MF_SD_LANGUAGE, MF_SD_ASF_EXTSTRMPROP_LANGUAGE_ID_INDEX, MF_PD_ASF_LANGLIST attributes on the corresponding IMFStreamDescriptor of the IMFPresentationDescriptor obtained by the IMFASFContentInfo object using GeneratePresentationDescriptor method.

VuVirt
  • 1,887
  • 11
  • 13
  • Hello VuVirt, Thanks a lot for your answer. I'd like to double check if what I'm doing is correct, since language does not seem to be set into ASF. Somehow it shows up as "en-us" in ASF viewer. For simplicity I tested with following sample code: https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/multimedia/mediafoundation/MFCaptureToFile – Aki24x Jun 27 '18 at 19:44
  • What I'm doing is: After IMFSinkWriter::BeginWriting is called (since before calling this, GeneratePresentationDescriptor returns E_UNEXPECTED) , I'm calling IMFSinkWriter::GetServiceForStream to get IMFASFContentInfo, and call IMFASFContentInfo::GeneratePresentationDescriptor to get IMFPresentationDescriptor, and then call IMFPresentationDescriptor::GetStreamDescriptorByIndex with index of 0 to obtain IMFStreamDescriptor. Then, call IMFStreamDescriptor::SetString(MF_SD_LANGUAGE, L"en-gb") to set language, but language does not seem to be set into ASF. Am I doing anything wrong? – Aki24x Jun 27 '18 at 19:45