After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762349 - matroskamux: generated files sometimes don't open on android
matroskamux: generated files sometimes don't open on android
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal normal
: 1.7.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 738575 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-02-19 22:48 UTC by Matej Knopp
Modified: 2018-05-06 14:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (6.67 KB, patch)
2016-02-19 22:48 UTC, Matej Knopp
committed Details | Review

Description Matej Knopp 2016-02-19 22:48:32 UTC
Created attachment 321701 [details] [review]
Patch

Stagefright uses libwebm to demux matroska files, but the library has a nasty bug where it fails to parse tags/tag element without any contents; 

This has been fixed recently
https://bugs.chromium.org/p/webm/issues/detail?id=1125

but all Android version up to and include 6.0.1 are affected. There is good chance that majority of devices will never get the fix. 

So while there is nothing wrong with the muxer, to ensure compatibility with those devices attached patch makes sure that empty tags/tag elements are not written.
Comment 1 Sebastian Dröge (slomo) 2016-02-20 08:56:09 UTC
Comment on attachment 321701 [details] [review]
Patch

I think this generally makes sense, what use are empty tags?

But if I understand this correctly, you would still write empty tags if there are also some non-empty ones? Is that intentional? Just skips the non-empty ones :)


And why are you checking against gst_value_serialize() being NULL? That doesn't seem like the ideal check for empty tags
Comment 2 Matej Knopp 2016-02-20 11:17:44 UTC
Not quite sure what you mean by that. By empty tag, I meant something that gst_matroska_mux_write_simple_tag ignores. That means tags that can not be mapped (by gst_matroska_tag_conv) or tags with value that failed to serialize. Those are the tags that GST_MATROSKA_ID_SIMPLETAG will not be written for.
Hence the NULL check after serialization. 

So if you have bunch of tags, and not a single one of them maps or serializes, you can not write the surrounding GST_MATROSKA_ID_TAGS and GST_MATROSKA_ID_TAG element, because webm parser chokes on empty GST_MATROSKA_ID_TAG element.

Using gst_matroska_mux_tag_list_is_empty instead of gst_tag_list_is_empty should take care of this (look at for example gst_matroska_mux_start).

That said, I'm not entirely sure if tags with empty (zero length) value would also break the parser. I'll test it, but looking at the mkvparser.cpp code, I actually think it might, because ParseElementHeader is also being used to parse GST_MATROSKA_ID_TAGSTRING elements; If that's the case, we'll probably need to check for serialized value both being null and empty string.
Comment 3 Sebastian Dröge (slomo) 2016-02-20 15:30:46 UTC
So the problem is empty TAGS without containing a TAG? Or TAG without content? We shouldn't write either of these IMHO.

But testing if a tag is empty via serialization returning NULL seems a bit weird nonetheless.
Comment 4 Matej Knopp 2016-02-20 16:47:01 UTC
well, the way tags are muxed in matroska is TAGS -> TAG -> bunch of SIMPLE_TAGs. 

The issue is TAG without content (no SIMPLE_TAGs); And I'm also guessing SIMPLE_TAG with empty string value too, I'll have to test later.

The null check after serialization is same thing gst_matroska_mux_write_simple_tag does. I wanted it to be consistent. gst_matroska_mux_write_simple_tag skips tags that have value that fails to serialize, so gst_matroska_mux_tag_list_is_empty should do the same.
Comment 5 Sebastian Dröge (slomo) 2016-02-21 08:52:28 UTC
So I think we should not add empty SIMPLE_TAGS, and not TAGS and TAG if they are not going to contain anything. Everything else is just useless information in the files anyway :)

My main remaining problem here is that we now serialize each tag twice but I don't see how that can be easily improved in a way that is not even more ugly. You? :)
Comment 6 Matej Knopp 2016-02-22 19:55:57 UTC
Two things: Tags that serialize to empty string are handled correctly. So we don't need to skip such tags (it actually wouldn't seem right anyway). Thus the patch should cover all tag related scenarios.

> So I think we should not add empty SIMPLE_TAGS, and not TAGS and TAG if they are not going to contain anything

That's what my patch does. If none of the SIMPLE_TAGs are be written, the outer TAGS and TAG will not be written either. Otherwise the file won't load.

Serializing the tag twice may not be the most elegant solution, but needs to be done for consistency. gst_matroska_mux_write_simple_tag skips tags that won't serialize, so we need to know upfront if that's the case before writing TAGS and TAG.
Comment 7 Sebastian Dröge (slomo) 2016-02-23 09:02:14 UTC
commit 8657987f8f9e659a7207f5d69fdc679f5ff8f24e
Author: Matej Knopp <matej.knopp@gmail.com>
Date:   Fri Feb 19 23:44:42 2016 +0100

    matroskamux: don't output empty tags/tag elements
    
    Such files will not play on Android, because of bug in libwebm matroska parsing, which is still present in 6.0.1
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762349
Comment 8 Sebastian Dröge (slomo) 2016-02-23 09:02:43 UTC
Let's go with that then for now.
Comment 9 Tim-Philipp Müller 2018-05-06 14:55:49 UTC
*** Bug 738575 has been marked as a duplicate of this bug. ***