-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send ID3 tag even when it has malformed content #408
Conversation
Enables sending ID3 tag with as many frames as could be parsed.
can anyone pick up this PR? |
Ping! Can anyone look at this PR? We'd love to have this fix for shaka-project/shaka-player#3761 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR!
I think this change makes sense as a more lenient approach to malformed content, but it may be worth looking at the encoder and content themselves.
If this is the line that breaks the sample content, then the sample content appears to not have a valid frame header, as the size should be the size of the frame (which should be greater than 0).
Judging from
mux.js/lib/m2ts/metadata-stream.js
Line 216 in 1838b7f
if (tagParsers[frame.id]) { |
mux.js/lib/m2ts/metadata-stream.js
Lines 40 to 88 in 1838b7f
tagParsers = { | |
TXXX: function(tag) { | |
var i; | |
if (tag.data[0] !== 3) { | |
// ignore frames with unrecognized character encodings | |
return; | |
} | |
for (i = 1; i < tag.data.length; i++) { | |
if (tag.data[i] === 0) { | |
// parse the text fields | |
tag.description = parseUtf8(tag.data, 1, i); | |
// do not include the null terminator in the tag value | |
tag.value = parseUtf8(tag.data, i + 1, tag.data.length).replace(/\0*$/, ''); | |
break; | |
} | |
} | |
tag.data = tag.value; | |
}, | |
WXXX: function(tag) { | |
var i; | |
if (tag.data[0] !== 3) { | |
// ignore frames with unrecognized character encodings | |
return; | |
} | |
for (i = 1; i < tag.data.length; i++) { | |
if (tag.data[i] === 0) { | |
// parse the description and URL fields | |
tag.description = parseUtf8(tag.data, 1, i); | |
tag.url = parseUtf8(tag.data, i + 1, tag.data.length); | |
break; | |
} | |
} | |
}, | |
PRIV: function(tag) { | |
var i; | |
for (i = 0; i < tag.data.length; i++) { | |
if (tag.data[i] === 0) { | |
// parse the description and URL fields | |
tag.owner = parseIso88591(tag.data, 0, i); | |
break; | |
} | |
} | |
tag.privateData = tag.data.subarray(i + 1); | |
tag.data = tag.privateData; | |
} | |
}, |
Did you have a specific segment that's breaking on this line? I'd be interested to take a look, and if you have any other details on the ID3 tags that might help.
It would also be worth us adding a test, if you don't mind writing one up.
Thank you again!
After further investigation it turns out that, if the encoder is missing the audio URL, it creates an ID3 Nevertheless I'd recommend merging this PR.
mux.js won't decode the information sent in text frames other than mux.js/lib/m2ts/metadata-stream.js Line 213 in 1838b7f
so I'm able to decode it myself. I'll be willing to spend some more time and try to implement decoding of text content for all text frames (
I have a 5sec .ts file with malformed ID3 frame in a way described in the beginning of this commend. I can send it to you if you're interested.
I'll try my best and get back to you soon. |
Co-authored-by: Garrett Singer <gesinger@gmail.com>
validFrame = id3Frame('TIT2', | ||
0x03, // utf-8 | ||
stringToCString('sample title')), | ||
malformedFrame = id3Frame('WOAF'), // frame with size of 0B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could also create the same malformed frame like this:
stringToInts('WOAF').concat([
0x00, 0x00, 0x00, 0x00, // size
0x00, 0x00 // flags
]),
to make the malformation more visible
Thank you again @pszemus , I think you're right that we should add this despite it being a content issue. If encoders take the approach of including malformed ID3 frames it still makes sense to pass back valid ones already parsed.
Any contributions are very much appreciated if you have the time!
If the content is not public enough to share here, and you can share it via another medium (e.g., the Video.js Slack), let me know. It would be good for testing. And thank you for adding the test! |
This is the .ts file with malformed If you're happy with this PR you can merge it. Changes regarding parsing other frames will be sent in another PR. |
Enables sending ID3 tag with as many frames as could be parsed.
Without this change this.trigger('data', tag) wasn't called if stumbled upon malformed ID3 tag/frame.
Beneficiaries: Tellos Z/IP Stream encoder produces ID3 data with
TIT2
,WOAF
andTENC
frames, from which onlyTIT2
can be parsed by mux.js, so let's take those frames that have been parsed.Additionally, I'll take a look at mux.js' ID3 parser and try to find out if that metadata is really malformed or it's an issue with the parser.