关闭

MPEG-4标签格式翻译

510人阅读 评论(0) 收藏 举报
MPEG-4标签格式翻译
2009-08-28 11:29

Atomicparsley.关于MPEG-4的Comment读取
文章来源 http://atomicparsley.sourceforge.net/mpeg-4files.html

Atoms, Boxes, Parents, Children & hex

一个MPEG-4文件由分开的、被称为atoms的单元组成(在第一版时这样叫,现在我们更倾向于称之为box)。一个atom有如下格式

任何超过基本的8字节的都被视为可选并且从它处于的位置继承下来(moov.udta.meta.XXXX atoms的格式由Quicktime定义),或者由它们的atom自己定义。ftyp atom总是第一个出现,它有一个确定的格式-它可以指定文件类型和atom结构的版本。

在上面的例子中,moov atom的长度为0x00001d38即7480字节。在后面是另一个atom,mvhd atom的长度为0x0000006c即108字节。因为108小于7480,所以mvhd atom是moov 原子的子atom。MPEG-4特别说明任何一个atom要么是一个父atom,要么后面附带信息,但不能两者都成立。

atom的长度等于它自身的长度加上后面子atom。例如,moov 的长度等于 mvhd的长度加上其它的跟它在同一级的atoms长度(图上没有出现),但mvhd的子atom不计算在内,因为mvhd的长度已经包含进来了。一个atom的和等于

4字节的 atom length
4字节的 atom name
???字节的可选数据。

因此,一个atom的最小长度为8字节

当moov.trak.mdia.minf.stbl.stsd可以即是一个父atom,又可以附加数据。苹果版权管理实现也有很多这种情况。moov.udta.meta因为历史原因也出现这种情况。但是,MPEG-4文件还是相对容易理解。

MPEG-4最重要的atom是mdat-文件真正的原始信息就储存在里,这个顶级atom占用大MPEG-4文件的大部份。不过,moov atom也提供了一些有用的信息。

uuid atom是公用自定义的atom,它与普通的atom类似,但它的name长度为8字节(4字节给uuid,另外4字节给uuid的名字)。索尼的PSP mp4文件显著地使用了uuid atoms。AtomicParsley 支持读取和写入uuid atoms。

stco 和 mdat

当一个新的atom加入时,继承树将要改变,atom的长度也要重新计算。如果mdat atom在文件靠前的位置,那么还有更多的地方要变动。有一些空白atom可以减少这种影响。

mdat由‘chunks’组成-这些chunks给出了相对文件位置信息,并告诉播放器媒体流在那个位置。这些信息储存在moov.trak.mdia.minf.stbl.stco。如下例如示

已知的iTunes元数据atoms

iTunes使用的元数据在moov.udta.meta.ilst下面。在ilst下面就直接指定了名字,但它不直接携带信息。子atom自己有附加对应的信息。4字节的代码如下表所示。

4char code

Name

Class/Flag

Appearance

©alb

Album

1

text

iTunes 4.0

©art

Artist

1

text

iTunes 4.0

aART

Album Artist

1

text

??

©cmt

Comment

1

text

iTunes 4.0

©day

Year

1

text

iTunes 4.0

©nam

Title

1

text

iTunes 4.0

©gen | gnre

Genre

1 | 0 1

text | uint8

iTunes 4.0

trkn

Track number

0

uint8

iTunes 4.0

disk

Disk number

0

uint8

iTunes 4.0

©wrt

Composer

1

text

iTunes 4.0

©too

Encoder

1

text

iTunes 4.0

tmpo

BPM

21

uint8

iTunes 4.0

cprt

Copyright

1

text

? iTunes 4.0

cpil

Compilation

21

uint8

iTunes 4.0

covr

Artwork

13 | 14 2

jpeg | png

iTunes 4.0

rtng

Rating/Advisory

21

uint8

iTunes 4.0

©grp

Grouping

1

text

iTunes 4.2

stik

?? (stik)

21

uint8

??

pcst

Podcast

21

uint8

iTunes 4.9

catg

Category

1

text

iTunes 4.9

keyw

Keyword

1

text

iTunes 4.9

purl

Podcast URL

21 | 0 4

uint8

iTunes 4.9

egid

Episode Global Unique ID

21 | 0 4

uint8

iTunes 4.9

desc

Description

1

text

iTunes 5.0

©lyr

Lyrics

3

text

iTunes 5.0

tvnn

TV Network Name

1

text

iTunes 6.0

tvsh

TV Show Name

1

text

iTunes 6.0

tven

TV Episode Number

1

text

iTunes 6.0

tvsn

TV Season

21

uint8

iTunes 6.0

tves

TV Episode

21

uint8

iTunes 6.0

purd

Purchase Date

1

text

iTunes 6.0.2

pgap

Gapless Playback

21

uin8

iTunes 7.0


1 Genre comes on 2 atoms - standard genres are on gnre; custom genres are on ©gen; only 1 is permitted at a time.
2 Coverart is the only atom that permits more than 1 data child atom. If there is a limit, its > 16.
3 Lyrics is the only text atom that doesnt't fall under a 255byte limit.
4 Apple changed from the original 21 to the current 0 around the release of iTunes 6.0.3
文本元数据长度限制在255字节,UTF-8编码,没有BOM,没有null结尾。

无符号长整形为8bit宽(比如tracknum限制在255)。大部分是atom把指定的格式(cpil 先有4字节的空,再是数据)。Viny1中的‘A1’指Apple.

Tagging implementations

The only style of metadata defined in the ISO Base Media File Format is what amounts to a single atom cprt - and the format described is in the 3gp asset style. In fact, the ISO copyright notice is identical to the 3gp copyright asset. This copyright notice is the only common tag available to all mpeg-4 files and derivatives.

The major brands that iTunes writes are listed at http://www.mp4ra.org/filetype.html, but iTunes-style metadata isn't defined in any publicly available document - its format is determined by the types of files that iTunes & the iTunes Music Store produce & provide. Since the goal of AtomicParsley is to set metadata is be maximally compatible with iTunes, the iTunes-style format of metadata is fully supported.

The 3GPP assets are family of metadata tags that the 3gp specification allows. These atoms differ in a number of ways from the more common iTunes style. There is no data atom; information is carried directly on the atom. Most 3gp assets have a language setting - so dozens of a like named atom are permitted that differ in the language used (around 480 languages).

A new style of metadata emerged with the foobar2000 0.9.x series. For whatever reason, this style typically duplicates the iTunes-style metadata. There is a double artwork tag, the artist is listed twice - it is heavy with redundancy. It is also non-compliant. A generic tool isn't allowed to create their own atoms - a mechanism exists to extend for supplemental functionality - the uuid atom form. foobar2000 doesn't use this mechanism. Nero has also adopted this tagging style with their freeware tagging tools. It seems to also write some tags in the reverse DNS form in the com.apple.iTunes domain.

The newest style of tagging was recently added at the MPEG4 Registration Authority. Currently, there is no known tool that can read or set this style of metadata

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2213次
    • 积分:34
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:3篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档