MP3 Extractor

This commit is contained in:
n1073645 2020-03-18 12:51:47 +00:00
parent cecae671d8
commit ff585584f6

View File

@ -780,7 +780,7 @@ export const FILE_SIGNATURES = {
1: 0xfb
}
],
extractor: null
extractor: extractMP3
},
{
name: "MPEG-4 Part 14 audio",
@ -3067,6 +3067,30 @@ export function extractWAV(bytes, offset) {
}
/**
* MP3 extractor.
*
* @param {Uint8Array} bytes
* @param {Number} offset
* @returns {Uint8Array}
*/
export function extractMP3(bytes, offset) {
const stream = new Stream(bytes.slice(offset));
if (stream.readInt(1) === 0xff) {
console.log("gggg");
} else if (stream.getBytes(3) === [0x49, 0x44, 0x33]) {
stream.moveTo(6);
const tagSize = (stream.readInt(1)<<23) | (stream.readInt(1)<<15) | (stream.readInt(1)<<7) | stream.readInt(1);
stream.moveForwardsBy(tagSize);
if (stream.getBytes(4) !== [0xff, 0xfb, 0x30, 0xc4])
console.log("always bad");
}
}
/**
* FLV extractor.
*