ams录像实现

本文介绍了一种使用Flash Media Server进行自定义文件名录制的方法。通过修改main.asc配置文件,实现了客户端开始和停止录制的功能,并详细展示了具体的ActionScript代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// main.asc

// ========发布时录像=============

application.onAppStart = function()

{

          trace("Application name: " + application.name);

          trace("Server: " + application.server);

          application.s = new Array();

}

 

 

application.onPublish = function(clientObj, streamObj)

{

          trace("recording started...");


          var strName = "recorded_" + streamObj.name;

          var s = Stream.get(strName);

          if (s == undefined )

                    return;

   

          if (!s.record("record"))

          {

                    s.trace("record failed.");

          }

 

          s.play(streamObj.name, -1, -1, true);

          application.s[streamObj.name] = s;

}

 

 

application.onUnpublish = function(clientObj, streamObj)

{

          var s = application.s[streamObj.name];

          if (s && s!= undefined)

          {

                    s.record(false);

                    s.play(false);

                    s.flush();

                    Stream.destroy(s);

                    application.s[streamObj.name] = null;

          }

}


//main.asc

// 实现自定义文件名录像,需要实现start,stop命令
application.onAppStart = function()
{
          trace("Application name: " + application.name);
          trace("Server: " + application.server);
          application.s = new Array();
}

// call startrecord

// s live stream name
Client.prototype.startrecord = function(s, filename)
{
s = Stream.get("mp4:" + filename + ".mp4"); 
if (s == undefined) {
trace("Stream.get failed");
return;
}

if (!s.record()) {
trace("record failed");
return;
}
s.play(s, -1, -1, true);
application.s[s] = s;
}

// call stoprecord
Client.prototype.stoprecord = function(s, filename)
{
var s = application.s[s];
if (s && s!= undefined)
{
s.record(false);
s.play(false);
s.flush();
Stream.destroy(s);
application.s[s] = null;
}
}


将main.asc放入ams安装目录下applications/live中即可,通过console可以观察打印情况。

不需要重启服务,修改main后reload就行。

转载请注明出处!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值