再探 Youtube 技術

現在已經有 Panasonic 的電視可以支援 Youtube 了! 雖然美國朋友說比較紅的已經變成 Hulu, 不過美國境外的人暫時還看不到 Hulu 網站, 所以我們還是先搞懂 Youtube.

Youtube 的網站有幾個地方值得探討:

Q1. Video/Audio 壓縮格式

Q2. 可否下載?

Q3. 未來發展

A1. 關於第一個問題:

Youtube 支援的格式為:

Platform Container Video Audio
PC SWF/FLV FLV1=Sorenson MP3
覆蓋式廣告(480×70)
影片內廣告(320×250)
SWF (Shockwave Flash) + FLA    
手機  3GP  H263 AMR 

手機 Youtube 資料來源: http://www.thinknext.net/archives/tag/youtube#

 

A2. Youtube 使用 streaming 串流技術, 基本上不希望大家下載.

然而, 還是有網站和工具協助大家下載這些影片:

http://blog.roodo.com/jojos/archives/3434155.html

下載之後, 還有很多轉檔工具.

http://download.longtermly.com/category/internet-tools/youtube-tools/

如果 user 端可以支援 streaming 的話 (也就是採用 RTP、RTSP 網路協議), 當然可以藉著 Youtube 的網址, 播出正確的內容. 當然, 若實際上不支援 SWF, 就要 hack 到檔案正確的位置, 透過 HTTP 網路協議, 將整個檔案 (FLV) 拿來解.

Youtube 為了防範大家找到 FLV 真正的位置, 會在 streaming URL 與 file storage URL 之間改變對應關係. 也就是說, 如果大家乖乖 streaming, 那個 URL 是不會變的. 但是如果想要 download 的話, 就要找出兩者對應的規則.

通常這個規則也很簡單. 引用啾啾的部落格的文字:

舉例來說如果我想下載此影片:
原網址:
http://www.youtube.com/watch?v=IncztAzMsck

將「watch?v=」換成「v/」後貼到瀏覽器上
http://www.youtube.com/v/IncztAzMsck
網址將會變成
http://www.youtube.com/p.swf?video_id=IncztAzMsck&eurl=&iurl=http…

再把「p.swf?」改成「get_video.php?」變成
http://www.youtube.com/get_video.php?video_id=IncztAzMsck&eurl=&i…

之後就可以直接下載影片了,記得要加上 .flv 副檔名,這就是直接下載的方法.

A3. 關於第三個問題, 因為 SWF 已經是 Adobe 的資產. 在 Adobe 的藍圖之中, 未來會用 H.264 和 AAC 來當作 Adobe SWF/FLV decoder 的音視頻格式.

也有一種說法是, Youtube 其實已經悄悄地在提供 SWF 9 的輸出. 使用 popcorn hour 這台機器連上 Youtube 就會看到畫質較佳的 streaming quality.這一點未經證實.

如果連結到其他 Youtube like 的網站, 它的 video 可能是 VP6. 主要是 flash player 的版本不同. 詳見下表:

version container video 格式
6 SWF/FLV TrueMotion VP6 (H.263-like)(audio = NellyMoser)
7 SWF/FLV Screen video bitstream
format = lossless
 8 SWF/FLV TrueMotion VP6 (H.263-like)
9 SWF/FLV H.264
10 SWF/FLV 多了 3D effect, audio mixing 等功能

FLV 小檔案

FLV 家族實在有點複雜, 首先它的源起是 Adobe 原來的 SWF 只是為了動畫 (像是前幾年流行的賤兔 SWF), 但是放 video 就不行了, 因此便有 FLV 這個新的 container 產生.

第一版的 FLV, video 壓縮是 H.263 的變形, 又叫 Sorenson Park. 又有人稱它為 FLV1的 video format. 這個應該就是 Youtube 在用的 video format.

Adobe Flash Player 8 的 video 改成了 On2 公司的 TrueMotion VP6 .又有人稱它為 FLV4 的 video. On2 後來出了 VP7, 但不知道誰在用? 

Note> On2 VP6:中國土豆網在用.

Adobe Flash Player 9 的 video 改成了 H.264 (video) 搭配 AAC (audio).

如果從 Youtube 抓回來的檔案, 它的 audio 多數是 MP3 , 但如果是自製的 FLV 檔, audio 可能是 NellyMoser. 另外也有 ADPCM 或 PCM.

使用 FLV 的網站包括: YouTube, Google Video, Reuters.com, Yahoo! Video, 但不知道每一家用的壓縮技術是否一樣?

從 WIKI 抓來這個表:

http://en.wikipedia.org/wiki/Flash_Video

File Formats

Because of restriction in the .flv format, Adobe is moving to a new file format, listed below. Flash player does not however, check the extension of the file, but rather looks inside the file to detect which format it is.

File Extension Mime Type Description
.f4v video/mp4 Video for Adobe Flash Player
.f4p video/mp4 Protected Video for Adobe Flash Player
.f4a audio/mp4 Audio for Adobe Flash Player
.f4b audio/mp4 Audio Book for Adobe Flash Player

These file formats are recommend formats for H.264/AAC support.

Codec support of FLV

Codecs Support
H.264 Yes
VP6 Yes
Xvid No
Divx No
Sorenson H.263 Yes