Skip to main content

 none
When using IMFMediaEngine, what is the best way to draw timed text like closed captions or subtitles RRS feed

  • Question

  • I'm using IMFMediaEngine to build a video player application, the basic playback works well with IMFMediaEngine but I'm in a trouble with displaying timed text(IMFTimedText) which is used for closed captions or subtitles.

    From my investigation on displaying timed text with IMFMediaEngine is to use frame server mode and draw text by myself onto video frame which is obtained by IMFMediaEngine::TransferVideoFrame. As this approach doesn't seem to be handy so I would like to know if there is another way to display timed text easily.


    • Edited by wisestorm Friday, July 5, 2019 4:02 AM
    Friday, July 5, 2019 3:59 AM

Answers

  • Hi,

    Since this interface only works under windows 10, you could use a transparent form with label as layer. An example how to implement this, can be found on MfPack at SourceForce (MfMediaEnginePlayer II) This is a sample written in Delphi, but gives you an idea how to do this.

    • Marked as answer by wisestorm Tuesday, July 9, 2019 4:00 AM
    Monday, July 8, 2019 9:07 AM

All replies

  • Hi Wisestorm,

    You could try the tool ffmpeg to embed subtitles into your video.

    Best regards,

    Drake


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 5, 2019 9:49 AM
    Moderator
  • Thanks for your quick answer, Drake !

    Concerning ffmpeg to embed subtitles into video,  do you mean running the ffmpeg command line tool to embed subtitles into a video file before playing video? 

    If yes, can IMFMedia engine display subtitles by default in case subtitles are embedded into a video file?

    Actually, in order to load external WebVTT file, I tried AddDataSourceFromUrl of IMFTimedText interface obtained from IMFMediaEngine instance but the MediaEngine instance didn't display text on video output after all.

    Even if it is working, in my case, subtitles and a video file should be downloaded in runtime so there is no chance to embed subtitle to a video file.

    So, I need to find a way to draw text onto video output in runtime.
    • Edited by wisestorm Friday, July 5, 2019 11:19 AM
    Friday, July 5, 2019 11:07 AM
  • Hi,

    Since this interface only works under windows 10, you could use a transparent form with label as layer. An example how to implement this, can be found on MfPack at SourceForce (MfMediaEnginePlayer II) This is a sample written in Delphi, but gives you an idea how to do this.

    • Marked as answer by wisestorm Tuesday, July 9, 2019 4:00 AM
    Monday, July 8, 2019 9:07 AM