【问题标题】:No response on live transition request对实时转换请求没有响应
【发布时间】:2020-03-03 20:23:29
【问题描述】:

我在 Java 中使用 YouTube Live Streaming API。 我有一个问题,有时会发生。

我编写了一个类来检索现有的直播流并创建一个直播,确保该流正在发送数据,然后将它们绑定在一起,然后我发出 2 个转换请求。

首先我转换到测试(实时预览)请求,然后我转换到实时请求, https://developers.google.com/youtube/v3/live/life-of-a-broadcast 的手册第 4.1 节说 我应该轮询 API,直到广播生命周期状态变为 live

这是我写的: '''

 YouTube.LiveBroadcasts.Transition requestLive = CreateYouTube.getYoutube().liveBroadcasts()
                    .transition("live", returnedBroadcast.getId(), "snippet,status");
            returnedBroadcast = requestLive.execute();
            //poll while live starting (wait while starting live)
  while(returnedBroadcast.getStatus().getLifeCycleStatus().equals("liveStarting")) {
           returnedBroadcast = getBroadcastById(returnedBroadcast.getId());
           System.out.println("polling liveStarting "+args[0]);
           Thread.sleep(1000);
 }

''' 有时它工作顺利,但有时状态没有改变,这意味着广播没有转换到直播,我陷入了无限循环。 当然我可以手动跳出循环,但我仍然不明白为什么请求没有被处理,我可以修复它。

【问题讨论】:

    标签: java youtube-api youtube-data-api youtube-livestreaming-api


    【解决方案1】:

    为什么要查找状态 liveStarting 而不是 live?超时可能会变得不走运并完全丢失状态。 liveStarting 是一个过渡状态。

    https://developers.google.com/youtube/v3/live/docs/liveBroadcasts#status.lifeCycleStatus

    我还建议查看 LiveBroadcast 资源上的 contentDetails.enableAutoStart 属性。

    您可以在附加LiveStream 之前将LiveBroadcast 更新为enableAutoStart: true。我发现这是一种更可靠的启动流的方式。

    https://developers.google.com/youtube/v3/live/docs/liveBroadcasts#contentDetails.enableAutoStart

    【讨论】:

    • 感谢您的提示,我发现了问题,您可以阅读我上面的答案
    【解决方案2】:

    我发现了导致直播有时无法开始的问题。 问题是编码软件的输出分辨率 与创建流时设置为直播“cdn”设置的分辨率不匹配。

    YouTube Live API 没有设法抛出异常或通知我的程序,只是在我上面发布的代码中进入了无限循环, 我在使用 Live Control Room 的新测试版时发现了这个问题,它通知我编码器输出分辨率与流分辨率不匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-30
      • 2015-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多