浏览代码

MP3 Extractor

n1073645 5 年之前
父节点
当前提交
ff585584f6
共有 1 个文件被更改,包括 25 次插入1 次删除
  1. 25 1
      src/core/lib/FileSignatures.mjs

+ 25 - 1
src/core/lib/FileSignatures.mjs

@@ -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.
  *