youtube / yt-watchme

340 stars 134 forks source link

Stream is always inactive #25

Open enginebai opened 9 years ago

enginebai commented 9 years ago

After creating a broadcast and start the streaming, I always get ths error caused by calling YouTubeApi.startEvent().

Transition transitionRequest = youtube.liveBroadcasts().transition(
                "live", broadcastId, "status");
transitionRequest.execute();
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
    {
    "code": 403,
    "errors": [
    {
    "domain": "youtube.liveBroadcast",
    "message": "Stream is inactive",
    "reason": "errorStreamInactive",
    "extendedHelp": "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition"
    }
    ],
    "message": "Stream is inactive"
    }
            at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
            at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
            at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
            at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
            at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
            at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
            at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
            at com.google.android.apps.watchme.util.YouTubeApi.startEvent(YouTubeApi.java:187)
            at com.google.android.apps.watchme.MainActivity$StartEventTask.doInBackground(MainActivity.java:389)
            at com.google.android.apps.watchme.MainActivity$StartEventTask.doInBackground(MainActivity.java:374)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

How can I fix this problem??

JohnLeekk commented 9 years ago

@iulukaya hi. I'm having trouble with the problem [forbidden 403, stream is inactive]. Everytime I try to start streaming, this error comes up and cannot stream any longer. I wish you could help me with the problem

enginebai commented 9 years ago

Recently, the broadcast received the streaming normally, and I call the code

Transition transitionRequest = youtube.liveBroadcasts().transition(
                "live", broadcastId, "status");
transitionRequest.execute();

and I always get this error response:

{
  "code": 403,
  "errors": [
    {
      "domain": "youtube.liveBroadcast",
      "message": "Invalid transition",
      "reason": "invalidTransition",
      "extendedHelp": "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition#params"
    }
  ],
  "message": "Invalid transition"
}

Is something wrong??

JohnLeekk commented 9 years ago

@enginebai Oh! How did you solved out the problem [stream is inactive]? I'm still having problem... please tell me how you did it!!

enginebai commented 9 years ago

@JohnLeekk Have you uploaded your stream to youtube successfully?? I solved this problem after uploading the stream successfully.

But I encountered another problem when trying to start the broadcast, the transition API response always returns Invalid transition status, my streaming status is good, I don't know what the problem is.

JohnLeekk commented 9 years ago

@enginebai Yes. I uploaded stream successfully. I can not find any Exceptions during creating Broadcast. However when I try to change status to "Live", [stream is inactive] error occurs. Also I have same problem [Invalid transition] when I change status to "complete". I could not figure out what is wrong......

enginebai commented 9 years ago

1111

@JohnLeekk Have you seen this screen? Is your streaming status good? If not, you should fix the problem first.

JohnLeekk commented 9 years ago

@enginebai Yeah! I've checked the stream status and it's good. So your app normally streams video from smartphone? A week ago changing API key on Developer Console made me stream well. try it!

app24hk commented 8 years ago

{ "code": 403, "errors": [ { "domain": "youtube.liveBroadcast", "message": "Stream is inactive", "reason": "errorStreamInactive", "extendedHelp": "https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition" } ], "message": "Stream is inactive" }

getting error, how to resolve this??

enginebai commented 8 years ago

@app24hk You can go to the youtube creator console and check the streaming status. Make sure that status is good so that you can call transition api successfully.

abram456 commented 8 years ago

@enginebai, I'm not able to find streaming status option in creator studio. Can you help me out in detail?

mcxycross commented 7 years ago

Here's my solution. If you guys are using Youtube WatchMe sample, in YoutubeAPI > startEvent method, set the Thread.sleep() a little bit longer. The default value is 10000 in ms, I set mine to 20000.

...
public static void startEvent(YouTube youtube, String broadcastID) throws IOException{
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            Log.e(MainActivity.APP_NAME, "", e);
        }
        YouTube.LiveBroadcasts.Transition transitionRequest = youtube.liveBroadcasts()
                .transition("live", broadcastID, "status");
        transitionRequest.execute();
}
...

Well, I guess the idea is to wait until StreamingActivity loaded and Ffmpeg starts tramitting data to YouTube so that the stream status changed to 'good' or 'ok' as long as not 'no data', and then we can do the transition request. Hope it helps :)

enginebai commented 7 years ago

Yeap, @mcxycross provides a work-around solution. It works at all, I think that the problem is thread issue.

nphausg commented 4 years ago

To live stream on mobile, your channel will need to have at least 1,000 subscribers. Note that this eligibility threshold does not apply to other live streaming tools. Creators who have less than 1,000 subscribers can still live stream through a computer and webcam. https://support.google.com/youtube/answer/2853834?hl=en

imran855 commented 2 years ago

Problem: "message": "Stream is inactive" means, you call the below code before connecting the RTMP server.

Transition transitionRequest = youtube.liveBroadcasts().transition("live", broadcastId, "status"); transitionRequest.execute();

Solution: You have to call the above code after connecting the stream server. Another way you can do it is by enabling autostart when creating a broadcast event. When you enable auto-start, you do not need to call the above code. Here is the sample code for enabling auto-start.

LiveBroadcastContentDetails contentDetails = new LiveBroadcastContentDetails(); contentDetails.set("enableAutoStart", true);