2012年6月4日 星期一

串流軟體封包分析 -- youtube


分析 Youtube 串流封包,是否與 RTSP 有關。

一、使用 Flash Player

1. 下載 flash player
GET /strat/components/YTPlayer/1.0/YTPlayer.swf HTTP/1.1\r\n


2. 下載播放的內容
[truncated] GET /videoplayback?signature=2D12402B2...(略)

HTTP/1.1 303 See Other\r\n
[truncated] Location: http://203.66.48.224/youtube-videoplayback-fmt34/35.2051548658586a05?ivit=2684...(略)
GET /youtube-videoplayback-fmt34/35.2051548658586a05?ivit=2684... (略)
Accept: */*
Accept-Language: zh-TW
Referer: http://s.ytimg.com/yt/swfbin/watch_as3-vfliuDwY4.swf
x-flash-version: 10,1,85,3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; NP06)
Connection: Keep-Alive
Host: 203.66.48.224

HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Type: video/x-flv
Content-Length: 2457600
Last-Modified: Sat, 02 Jun 2012 20:20:24 GMT
Date: Mon, 04 Jun 2012 09:38:04 GMT
Connection: Keep-Alive

二、使用 html5

1. 下載 Javascript 所撰寫的 player
GET /yt/jsbin/html5player-vfl4vP7Wk.js HTTP/1.1\r\n
2. 下載影片,要求換URL
[truncated] GET /youtube-videoplayback-fmt34/43.0de46c2694e3cab4?ivit=4790&headers=Cookie%3DVISITOR_INFO1_LIVE%3D8olOa6hxG1Y&original=o-o.preferred.tpe05s03.v3.lscache8.c.youtube.com/videoplayback?upn=lHPjhYC3ShY&sparams=cp%2Cid%2Cip%2Cipb
...

HTTP/1.1 303 See Other\r\n
[truncated] Location: http://o-o.preferred.tpe05s03.v3.lscache8.c.youtube.com/videoplayback?upn=lHPjhYC3ShY&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&fexp=911623%2C907217%2C907335%2C921602%2C919306%2C919316%

3. 換 URL 下載影片,再次要求換URL
GET /videoplayback?upn=lHPjhYC3ShY&sparams=cp%2Cid%
Host: o-o.preferred.tpe05s03.v3.lscache8.c.youtube.com
...


HTTP/1.1 302 Found
Location: http://r5.tpe05s09.c.youtube.com/videoplayback?upn=lHPjhYC3ShY&...

4.  成功下載資料(Packet:342)
GET /videoplayback?upn=lHPjhYC3ShY&...
Host: r5.tpe05s09.c.youtube.com\r\n
...
HTTP/1.1 206 Partial Content
Last-Modified: Sun, 13 May 2012 14:57:07 GMT
Content-Type: video/webm
Date: Mon, 04 Jun 2012 10:13:11 GMT
Expires: Mon, 04 Jun 2012 10:13:11 GMT
Cache-Control: private, max-age=22712
Content-Range: bytes 0-19091773/19091774
Accept-Ranges: bytes
Content-Length: 19091774
Connection: close
X-Content-Type-Options: nosniff
Server: gvs 1.0
看來 Youtube 的播放也是跟 RTSP 無關,雖然 RTSP 是個標準的串流協議,但是看來商業上的許多應用都並非採用此協議,不知其考量為何。

參考資料
1. http://www.youtube.com/
2. http://www.youtube.com/html5
3. http://en.wikipedia.org/wiki/WebM