GNOME Bugzilla – Bug 752847
matroska mux doesn't write user-supplied tags unless the 'streamable' property is set
Last modified: 2015-07-26 17:23:07 UTC
User-supplied tags are not written out unless 'streamable=true' is set. Easily reproducible with gst-launch and mkvinfo. We'll try to but the tag comment=hello into the x.mkv file: $ gst-launch-1.0 videotestsrc ! taginject tags=comment=hello ! matroskamux ! filesink location=x.mkv Setting pipeline to PAUSED ... Pipeline is PREROLLING ... Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock ^Chandling interrupt. Interrupt: Stopping pipeline ... Execution ended after 0:00:03.699848471 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... ^C $ mkvinfo x.mkv + EBML head |+ Doc type: matroska |+ Doc type version: 2 |+ Doc type read version: 2 + Segment, size unknown |+ Seek head (subentries will be skipped) |+ Segment information | + Segment UID: 0x12 0x21 0x11 0xd4 0x51 0x77 0xbe 0x8e 0xd1 0x31 0x26 0xa7 0x26 0x70 0x10 0x62 | + Timecode scale: 1000000 | + Duration: 0.000s (00:00:00.000) | + Muxing application: GStreamer matroskamux version 1.5.2.1 | + Writing application: GStreamer Matroska muxer | + Date: Fri Jul 24 23:05:15 2015 UTC |+ Segment tracks | + A track | + Track number: 1 (track ID for mkvmerge & mkvextract: 0) | + Track type: video | + Track UID: 2201393592170869641 | + Default duration: 33.333ms (30.000 frames/fields per second for a video track) | + Name: Video | + Video track | + Pixel width: 320 | + Pixel height: 240 | + Colour space: length 4, data: 0x49 0x34 0x32 0x30 | + Codec ID: V_UNCOMPRESSED |+ Cluster ...Note that the mkvinfo does not show the "comment" tag as being defined. Rerun with the streamable property set: $ gst-launch-1.0 videotestsrc ! taginject tags=comment=hello ! matroskamux streamable=true ! filesink location=x.mkv $ mkvinfo x.mkv + EBML head |+ Doc type: matroska |+ Doc type version: 2 |+ Doc type read version: 2 + Segment, size unknown |+ Tags | + Tag | + Targets | + TrackUID: 127012133913909968 | + Simple | + Name: COMMENTS | + String: hello |+ Segment information | + Segment UID: 0x3d 0x73 0xba 0x2e 0x51 0x16 0xc9 0x66 0x5f 0x7b 0x83 0x4a 0xdb 0x82 0x8d 0xac | + Timecode scale: 1000000 | + Muxing application: GStreamer matroskamux version 1.5.2.1 | + Writing application: GStreamer Matroska muxer | + Date: Fri Jul 24 23:15:12 2015 UTC |+ Segment tracks | + A track | + Track number: 1 (track ID for mkvmerge & mkvextract: 0) | + Track type: video | + Track UID: 127012133913909968 | + Default duration: 33.333ms (30.000 frames/fields per second for a video track) | + Name: Video | + Video track | + Pixel width: 320 | + Pixel height: 240 | + Colour space: length 4, data: 0x49 0x34 0x32 0x30 | + Codec ID: V_UNCOMPRESSED |+ Cluster ...and the 'hello' comment is set. It seems that streams_tags are written by the following call in matroska-mux.c, which is only invoked when streamable is true: if (mux->streamable) { .... gst_matroska_mux_write_streams_tags (mux); ... } Disabling the mux->streamable conditional fixes the issue for me; diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 9f79175..ff0971e 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -2729,7 +2729,8 @@ gst_matroska_mux_start (GstMatroskaMux * mux) gst_ebml_write_master_finish (ebml, master); } - if (mux->streamable) { + // if (mux->streamable) { + if (1) { // Write tags regardless of value of mux->streamable const GstTagList *tags; gboolean has_main_tags;
(In reply to Glen Diener from comment #0) > User-supplied tags are not written out unless 'streamable=true' is set. > Easily reproducible with gst-launch and mkvinfo. > We'll try to but the tag comment=hello into the x.mkv file: > > $ gst-launch-1.0 videotestsrc ! taginject tags=comment=hello ! matroskamux ! The problem is on your side. You don't set a finit number of buffers (num-buffers=N) neither set the -e option to GST launch. That means you will cause an incorrect termination of the recording, and the matroska header will never be written to disk. Matroska files are still readable, but things like seeking will be slow and tag lost.
Thanks, you're right. My test showed that even with -e (whether or not I invoked videotestsrc with num-buffers=N or simply ctrl-C'ed), the stream tags were not written. However my test was wrong: turns out 'mkvinfo file.mkv' won't always show stream tags. But calling it with an increased verbosity (i.e. -v) will. Because of the profuse output, I needed grep to filter the result from the noise: $ cd /tmp $ gst-launch-1.0 -e videotestsrc num-buffers ! taginject tags=comment=hello ! matroskamux ! filesink location=x.mkv $ mkvinfo x.mkv | grep -A 100 Tags // Note: no -v, and no result... $ $ mkvinfo -v x.mkv | grep -A 100 Tags // Note:with -v, the tag is shown: |+ Tags | + Tag | + Targets | + TrackUID: 8728794964024215333 | + Simple | + Name: COMMENTS | + String: hello -grd