Skip to contentSkip to conversation

yocto playbin pipeline can not display subtitle

PATCH louwuxin 2 participants 2 messages Jul 27, 2016 – Jul 28, 2016 Arm i.MX and Layerscape

lore
Share & tools
lore

louwuxin

author
#0 lore raw

Dear meta-freescale,

I found a issue that playbin can not display some subtitle stream, if it already fix, please ignore this mail.

BSP environment:
2.0 - codename Jethro(imx6)

Issue describe:
when I run the pipeline like this: gst-launch-1.0 playbin uri=file:/xxx.videofile
If the video file include subtitle stream, the video playing with '*' instead the word of subtitle. At last, I found that the subtitle used utf8 coded, it will be display normally.

Fix describe:
I search the issue on imx community, and found "current imx6 bsp, not only ltib but also yocto couldn't support subtitle."

But when I changed demux plugin from 'aiurdemux' to 'qtdemux', I found it will be work well. so I find out the difference between 'aiurdemux' and 'qtdemux', and try to changed 'aiurdemux', now it will be work well with subtitle.

The iusse was that display subtitle plugin 'textoverlay' only accept utf8 coded subtitle stream, but 'aiurdemux' send out some other coded subtitle streams, if 'textoverlay' can not process subtitle streams, it will be print '*'. So I add a function in ‘aiurdemux’ do that translate other coded subtitle to utf8 coded subtitle.

patch:
Refer to the attachment.

imx-gst1.0-plugin-4.0.9/plugins/aiurdemux/aiurdemux.c +45 -0
index 8eb4060..fd19969 100755
@@ -338,6 +338,8 @@ static void aiurdemux_release_resource (GstAiurDemux * demux);
 static GstFlowReturn gst_aiurdemux_close_core (GstAiurDemux * demux);
 
 
+static GstBuffer *
+subtitle_to_utf8 (GstAiurDemux *demux, AiurDemuxStream *stream, GstBuffer *buf);
 
 
 
@@ -1370,6 +1372,14 @@ static GstFlowReturn aiurdemux_loop_state_movie (GstAiurDemux * demux)
     }
 
     gst_aiurdemux_push_tags (demux, stream);
+    stream->buffer = gst_buffer_make_writable (stream->buffer);
+    if (stream->need_subtitle_to_utf8) {
+        stream->buffer = subtitle_to_utf8 (demux, stream, stream->buffer);
+        if (!stream->buffer)
+            goto beach;
+        aiurdemux_adjust_timestamp (demux, stream, stream->buffer);
+    }
+
 
     //for vorbis codec data
     if(demux->option.disable_vorbis_codec_data &&
@@ -1418,6 +1428,40 @@ beach:
   return ret;
 }
 
+static GstBuffer *
+subtitle_to_utf8 (GstAiurDemux *demux, AiurDemuxStream *stream, GstBuffer *buf) {    
+    GstMapInfo map;
+    guint nsize = 0;
+    gchar *str;
+
+    gst_buffer_map (buf, &map, GST_MAP_READ);
+
+    if (map.size <=2) {
+        gst_buffer_unmap (buf, &map);
+        return NULL;
+    }
+
+    nsize = GST_READ_UINT16_BE (map.data);
+    nsize = MIN (nsize, map.size - 2);
+
+    str = gst_tag_freeform_string_to_utf8 ((gchar *) map.data + 2, nsize, NULL);
+    gst_buffer_unmap (buf, &map);
+
+    if (str) {
+        buf = gst_buffer_new_wrapped_full (g_free ? 0 : GST_MEMORY_FLAG_READONLY,
+                str, strlen(str), 0, strlen(str), str, g_free);
+        return buf;
+    } else {
+        return NULL;
+    }
+}
+
+static void
+aiurdemux_init_subtitle_to_utf8 (GstAiurDemux *demux, AiurDemuxStream *stream) {
+    if (stream->type == MEDIA_TEXT)
+        stream->need_subtitle_to_utf8 = TRUE;
+}
+
 static void
 aiurdemux_print_track_info (AiurDemuxStream * stream)
 {
@@ -1911,6 +1955,7 @@ static int aiurdemux_parse_streams (GstAiurDemux * demux)
       gst_pad_use_fixed_caps (stream->pad);
       gst_pad_set_event_function (stream->pad, gst_aiurdemux_handle_src_event);
       gst_pad_set_query_function (stream->pad, gst_aiurdemux_handle_src_query);
+      aiurdemux_init_subtitle_to_utf8(demux,stream); //init subtitle_to_utf8
       gst_pad_set_active (stream->pad, TRUE);
 
 
imx-gst1.0-plugin-4.0.9/plugins/aiurdemux/aiurdemux.h +1 -0
index b5589ee..4609592 100755
@@ -273,6 +273,7 @@ struct _AiurDemuxStream
     gint64 last_timestamp;
     gint64 lag_time;
     GstFlowReturn last_ret;
+    gboolean need_subtitle_to_utf8;  //use to decide yes/not change subtitle coded
 
     
 
#1 lore raw
Quoted 24 lines · louwuxin

Dear meta-freescale,

I found a issue that playbin can not display some subtitle stream, if it already fix, please ignore this mail.

BSP environment:
2.0 - codename Jethro(imx6)

Issue describe:
when I run the pipeline like this: gst-launch-1.0 playbin uri=file:/xxx.videofile
If the video file include subtitle stream, the video playing with '*' instead the word of subtitle. At last, I found that the subtitle used utf8 coded, it will be display normally.

Fix describe:
I search the issue on imx community, and found "current imx6 bsp, not only ltib but also yocto couldn't support subtitle."

But when I changed demux plugin from 'aiurdemux' to 'qtdemux', I found it will be work well. so I find out the difference between 'aiurdemux' and 'qtdemux', and try to changed 'aiurdemux', now it will be work well with subtitle.

Quoted 8 lines

The iusse was that display subtitle plugin 'textoverlay' only accept utf8 coded subtitle stream, but 'aiurdemux' send out some other coded subtitle streams, if 'textoverlay' can not process subtitle streams, it will be print '*'. So I add a function in ‘aiurdemux’ do that translate other coded subtitle to utf8 coded subtitle.

patch:
Refer to the attachment.

Please, follow the procedure to submit a patch to the layer, like in
http://git.yoctoproject.org/cgit/cgit.cgi/meta-fsl-arm/tree/README#n24

You can include most of this email in the commit log, I think...

Daiane

Quoted 16 lines

--
_______________________________________________
meta-freescale mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-freescale