1、rm文件格式RealMedia Format This is the newer format which stores both audio and video. All multi-byte numbers are stored in big-endian format. A RealMedia file consists of a series of chunks. Each chunk has the following format: dword chunk type (FOURCC)dword chunk size, including 8-byte preambleword ch
2、unk versionbyte chunk payloadReal chunk types: .RMF: RealMedia file header (only one per file, must be the first chunk) PROP: File properties (only one per file) MDPR: Stream properties (one for each stream) CONT: Content description/metadata (typically one per file) DATA: File data INDX: File index
3、 (typically one per stream) RealMedia file header (.RMF) This must be the first chunk in a RealMedia file. Only one .RMF can be present in a file. The only useful information carried by .RMF is the number of headers. A .RMF chunk has the following format dword chunk type (.RMF)dword chunk size (typi
4、cally 0x12)word chunk version (always 0, for every known file)dword file versiondword number of headersFile properties header (PROP) This chunk contains some information about the general properties of a RealMedia file. Only one PROP chunk can be present in a file. A PROP chunk has the following for
5、mat dword Chunk type (PROP)dword Chunk size (typically 0x32)word Chunk version (always 0, for every known file)dword Maximum bit ratedword Average bit ratedword Size of largest data packetdword Average size of data packetdword Number of data packets in the filedword File duration in msdword Suggeste
6、d number of ms to buffer before starting playbackdword Offset of the first INDX chunk form the start of the filedword Offset of the first DATA chunk form the start of the fileword Number of streams in the fileword Flags (bitfield, see below)Flags: bit 0: file can be saved on disk bit 1: PerfectPlay
7、can be used (extra buffering) bit 2: the file is a live broadcast Media properties header (MDPR) This chunk contains information about the properties of a RealMedia stream. This header defines the type of a stream and the codec used. All codec-related data is in the type specific part of this header
8、. Many fields share the same meanings as the ones in PROP chunk, but in this case they are specific for one stream. There is one MDPR chunk for every stream in the file. A MDPR chunk has the following format dword Chunk type (MDPR)dword Chunk sizeword Chunk version (always 0, for every known file)wo
9、rd Stream numberdword Maximum bit ratedword Average bit ratedword Size of largest data packetdword Average size of data packetdword Stream start offset in msdword Preroll in ms (to be subtracted from timestamps?)dword Stream duration in msbyte Size of stream description stringbyte Stream description
10、 stringbyte Size of stream mime type stringbyte Mime type stringdword Size of type specific part of the headerbyte Type specific data, meaning and format depends on mime typeAudio (audio/) audio/x-pn-realaudio and audio/x-pn-multirate-realaudio These mimetypes are used to specify streams with RealAu
11、dio codecs. There are 3 known versions of this datablock: ra3, ra4, ra5. ra3 is used only with the old 14_4 codec, ra4 and ra5 can be used with all the other codecs. The audio block has this format byte4 Header signature (., r, a, 0xfd) word Version (3, 4 or 5)#if version = 3 word Header size, not i
12、ncluding first 8 bytes byte10 Unknown dword Data size byte Title string length byte Title string byte Author string length byte Author string byte Copyright string length byte Copyright string byte Comment string length byte Comment string byte Unknown * byte Fourcc string length (always 4) * byte F
13、ourcc string (always lpcJ) *#elseif version = 4 or version = 5 word Unused (always 0) byte4 ra signature (.ra4 or .ra5, depending on version) dword Unknown (maybe data size) word Version2 (always equal to version) dword Header size word Codec flavor dword Coded frame size byte12 Unknown word Sub pac
14、ket h word Frame size word Subpacket size word Unknown#if version = 5 byte6 Unknown#endif word Samplerate word Unknown word Sample size word Channels#if version = 4 byte Interleaver ID string length (always 4) byte Interleaver ID string byte FourCC string length (always 4) byte FourCC string#endif#i
15、f version = 5 dword Interleaver ID dword FourCC#endif byte3 Unknown#if version = 5 byte Unknown#endif dword Codec extradata length byte Codec extradata#endifaudio/X-MP3-draft-00 This is used to store MP3 audio in rm container. When this mimetype is used the type-specific part of the MDPR header is n
16、ot used, and its length is set to 0. The MP3 frames are stored in ADU format (see RFC 3119 for details) with no interleaving (at least this is true in the only known sample). audio/x-ralf-mpeg4 This is used to store ralf lossless audio. This is the only known RealAudio codec that does not use the x-
17、pn-realaudio mimetype. The format of this type-specific data is not known. Content description header (CONT) This chunk contains some text information (like title, author, .) about the content of the file. This header has an informative purpose only and its not needed to demux the file. A CONT chunk
18、 has the following format dword Chunk type (CONT)dword Chunk sizeword Chunk version (always 0, for every known file)word Title string lengthbyte Title stringword Author string lengthbyte Author stringword Copyright string lengthbyte Copyright stringword Comment string lengthbyte Comment stringData h
19、eader (DATA) This chunk contains a group of data packets. Packets from each stream are interleaved, except for multirate files. A DATA chunk has the following format dword Chunk type (DATA)dword Chunk sizeword Chunk version (always 0, for every known file)dword Number of data packets in this chunkdw
20、ord Offset of the next DATA chunk (form the start of the file)byte Data packetsEach data packet has this format word Packet version (0 or 1 in available samples) word Packet size word Stream number dword Timestamp (in ms) byte Unknown byte Flags (bitfield, see below)#if version = 1 byte Unknown#endi
21、f byte Stream-specific dataFlags: bit 0: reliable packet (refers to network transmission method) bit 1: keyframe Note: The previous description of the data packet comes from working demuxer code, the description in official Real docs (somewhere on Helix site) is a bit different: word Packet version
22、word Packet size word Stream number dword Timestamp#if version = 0 byte Packet group byte Flags#endif#if version = 1 word ASM rule byte ASM flags#endif byte Stream-specific datawhere packet group is The packet group to which the packet belongs. If packet grouping is not used, set this field to 0 (ze
23、ro), asm rule is The ASM rule assigned to this packet and asm flags Contains HX_ flags that dictate stream switching points. Index header (INDX) This chunk contains index entries. It comes after all the DATA chunks. An index chunk contains data for a single stream, A file can have more than one INDX
24、 chunk. A INDX chunk has the following format dword Chunk type (INDX)dword Chunk sizeword Chunk version (always 0, for every known file)dword Number of entries in this chunkword Stream numberdword Offset of the next INDX chunk (form the start of the file)byte Index entriesEach index entry has this f
25、ormat word Entry version (always 0, for every known file) dword Timestamp (in ms) dword Packet offset in file (form the start of the file) dword Packet numberrm文件包含如下域字段 .RMF .RMS CONT PROP MDPR 上面的四个域字段哪个老外已经分析了,附后 DATA INDX 下面仅对 data,indx 域字段进行分析 DATA 字段包含的内容: +0: dword “DATA”字段标志 +4: dword该字段总长度。
26、 +8: word应该为 零 +a: dword总帧数 +c-11h0 估计是保留的 +12: 以包为单位的流数据格式如下: 另在DATA部分的数据是按包进行组织的,包的格式如下: 12个字节为包头 +0:dword 记录是这个包的长度包裹头在内 +4: word 音频或视频标志 +6:dword 如果是音频则是相对开始的时间以ms为单位 如果是视频则是压缩给定的一个标定时间。 +a:word 该包的位置是否在索引表中,0不在,2在。 +c: 压缩后的数据长度等于 +0 处的长度 - 12 又加入6-7字节的头 +c: d7 : 如果为1表示帧结束包。否则该帧有很多包组成 d6 : =1 表示
27、在后续的+10,11字节表示的意思是帧的时间标号 d3-d0: 为零表示没有包编号字节 +d: d7: 等于1,后面用四个字节表示压缩后帧数据长度。之后推移到+10解释相同 下面的解释是d7=0的。 d6-d0: 帧编号字节可能没有,如果没有下面的依次前移一个字节 +e:d7 - d6: 压缩后的数据长度表示,后面要用多少个字节 d5 -d0: 压缩后的数据长度的高6bit +f:压缩后的一帧数据长的低8bit +10:d7 - d6: 压缩后的数据长度相对位置,后面要用多少个字节表示 d5-d0相对位置表示的高6bit如果是最后一个slice包,则表示这个帧在这个包中还剩余的字节数 +11:
28、相对位置表示的低8bit如果是最后一个slice包,则表示这个帧在这个包中还剩余的字节数 如果一个帧压缩后很小,那么上面的10,11可能表示该帧的时间标号 +12:帧编号在该包中。一个包可以包含很多帧因为,有时帧压缩后可能很小 INDX字段包含的内容: +0:dword “INDX”字段标志 +4:dword该字段总长度。 +8: word应该为 零 +a: dword总索引个数 +e: word索引类型,表示是音频的还是视频的。 +10: dword下一个索引表的位置 +14:以长度为14e的索引表 视频的字段定义如下: +0: word 保留 为零 +2:dword时间标号,压缩时给定的 +6:dword该帧的位置相对整个文件 +a:dword该帧的编号 音频的字段定义如下: +0: byte 保留 0 +2: dowrd 此语音相对开始的时间以ms为单位,与视频的时间标号相对应 +6: dowrd 该段语音在文件中的相对位置 +a: dword 对应的视频帧的编号。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1