儲存視頻會議的正確做法(Server-side Record Client-side Live Stream) | (22-01-2004) |
製作視頻會議應用時,經常有客戶要求能夠同時將會議儲存下來。平時,我們會利用Netstream Object,其中一方發出一個Live Stream: ns.publish("testStream", "live"); 觀看一方則用: ns.play("testStream", -1); 如果將Live改為Record或者Append,這個Live Stream就會同時儲存在FlashCom Application下的streams的Instance Folder裡,名稱為testStream.flv,而觀看一方繼續可以收到。雖然這個方法很簡單,但卻應付不到現實世界的要求,因為客戶希望要一個Button,控制會議有時會儲存,有時不會儲存。 很自然地,可以編寫一個Function,切換ns.publish的參數,一時用Live,一時用Append。可是,當Stream由Append(儲存)變成Live(不儲存)時,Flashcom會自動將之前儲存的FLV刪除! 解決方法一(不建議使用) 那麼用兩個NetStream Objects,ns1:負責Live Stream,發放給觀看一方;ns2:負責Append,發放給FlashCom儲存。如果要暫停儲存,可以用: ns2.publish(false); 雖然這可以解決了參數Live會刪除FLV的問題,卻花了多一倍Bandwidth,不化算。 解決方法二 利用Server-side Stream Object,它就是FlashCom Server-side的NetStream Object,原來的作用是用來作視頻分流,可以由一個FlashCom A要求視頻流到FlashCom B,再由FlashCom B發放到Client的Flash Player裡,藉以解決FlashCom Server License上的Bandwidth限制。 這裡利用Stream Object接收Client傳來的Live Stream(testStream),然後將它另存為testRecord.flv。Client-side ActionScript如常是: ns.publish("testStream", "live"); Server-side的main.asc: // 儲存的名稱 this.s = Stream.get("testRecord"); // Client傳來的Live Stream的名稱 this.s.play("testStream", -1, -1); // 開始儲存 this.s.record(); this.s.onStatus = function(info) { if (info.description == "testStream is now unpublished.") { // 當Client停止傳來時,就停止儲存 this.play(false); this.record(false); } } 根據FlashCom Help > Server-Side Communication ActionScript Dictionary > Server-Side Communication ActionScript > Stream.record,裡面指要停止儲存,只需要用參數false,這是錯誤的。用Communication App Inspector監測,當應用結束,仍然有一個Stream Publishing繼續執行著,因為Stream.play()沒有被停止,所以真正要停止儲存時,必須先用Stream.play(false);停止Stream Publishing,然後才用Stream.record(false);。 [範例](解壓到applications\ss_record) |
|
本文章由發表。 |
意見 | |
沒有意見。 |
|
同組文章 |