[Qt-mobility-feedback] Subtitle support in Qt-mobility

Chen, Jacob jacob.chen at intel.com
Thu Jul 1 05:14:11 CEST 2010


Hi Dmytro,

It's good news that Halley said you are planning to add "loading subtitles with matching name" to qt-mobility. :)
What's your idea on subtitle-encoding? Set it as UTF as default for every subtitles?

Sincerely,
Jacob
-----Original Message-----
From: Dmytro Poplavskiy [mailto:dmytro.poplavskiy at nokia.com] 
Sent: Wednesday, June 30, 2010 11:12 AM
To: Chen, Jacob
Cc: Zhao, Halley; Mcpherson Justin (Nokia-D-Qt/Brisbane); qt-mobility-feedback at trolltech.com
Subject: Re: Subtitle support in Qt-mobility

Hi Jacob,

On Tuesday 29 June 2010 18:50:04 ext Chen, Jacob wrote:
> Hello, Dmytro,
> 
> How are you, I’m Jacob from Intel. :)
> As your consideration, “To extend the QMediaContent to add optional
> subtitle url” will just like adding a couple APIs like setSubtitleUri(),
> SubtitleUri() to QMediaContent? If so, I guess that, when calling
> setMedia() in QmediaPlayer, the subtitle will be set in the backend.
> However, I think this may limit to change the subtitle while playing
> video, but there may be requirement to change subtitle while playing
> video.

For adding subtitles during playback, just extending QMediaContent
may not be enough, in this case the better solution would be to add control 
like QMediaPlayerSubtitlesControl, with methods like addSubtitle(), setFont() 
etc, with added subtitle stream automatically activated and presented in 
QMediaStreamsControl.

> 
> By the way, any plan to come out the roadmap for external subtitle APIs
> support in qt-mobility?

I can't tell an exact date, 
during the next qtmobility multimedia releases.

> 
> Best Regards,
> - Jacob
> 

Regards
  Dmytro.

