ASF檔案格式

來源:互聯網
上載者:User

 asf 是 ( advanced streaming format 進階串流格式) 的縮寫,是 microsoft 為 windows 98 所開發的串流多媒體
檔案格式。這個詞彙當前可和 wma 及 wmv 互換使用

asf 是一個開放標準,它能依靠多種協議在多種網路環境下支援資料的傳送。同
jpg 、 mpg 檔案一樣, asf 檔案也是一種檔案類型,但它是專為在 ip 網上傳送有同步關係的多媒體資料而設計的,所以 asf 格式的資訊特別適合在 ip 網上傳輸。 asf 檔案的內容既可以是我們熟悉的普通檔案,也可以是一個由編碼裝置即時產生的連續的資料流,所以 asf 既可以傳送人們事先錄製好的節目,也可以傳送即時產生的節目。

asf 用於排列、組織、同步多媒體資料以利於通過網路傳輸。 asf 是一種資料格式,它也可用於指定實況示範。 asf 最適於通過網路發送多媒體流,也同樣適於在本地播放。任何壓縮 / 解壓縮運演算法則(轉碼器)都可用來編碼 asf 流。

 windows media service 的核心是 asf 。 asf 是一種資料格式,音頻、視頻、映像以及控制命令指令碼等多媒體資訊通過這種格式,以網路資料包的形式傳輸,實現流式多媒體內容發布。其中,在網路上傳輸的內容就稱為 asf stream 。 asf 支援任意的壓縮 / 解壓縮編碼方式,並可以使用任何一種底層網路傳輸協議,具有很大的靈活性。

microsoft media player 是能播放幾乎所有多媒體檔案的播放器,支援 asf 在 internet 網上的流檔案格式,可以一邊下載一邊即時播放,無需下載完再聽。

 

wma 檔案格式 ,即是 asf 的格式

header object

file properties object

stream properties object 1

stream properties object n

<other header objects>

data object

data packet 1

data packet m

<other top-level objects>

index object 1

index object k

simple index object 1

simple index object l

格式的簡單說明:

1.asfhead:

asf_header_object = 75b22630-668e-11cf-a6d9-00aa0062ce6c (16byte)

1 ,每一個 wma 檔案,它的頭 16 個位元組是固定的,為十六進位的 “30 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c” , 用來標識這個是否為 wma 檔案。接下來的 8 個位元組為一個整數,表示整個 wma 檔案頭部的大小,這個頭部裡麵包含了 tag 資訊等所有非音頻資訊,頭部後面的是音頻資訊,我們在這裡就不深入瞭解了。那個整數接下來的 4 個位元組幀的個數, 2 個位元組未知

field name

field type

size (bytes)

說明

object id

guid

16

就是上面的 object 序號

object size

qword 

8

asf head 大小 ( 包括以上 24 位元組 )

number of header objects

dword 

4

head 個數

reserved1

byte

1

reserved2

byte

1

也就是說從檔案開始位移量為 31 開始,裡面存放了很多幀,有我們需要的標準 tag 資訊,擴充 tag 資訊, wma 檔案控制資訊等等。每個幀不是等長的,但是幀頭是固定的 24 個位元組

asf_file_properties_object = 8cabdca1-a947-11cf-8ee4-00c00c205365 (16byte)

field name

field type

size (bits)

說明

object id

guid

128

8cabdca1-a947-11cf-8ee4-00c00c205365

object size

qword

64

這個幀(包括幀頭)的大小

file id

guid

128

file size

qword

64

creation date

qword

64

data packets count

qword

64

play duration

qword

64

send duration

qword

64

preroll

qword

64

flags

dword

32

broadcast flag

1 (lsb)

seekable flag

1

reserved

30

minimum data packet size

dword

32

maximum data packet size

dword

32

maximum bitrate

dword

32

2 . asf data object

the data object is represented using the following structure.

field name

field type

size (bytes)

object id

guid

16

object size

qword 

8

file id

guid

16

total data packets

qword

8

reserved

word

2

data packets

see section 5.2

varies

data object  (not loaded)  (9435146 bytes)

property

value

file position

3471  ( 0xd8f )

object id

75b22636-668e-11cf-a6d9-00aa0062ce6c

object size

9435146  ( 0x8ff80a )

mms id

68e9598c-336e-471d-8f2f-576e11e037c5

packets

3267

alignment

1

packet aligment

1

raw data dump

size

50  ( 0x32 )

data

0000: 36 26 b2 75 8e 66 cf 11-a6 d9 00 aa 00 62 ce 6c   6& u f       b l
0010: 0a f8 8f 00 00 00 00 00-8c 59 e9 68 6e 33 1d 47            y hn3 g
0020: 8f 2f 57 6e 11 e0 37 c5-c3 0c 00 00 00 00 00 00    /wn  7        
0030: 01 01                      

http 互動過程:

get /xfm2003/video/morrissey_-_first_of_the_gang_to_die_hi.wmv http/1.0

