0

我在将 M4A 原子插入文件时遇到问题。由于原始文件没有 udta 结构,因此我使用现有的 M4A 文件添加它作为指南。

这是我添加原子的操作:

  1. 在内存中构建一个 udta atom
  2. 更新 moov atom 的大小以包含 udta atom 的大小
  3. 将文件复制到第一个 trak atom 的末尾
  4. 插入我的 udta atom
  5. 照常复制其余部分。

原始文件和标记文件之间唯一真正的区别是 mdat 原子被向下移动了一点以容纳标记。这让我相信在其他原子中有一些关于那个位置的参考,但我找不到。

这是 AtomicParsley 的输出:

原始文件:

Atom ftyp @ 0 of size: 36, ends @ 36
Atom moov @ 36 of size: 30156, ends @ 30192
     Atom mvhd @ 44 of size: 108, ends @ 152
     Atom iods @ 152 of size: 33, ends @ 185
     Atom trak @ 185 of size: 30007, ends @ 30192
         Atom tkhd @ 193 of size: 92, ends @ 285
         Atom mdia @ 285 of size: 29907, ends @ 30192
             Atom mdhd @ 293 of size: 32, ends @ 325
             Atom hdlr @ 325 of size: 37, ends @ 362
             Atom minf @ 362 of size: 29830, ends @ 30192
                 Atom smhd @ 370 of size: 16, ends @ 386
                 Atom dinf @ 386 of size: 36, ends @ 422
                     Atom dref @ 394 of size: 28, ends @ 422
                 Atom stbl @ 422 of size: 29770, ends @ 30192
                     Atom stts @ 430 of size: 24, ends @ 454
                     Atom stsd @ 454 of size: 106, ends @ 560
                         Atom mp4a @ 470 of size: 90, ends @ 560
                             Atom esds @ 506 of size: 54, ends @ 560
                     Atom stsz @ 560 of size: 26888, ends @ 27448
                     Atom stsc @ 27448 of size: 40, ends @ 27488
                     Atom stco @ 27488 of size: 2704, ends @ 30192
Atom mdat @ 30192 of size: 2495503, ends @ 2525695

修改文件:

Atom ftyp @ 0 of size: 36, ends @ 36
Atom moov @ 36 of size: 30323, ends @ 30359
     Atom mvhd @ 44 of size: 108, ends @ 152
     Atom iods @ 152 of size: 33, ends @ 185
     Atom trak @ 185 of size: 30007, ends @ 30192
         Atom tkhd @ 193 of size: 92, ends @ 285
         Atom mdia @ 285 of size: 29907, ends @ 30192
             Atom mdhd @ 293 of size: 32, ends @ 325
             Atom hdlr @ 325 of size: 37, ends @ 362
             Atom minf @ 362 of size: 29830, ends @ 30192
                 Atom smhd @ 370 of size: 16, ends @ 386
                 Atom dinf @ 386 of size: 36, ends @ 422
                     Atom dref @ 394 of size: 28, ends @ 422
                 Atom stbl @ 422 of size: 29770, ends @ 30192
                     Atom stts @ 430 of size: 24, ends @ 454
                     Atom stsd @ 454 of size: 106, ends @ 560
                         Atom mp4a @ 470 of size: 90, ends @ 560
                             Atom esds @ 506 of size: 54, ends @ 560
                     Atom stsz @ 560 of size: 26888, ends @ 27448
                     Atom stsc @ 27448 of size: 40, ends @ 27488
                     Atom stco @ 27488 of size: 2704, ends @ 30192
     Atom udta @ 30192 of size: 167, ends @ 30359
         Atom meta @ 30200 of size: 159, ends @ 30359
             Atom ilst @ 30212 of size: 147, ends @ 30359
                 Atom ©ART @ 30220 of size: 35, ends @ 30255
                     Atom data @ 30228 of size: 27, ends @ 30255
                 Atom ©nam @ 30255 of size: 63, ends @ 30318
                     Atom data @ 30263 of size: 55, ends @ 30318
                 Atom ©alb @ 30318 of size: 41, ends @ 30359
                     Atom data @ 30326 of size: 33, ends @ 30359
Atom mdat @ 30359 of size: 2495503, ends @ 2525862

另一件值得注意的事是,我用作参考的标记文件在 udta->meta 下有一个 hdlr 原子,但添加该标记的副本也无济于事。如果我手动删除 udta atom 和 moov 的大小数据,该文件将再次运行。

当我尝试播放标记文件时,我在各种程序中收到这些错误:

mplayer:
    [aac @ 0x204d720] channel element 0.0 is not allocated
    [aac @ 0x204d720] channel element 0.0 is not allocated
    [aac @ 0x204d720] channel element 3.13 is not allocated
    [aac @ 0x204d720] channel element 2.14 is not allocated
    [aac @ 0x204d720] channel element 2.9 is not allocated
    [aac @ 0x204d720] Prediction is not allowed in AAC-LC.
    [aac @ 0x204d720] channel element 3.1 is not allocated
    [aac @ 0x204d720] channel element 0.3 is not allocated
    ....
totem:
    ** Message: Error: Could not decode stream.
    gstfaad.c(1319): gst_faad_chain (): /GstPlayBin2:play/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstFaad:faad0:
    decoding error: Bitstream value not allowed by specification
banshee:
    [Error 08:26:27.610] GStreamer stream error: Decode
    [Error 08:26:27.960] GStreamer stream error: Decode
    [Error 08:26:28.252] GStreamer resource error: NotFound

哦,我多么希望其他 99% 的程序能够识别除 MP3 以外的文件上的 ID3 标记....

4

1 回答 1

0

多亏了 xdelta3,我能够找到用标记软件标记然后手动删除的文件与原始文件之间的区别。

问题似乎是“stco”原子,它是使用绝对文件偏移量的块列表。答对了!由于我添加了标签,因此这些偏移量现在无效。更多的编码做感叹

于 2012-03-12T14:35:24.643 回答