> ________________________________
> From: dmytro.poplavskiy at nokia.com [mailto:dmytro.poplavskiy at nokia.com]
> Sent: Tuesday, June 29, 2010 8:40 AM
> To: Zhao, Halley
> Cc: justin.mcpherson at nokia.com; Chen, Jacob;
> qt-mobility-feedback at trolltech.com Subject: Re: Subtitle support in
> Qt-mobility
> 
> Hi Halley,
> 
> I'm keeping in mind the subtitles support case,
> currently for subtitles embedded into the stream or connected to the stream
> (like DVD, DVB stream, mkv files, etc) backend may load and render
> subtitles itself, and provide QMediaStreamsControl to allows application
> to select which subtitles or audio tracks to render.
> 
> We don't currently have an API to specify the external subtitles url,
> I expect to extend the QMediaContent to add optional subtitle url, but this
> is not decided yet.
> 
> Regards
>   Dmytro.
> 
> 
> On 29/06/2010, at 10:25 AM, ext Zhao, Halley wrote:
> 
> 
> Hi Dmytro & Justin:
> Some customers request subtitle features, we need it support from
> QtMobility. How is your plan to support it?
> Thanks
> 
> 
> 
> ________________________________
> From:
> qt-mobility-feedback-bounces at trolltech.com<mailto:qt-mobility-feedback-bou
> nces at trolltech.com> [mailto:qt-mobility-feedback-bounces at trolltech.com] On
> Behalf Of Chen, Jacob Sent: 2010年6月24日 14:23
> To:
> qt-mobility-feedback at trolltech.com<mailto:qt-mobility-feedback at trolltech.c
> om> Subject: [Qt-mobility-feedback] Subtitle support in Qt-mobility
> 
> Hi here,
> I’m looking for a way to render subtitle file with video playback in
> qt-mobility. I found that qt-mobility is lack of subtitle/APIs support.
> Qt-mobility is using gstream playbin as the back-end of media player, but
> the subtitle functions haven’t been enabled. I made a simple patch to
> enable gstreamer plug-in to find and render the subtitle file which has
> same name as the media file automatically.
> 
> ---------------------------------------------------------------------------
> ---------------------------------------------------------------------------
> ------------
> 
> diff --git
> a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
> b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
> index 58ba160..7510be6 100644
> --- a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
> +++ b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp
> @@ -286,7 +286,7 @@ void QGstreamerPlayerControl::setMedia(const
> QMediaContent &content, QIODevice * m_seekToStartPending = false;
> 
>      QUrl url;
> -
> +
>      if (m_stream) {
>          if (m_stream->isReadable() && openFifo()) {
>              url =
> QUrl(QString(QLatin1String("fd://%1<fd://%251>")).arg(m_fifoFd[0])); @@
> -296,7 +296,7 @@ void QGstreamerPlayerControl::setMedia(const
> QMediaContent &content, QIODevice * }
> 
>      m_session->load(url);
> -
> +
>      if (m_fifoFd[1] >= 0) {
>          m_fifoCanWrite = true;
> 
> @@ -304,6 +304,20 @@ void QGstreamerPlayerControl::setMedia(const
> QMediaContent &content, QIODevice * }
> 
>      if (!url.isEmpty()) {
> +        QString subtitle_file = ".srt";
> +        QFileInfo fi(url.toLocalFile ());
> +       subtitle_file.prepend(fi.baseName());
> +        subtitle_file.prepend("/");
> +        subtitle_file.prepend(fi.absolutePath());
> +
> +        QFile file(subtitle_file);
> +        if (file.exists()) {
> +            subtitle_file.prepend("file://");
> +            m_session->set_sub_encoding("UTF");
> +            m_session->set_sub_font_desc("san bold 20");
> +            m_session->load_subtitle(QUrl(subtitle_file));
> +       }
> +
>          if (m_mediaStatus != QMediaPlayer::LoadingMedia)
>              emit mediaStatusChanged(m_mediaStatus =
> QMediaPlayer::LoadingMedia); m_session->pause();
> diff --git
> a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp
> b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp
> index 942a8ba..5c6aa77 100644
> --- a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp
> +++ b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.cpp
> @@ -151,6 +151,26 @@ void QGstreamerPlayerSession::load(const QUrl &url)
>      }
>  }
> 
> +
> +void QGstreamerPlayerSession::load_subtitle(const QUrl &url)
> +{
> +    m_url = url;
> +
> +    if (m_playbin)
> +        g_object_set(G_OBJECT(m_playbin), "suburi",
> m_url.toEncoded().constData(), NULL); +}
> +
> +
> +void QGstreamerPlayerSession::set_sub_encoding(const QString
> &encoding_String) { +   if (m_playbin)
> +       g_object_set(G_OBJECT(m_playbin), "subtitle-encoding",
> encoding_String.toLatin1().constData(), NULL); + }
> +
> +void QGstreamerPlayerSession::set_sub_font_desc(const QString
> &font_desc_String) { +   if (m_playbin)
> +       g_object_set(G_OBJECT(m_playbin), "subtitle-font-desc",
> font_desc_String.toLatin1().constData(), NULL); +}
> +
>  qint64 QGstreamerPlayerSession::duration() const
>  {
>      return m_duration;
> diff --git
> a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h
> b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h index
> 17f17bd..9550f38 100644
> --- a/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h
> +++ b/plugins/multimedia/gstreamer/mediaplayer/qgstreamerplayersession.h
> @@ -102,6 +102,9 @@ public:
> 
>  public slots:
>      void load(const QUrl &url);
> +    void load_subtitle(const QUrl &url);
> +   void set_sub_encoding(const QString &encoding_String);
> +   void set_sub_font_desc(const QString &font_desc_String);
> 
>      bool play();
>      bool pause();
> 
> ---------------------------------------------------------------------------
> ---------------------------------------------------------------------------
> ------------
> 
> I think the right way is to let QMediaplayer support subtitle APIs like,
> set_subtitle(), set_subtitle_encoding() and set_subtitle_font(), the
> application could have fully control of subtitle. Any suggestion?
> Jacob




More information about the Qt-mobility-feedback mailing list