accept: */*

user-agent: nsplayer/9.0.0.3250

host: 195.173.73.27

x-accept-authentication: negotiate, ntlm, digest, basic

pragma: no-cache,rate=1.000,stream-time=0,stream-offset=4294967295:4294967295, packet-num=4294967295,max-duration=0

pragma: xplaystrm=1

pragma: xclientguid={3300ad50-2c39-46c0-ae0a-ef4916e929d5}

pragma: stream-switch-count=3

pragma: stream-switch-entry=ffff:1:0 ffff:2:2 ffff:3:0

accept-language: en-gb, *;q=0.1

http/1.0 200 ok

content-type: application/octet-stream

server: cougar 4.1.0.3857

via: netcache1-new (netcache netapp/5.6.2r1d17)

cache-control: no-cache

pragma: no-cache

pragma: client-id=5382809

pragma: features="seekable,stridable"

<http body>

..

<http body> 包格式:

command(2 bytes)

length(2 bytes)

data (length bytes)

...

...

...

data

seq(4)

id(1)

flag(1)

length(2)

asf data(length – 8)

儲存:把所有的 asf data 寫入本地檔案中,接收完後,最後回寫 asf_file_properties_object 幾個重要的欄位( file size/file size/creation date/data packets count/play duration/send duration/preroll/flags) ,即為 .asf 檔案了

00000000 48 54 54 50 2f 31 2e 30 20 32 30 30 20 4f 4b 0d http/1.0 200 ok.

...

000000e0 6b 61 62 6c 65 2c 73 74 72 69 64 61 62 6c 65 22 kable,st ridable"

000000f0 0d 0a 0d 0a   

000000f4 24 48 44 0b00 00 00 00 00 04 44 0b 30 26 b2 75 $hd..... ..d.0&.u

00000104 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c 8f 0d 00 00 .f...... .b.l....

00000114 00 00 00 00 09 00 00 00 01 02 a1 dc ab 8c 47 a9 ........ ......g.

00000124 cf 11 8e e4 00 c0 0c 20 53 65 68 00 00 00 00 00 ....... seh.....

...

<type header structure>: 24 48 44 0b

command: 24 48

2448 “$h” header packet follows

2444 “$d” data (media) packet follows

a444 “?d” data (sometimes used instead of $d)

2445 “$e” end of stream

2443 “$c” changing media – reload new media, new asf header follows

244d “$m” meta data follows (used for custom scripts)

2450 “$p” packet pair data follows

length: 44 0b = 0b44 , next header addr = 000000f4 + 0b44 + 4 = 00000c3c

<type object>: 00 00 00 00 00 04 44 0b      

seq: 00 00 00 00

id: 00   (00=live 01=pre-recorded)

flag: 04   (00 = middle of packet, 04 = first packet

08 = last packet 0c = only one packe)

<asf header>: 30 26 b2 ..

asf header size = 8f 0d 00 00 00 00 00 00 = 0d8f = 2271

asf_file_properties_object = 8cabdca1-a947-11cf-8ee4-00c00c205365

= a1 dc ab 8c 47 a9 cf 11 8e e4 00 c0 0c 20 53 65

<asf header ...>

next addr = 00000c3c + 028d + 4 = 00000ecd

00000c3c 24 48 8d 02 01 00 00 00 00 08 8d 02 00 69 00 61 $h...... .....i.a

00000c4c 00 20 00 56 00 69 00 64 00 65 00 6f 00 20 00 39 . .v.i.d .e.o. .9

...

00000e8c 84 00 00 02 00 2d a2 00 00 03 00 2d 8a 03 00 36 .....-.. ...-...6

00000e9c 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c 0a &.u.f... ....b.l.

00000eac f8 8f 00 00 00 00 00 8c 59 e9 68 6e 33 1d 47 8f ........ y.hn3.g.

00000ebc 2f 57 6e 11 e0 37 c5 c3 0c 00 00 00 00 00 00 01 /wn..7.. ........

00000ecc 01 

  上面 36 26 ... 為 <data object> 開始

<asf data packet> next addr = 00000ecd + 0b4f + 4 = 00001a20

live, seq = 05e7, first frame, packet size= 0b4f – 8 = 0b47 = 2887

00000ecd 24 44 4f 0b e7 05 00 00 00 04 4f 0b 82 00 00 09 $do..... ..o.....

00000edd 5d 00 0d c8 01 00 0a 00 82 03 43 be 02 00 00 0a ]....... ..c.....

00000eed ea 03 00 00 80 d3 01 00 28 00 2c 01 07 d0 91 d0 ........ (.,.....

<asf data packet> next addr = 00001a20 + 0b4f + 4 = 00002573

live, seq = 05e8

00001a19 04 62 86 dd 4c 94 48 24 44 4f 0b e8              .b..l.h$ do..

00001a25 05 00 00 00 00 4f 0b 82 00 00 09 5d 00 18 c8 01 .....o.. ...]....

00001a35 00 5e 00 84 82 a9 ea 09 00 00 08 8e 0a 00 00 d0 .^...... ........

00001a45 d3 01 00 a4 00 b4 c5 18 44 00 04 1f 2c 86 08 ac ........ d...,...

..

<asf data packet> next addr = 00002573 + 0b4f + 4 = 000030c6

live, seq = 05e9

00002561 16 fc 1c fc 85 00 63 4c e2 09 02 48 a2 08 07 b5 ......cl ...h....

00002571 66 d4 24 44 4f 0b e9 05 00 00 00 00              f.$do... ....

0000257d 4f 0b 82 00 00 09 5d 00 76 c8 01 00 6c 00 84 03 o.....]. v...l...

0000258d 46 83 02 00 00 0a 25 04 00 00 f8 d3 01 00 28 00 f.....%. ......(.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.