将时间戳添加到 Flash Media Server 中的文件名

发布于 2024-10-09 16:06:20 字数 1086 浏览 0 评论 0原文

有没有什么方法可以动态命名在 Flash Media 服务器中发布的文件。

应用程序中的多个客户端将发布到 FMS。它们可能会多次开始和停止记录,我想在 main.asc 中的文件名中附加一个时间戳(格式:yy-mm-dd-hh-mm-ss)。

例如,客户端 1 和 2 可能使用 ns.publish(myclientName); 命令创建以下文件;

  1. client1 的第一个录音 client1_2011-01-01-22-47-01.flv
  2. client1 的第二个录音 client1_2011-01-01-22-54-55.flv
  3. client2 的第一个录音 < strong>client2_2011-01-01-22-59-34.flv
  4. client1的第三次录音client1_2011-01-01-22-04-12.flv

我不想使用<代码>ns.publish(myClientName,“append”);。每个发布会话都需要有一个单独的文件。

我能想到的最好办法是在 application.onUnpublish() 上使用 File.creationTime 和 File.renameTo() 在发布结束时添加时间戳,但它不能容忍意外的服务器中断。

编辑:我不知道并且与文档相冲突,Flash Media Server 中的 Date 对象不是我们所了解和喜爱的对象。它没有属性。例如

var currentTime = new Date();
trace("CurrentTime: " +currentTime.time);

打印

当前时间:未定义

运行

for (var prop in currentTime)
    trace(prop);

不会打印任何内容。

大约一个小时后,我得知这一点后感到惊讶和沮丧。希望它能帮助某人。

Is there some way to dynamically name files published in Flash Media server.

Several clients in an application will be publishing to FMS. They may start and stop recording several times, and I would like to append a time stamp (format: yy-mm-dd-hh-mm-ss) to the file name in main.asc.

For example the following files might be created by clients 1 and 2 using the ns.publish(myclientName); command;

  1. client1's first recording client1_2011-01-01-22-47-01.flv
  2. client1's second recording client1_2011-01-01-22-54-55.flv
  3. client2's first recording client2_2011-01-01-22-59-34.flv
  4. client1's third recording client1_2011-01-01-22-04-12.flv

I don't want to use ns.publish(myClientName, "append");. There needs to be a separate file for each publish session.

The best I can come up with is to use File.creationTime and File.renameTo() on application.onUnpublish() to add the timestamp when publishing has ended, but it it wouldn't be tolerant of an unexpected server outage.

Edit: Unknown to me and in conflict with the documentation, the Date object in Flash Media Server is not the one we know and love. It has no properties. For example

var currentTime = new Date();
trace("CurrentTime: " +currentTime.time);

prints

CurrentTime: undefined

Running

for (var prop in currentTime)
    trace(prop);

prints nothing.

I was surprised and frustrated after an hour or so to learn this. Hope it helps someone.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所谓啦 2024-10-16 16:06:20

currentTime.valueOf() 是时间跨度

currentTime.valueOf() is timespan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文