Red5 流 flv 文件

发布于 2024-07-18 10:54:41 字数 1486 浏览 10 评论 0原文

我正在检查 Red5 的 oflaDemo。 我想知道如何更改 oflaDemo 以便我可以将某个 flv 文件流式传输给所有订阅者...

/** {@inheritDoc} */
    @Override
    public boolean appConnect(IConnection conn, Object[] params) {
        // Trigger calling of "onBWDone", required for some FLV players
        measureBandwidth(conn);
        if (conn instanceof IStreamCapableConnection) {
            IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
            SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
            bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] =
                1024 * 1024;
            bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] =
                128 * 1024;
            streamConn.setBandwidthConfigure(bwConfig);
        }

            serverStream = StreamUtils.createServerStream(appScope, "live0");
            SimplePlayItem item = new SimplePlayItem();
            item.setStart(0);
            item.setLength(10000);
            item.setName("IronMan");
            serverStream.addItem(item);
            item = new SimplePlayItem();
            item.setStart(20000);
            item.setLength(10000);
            item.setName("DarkKnight");
            serverStream.addItem(item);
            serverStream.start();
            serverStream.setRepeat(true);

        return super.appConnect(conn, params);
    }

上面代码的结果对于所有订阅者来说只是一个空白屏幕...

你们有人知道吗?

提前致谢!

I was inspecting the oflaDemo from Red5.
I was wondering how I could change the oflaDemo so that I could stream a certain flv file to all the subscribers...

/** {@inheritDoc} */
    @Override
    public boolean appConnect(IConnection conn, Object[] params) {
        // Trigger calling of "onBWDone", required for some FLV players
        measureBandwidth(conn);
        if (conn instanceof IStreamCapableConnection) {
            IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
            SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
            bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] =
                1024 * 1024;
            bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] =
                128 * 1024;
            streamConn.setBandwidthConfigure(bwConfig);
        }

            serverStream = StreamUtils.createServerStream(appScope, "live0");
            SimplePlayItem item = new SimplePlayItem();
            item.setStart(0);
            item.setLength(10000);
            item.setName("IronMan");
            serverStream.addItem(item);
            item = new SimplePlayItem();
            item.setStart(20000);
            item.setLength(10000);
            item.setName("DarkKnight");
            serverStream.addItem(item);
            serverStream.start();
            serverStream.setRepeat(true);

        return super.appConnect(conn, params);
    }

The result of the code above is just a blank screen for all subscribers...

Does anyone of you have any idea?

thanks in advance!

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

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

发布评论

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

评论(2

柠栀 2024-07-25 10:54:41

这在客户端会更容易完成,如果您不想对流名称进行硬编码,则可以将其名称作为 flash 变量传递。

This would be easier to accomplish on the client side and if you didn't want to hard-code the stream name, you could pass its name as a flash var.

倥絔 2024-07-25 10:54:41

我遇到了同样的问题。 我发现黑屏是因为哪一行,

serverStream.setRepeat(true);

如果将重复设置为 false,则一切正常

UPD:
我认为这是 red5 的错误。 我做了一个 hack 来连续重复一个 flv。 我添加了自定义播放列表控制器:

public class MyPlayListController implements IPlaylistController {
    @Override
    public int nextItem(IPlaylist playlist, int itemIndex) {
        return 0;
    }

    @Override
    public int previousItem(IPlaylist playlist, int itemIndex) {
        return 0;
    }
}

I got the same problem. I found that blank screen is because of what line

serverStream.setRepeat(true);

if you set repeat to false all works fine

UPD:
I think that this is red5 bug. I made a hack to repeat continiously one flv. I added custom play list controller:

public class MyPlayListController implements IPlaylistController {
    @Override
    public int nextItem(IPlaylist playlist, int itemIndex) {
        return 0;
    }

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