ユーザーがビデオ メッセージを記録できる Web アプリを作成しようとしています。可能な限り最高の品質を取得しようとしています (アップロード時間が長くなる場合でも)。サーバーコードは次のようになりns.publish("livestream", "live");
ます。
Client.prototype.startRecord = function( source, destination ) {
trace("recording Stream: " + source + " to: " + destination);
this.newStream = Stream.get(destination);
this.fileRecording = destination;
trace(this.fileRecording);
if (this.newStream)
{
this.newStream.onStatus = function (info) {
//trace(info.code );
if (info.code == "NetStream.Play.PublishNotify") {
trace("start recording");
this.record();
}
}
this.newStream.play(source)
}
}
Client.prototype.stopRecord = function() {
trace("stopping Recording");
this.newStream.record(false);
this.newStream.play(false);
}
Client.prototype.getFiles = function() {
var fileRecord = new File("/streams/_definst_/"+this.fileRecording+".flv");
if (fileRecord.exists)
{
return this.fileRecording;
}
return "error recording";
}
application.onConnect = function(clObj) {
this.acceptConnection(clObj);
}
問題は、品質が良くないことです。を使ってみns.publish("livestream", "record");
たのですが、サーバー上に2つのファイルを作成して品質が向上しません。何か提案はありますか? 必要に応じて、クライアント コードをアップロードすることもできます。
クライアントコード:
import flash.media.*;
import flash.events.*;
import flash.net.*;
import flash.utils.getTimer;
var vid:Video;
var mic:Microphone;
var cam:Camera;
var fileListObj:Object = {};
var ns:NetStream;
var nc:NetConnection;
var recordingName:String;
initCamera();
function initCamera ():void
{
if (Camera.isSupported)
{
cam = Camera.getCamera();
cam.setMode (800, 480, 24);
//cam.setQuality(0, 90);
vid = new Video(cam.width,cam.height);
vid.attachCamera (cam);
if (Microphone.isSupported)
{
mic = Microphone.getEnhancedMicrophone();
}
this.addChildAt (vid, 1);
vid.x = (800 - vid.width) >> 1;
vid.y = (480 - vid.height) >> 1;
initConnection();
}
else
{
trace ("no camera");
}
}
function initConnection ():void
{
nc = new NetConnection();
nc.addEventListener (NetStatusEvent.NET_STATUS, netStatusHandler);
nc.addEventListener (AsyncErrorEvent.ASYNC_ERROR, function (event:AsyncErrorEvent):void {trace("error");});
nc.connect ("rtmp://adrian7.srfms.com/nabCapture");
}
function recordVideo (event:MouseEvent):void
{
if (record_mc.label == "Record")
{
record_mc.label = "Stop Record";
var currentTime:Date = new Date();
recordingName = "myRecording"+getTimer()+""+currentTime.time;
nc.call ("startRecord", new Responder(startPublish), "livestream", recordingName);
}
else
{
record_mc.enabled = false;
record_mc.label = "Record";
nc.call ("stopRecord", null);
ns.close();
nc.call ("getFiles", new Responder(onResultFileListObj, null));
}
}
function startPublish (result:Object):void
{
ns.publish("livestream", "live");
}
function netStatusHandler (event:NetStatusEvent):void
{
//trace (event.info.code);
if (event.info.code == "NetConnection.Connect.Success")
{
ns = new NetStream(nc);
ns.attachCamera (cam);
if (mic)
{
ns.attachAudio(mic);
}
record_mc.enabled = true;
record_mc.addEventListener (MouseEvent.CLICK, recordVideo);
}
}
function onResultFileListObj (resultObj:Object):void
{
if (String(resultObj) != "error recording")
{
recordingName = String(resultObj);
see_mc.enabled = true;
see_mc.addEventListener(MouseEvent.CLICK, function (event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.labs.adrian281990.com/fms_demo1/index.php?id=" + recordingName), "_self");
});
}
}