How to force QT5 MediaPlayer to show Subtitles?

后端 未结 2 2087
日久生厌
日久生厌 2021-01-26 12:45

I am evaluating a migration from Qt 4.8 towards Qt 5.2 and the most important point is the multimedia backend. In Qt 5.2 there are some important features the Phonon backend in

2条回答
  •  囚心锁ツ
    2021-01-26 13:12

    You have to set the flag GST_PLAY_FLAG_TEXT on playbin2. (It is usually on by default. If need be then change it in the ctor of QGstreamerPlayerSession).

    And if your subtitle file is external then you will have to set the "suburi" property on playbin2. The value of the suburi property is the path to the subtitle file. This change should be done in the method QGstreamerPlayerSession::loadFromUri.

    In Qt5.2 these changes have to be done in the file qgstreamerplayersession.cpp.You will find the file at qtmultimedia/src/plugins/gstreamer/mediaplayer. The file location may be different for the older 4.x versions.

    The other thing I observed is that the plugin code sets the flag GST_PLAY_FLAG_NATIVE_VIDEO. The subtitles do not show up if this flag is set. You will have to prevent the plugin code from setting this flag. Either you can comment out the code that sets this flag or you will have to set the environment variable QT_GSTREAMER_PLAYBIN_FLAGS to 0x00000017 ( which is GST_PLAY_FLAG_VIDEO|GST_PLAY_FLAG_AUDIO|GST_PLAY_FLAG_TEXT). Setting it to any value will skip the GST_PLAY_FLAG_NATIVE_VIDEO flag.

    After you make these changes, build the plugin and use it.

提交回复
热议问题