matroskademux: Wrong titles
Currently when processing mkv files gstreamer extracts wrong title data for video, audio and subtitles track.
Steps to reproduce:
wget https://sample-videos.com/video123/mkv/240/big_buck_bunny_240p_1mb.mkv
wget https://raw.githubusercontent.com/spektraldevelopment/spektralvideo/master/video/bigbuckbunny/bigbuckbunny.srt
mkvmerge -o test.mkv big_buck_bunny_240p_1mb.mkv bigbuckbunny.srt
mkvpropedit --edit info --set title=MYTITLE test.mkv
mkvpropedit --edit track:a1 --set name=MYAUDIO test.mkv
mkvpropedit --edit track:s1 --set name=MYSUBS test.mkv
Now run gst-discoverer-1.0 -v test.mkv
to get the following output:
Properties:
Duration: 0:12:00.000000000
Seekable: yes
Live: no
Tags:
encoder: Lavf53.24.2
container format: Matroska
datetime: 2021-01-12T23:48:29Z
title: MYTITLE, MYSUBS, MYTITLE, MYAUDIO, MYAUDIO, MYAUDIO, MYTITLE
bitrate: 0
extended comment: DURATION=00:11:58.000000000
language code: und
audio codec: MPEG-4 AAC audio
video codec: H264
container: video/x-matroska
subtitles: text/x-raw, format=(string)pango-markup
Tags:
encoder: Lavf53.24.2
container format: Matroska
datetime: 2021-01-12T23:48:29Z
title: MYTITLE, MYSUBS
bitrate: 0
extended comment: DURATION=00:11:58.000000000
language code: und
Codec:
text/x-raw, format=(string)pango-markup
Stream ID: ff3671f6a224945258488b71b8ebdeba0e4b99364950d64ba1d50521e71ee181/003:9292031702051792385
Language: und
audio: audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, codec_data=(buffer)11b0, level=(string)4, base-profile=(string)lc, profile=(string)lc, channels=(int)6, rate=(int)48000
Tags:
encoder: Lavf53.24.2
container format: Matroska
datetime: 2021-01-12T23:48:29Z
title: MYTITLE, MYAUDIO, MYAUDIO, MYAUDIO
bitrate: 384600
extended comment: DURATION=00:00:12.095000000
audio codec: MPEG-4 AAC audio
language code: und
Codec:
audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, codec_data=(buffer)11b0, level=(string)4, base-profile=(string)lc, profile=(string)lc, channels=(int)6, rate=(int)48000
Stream ID: ff3671f6a224945258488b71b8ebdeba0e4b99364950d64ba1d50521e71ee181/002:002
Language: und
Channels: 6 (front-left, front-right, front-center, lfe1, rear-left, rear-right)
Sample rate: 48000
Depth: 32
Bitrate: 384600
Max bitrate: 0
video: video/x-h264, level=(string)2, profile=(string)main, codec_data=(buffer)014d4014ffe10016674d4014da0507ec0440000003004000000c83c50aa801000468ef3c80, stream-format=(string)avc, alignment=(string)au, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
Tags:
encoder: Lavf53.24.2
container format: Matroska
datetime: 2021-01-12T23:48:29Z
title: MYTITLE
bitrate: 309588
extended comment: DURATION=00:00:12.080000000
video codec: H264
language code: und
Codec:
video/x-h264, level=(string)2, profile=(string)main, codec_data=(buffer)014d4014ffe10016674d4014da0507ec0440000003004000000c83c50aa801000468ef3c80, stream-format=(string)avc, alignment=(string)au, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
Stream ID: ff3671f6a224945258488b71b8ebdeba0e4b99364950d64ba1d50521e71ee181/001:001
Width: 320
Height: 240
Depth: 24
Frame rate: 25/1
Pixel aspect ratio: 1/1
Interlaced: false
Bitrate: 309588
Max bitrate: 0
As can be seen, while title for the video stream gets extracted correctly, it is wrong for the audio (MYTITLE, MYAUDIO, MYAUDIO, MYAUDIO), subtitles (MYTITLE, MYSUBS) and the whole file (MYTITLE, MYSUBS, MYTITLE, MYAUDIO, MYAUDIO, MYAUDIO, MYTITLE). Moreover, the last one seems to have always randomly changed order of items after the first "MYTITLE" when re-running gst-discoverer, which completely puzzles me.
Another scenario is when the mkv file has only the audio stream name specified and gstreamer sets it as title of the entire file, or when it has both title of the file and audio stream specified and gstreamer sets them to "MYAUDIO, MYTITLE, MYAUDIO, MYAUDIO, MYTITLE" and "MYAUDIO, MYTITLE, MYAUDIO, MYAUDIO".
I managed to bisect which commit introduced this issue: 4c10a1ba
However, reverting isn't a complete solution to the problem as before it gstreamer would set every title tag to the file title, disregarding audio and subtitle titles completely. It is a big improvement in behaviour though - if there is no title set for a video, gstreamer doesn't take it from audio title or subtitle titles and other programs can set it based on the filename.