i have an AJA HELO media streaming device and from time to time it stops streaming. What i want to do it automate some kind of streaming reset. I am able to issue command to the AJA to stop and start streaming, but i need help figuring out how to "End Stream" on my current Youtube Live stream. Just doing so on the AJA does nothing since Youtube still thinks the stream will be back shortly.
Does anyone know of a way to achieve this?
P.S. i am able to retrieve the exact stream identifier via a Python script, as i am monitoring the state in an NMS.
Thanks
I'm not sure if this is directly related, but to end a livestream using the Python google-api-python-client library:
youtube = build("youtube", "v3", credentials = [YOUR CREDENTIALS])
request = youtube.liveBroadcasts().transition(
part = 'snippet',
id = [VIDEO ID OF THE LIVESTREAM],
broadcastStatus = 'complete'
#Setting the 'broadcastStatus' to 'complete' ends the stream
)
response = request.execute()
You can find more details about this in the docs here (including POST): https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition
Related
I want to play twilio media stream in browser in real time. For this I am using websocket to send twilio stream from node.js server to browser. I am converting the twilio media stream by using wavefile npm with the following code :-
// Server Side Code
const wav = new WaveFile();
wav.fromScratch(1, 8000, '8m', Buffer.from(item.audioPayload, "base64"));
wav.fromMuLaw();
wav.toSampleRate(44100);
let dataURI = wav.toDataURI();
item.audioPayload = dataURI;
this.sendAgentMessage(item, this.connection);
And at the browser side I am playing audio using this :-
// Client side code
var snd = new Audio(message.audioPayload);
snd.play();
Now while playing the audio I am getting very much noise and distortion.
Please help me with this.
How can I bind my YouTube stream key to match previous video.
I'm trying to use java to do it but getting no where.
I'm looking at the example given to create the broadcast stream but it doesn't have the keeping same key.
I've gotten help on this before. Please try do some research on Google and then ask the question. You can see How can I change the stream my event uses via the YouTube live api?. Which will help you as it did me.
In short this was the code i received for help.
Credit to #M. Prokhorov
YouTube yt = ... // your reference to YouTube
String broadcastId = ... // your broadcast Id
String newStreamId = ... // identifier of stream you want to bind
String apiKEy = ... // your API key
// you can define other response parts if you want more or don't want some of these
String responseParts = "id,status,contentDetails.boundStreamId";
yt.liveBroadcasts().bind(broadcastId, responseParts)
.setApiKey(apiKey)
.setStreamId(streamId)
// other data you might want in request
.execute()
I have a scenario where say at 5.00 AM every morning, I have a server side script / batch job that wakes up, selects a phone number from a list based on an algorithm, places a call to that phone number and uses text-to-speech to deliver a customized message. I have 2 questions,
Which Twilio API can I use to achieve this? Bear in mind there is no app UI and all the code would be on the back end. Think NodeRED flow or a Python script that is made to run at a given time.
Instead of specifying the text in the TwiML, can I pass say an audio stream from Watson's Text to Speech to the appropriate Twilio API?
To do this, you would need to use the programmable voice API from Twilio. This lets you play audio files, text to speech, make and manipulate phone calls, etc. I have never used Watson Text-to-Speech, but, if it can output an audio file you can play that with Twilio TwiML.
Here's an example in Node.
npm install twilio
//require the Twilio module and create a REST client
var client = require('twilio')('ACCOUNT_SID', 'AUTH_TOKEN');
client.makeCall({
to:'+16515556677', // Any number Twilio can call
from: '+14506667788', // A number you bought from Twilio
url: 'url/to/twiml/which/may/have/WatsonURL' // A URL that produces TwiML
}, function(err, responseData) {
//executed when the call has been initiated.
console.log(responseData.from); // outputs "+14506667788"
});
The TwiML could look like this:
<Response>
<Play loop="1">https://api.twilio.com/cowbell.mp3</Play>
</Response>
This would play the cowbell sound from the Twilio API. Just a default sound. This could be easily generated to play a Watson sound file if you can get a URL for that.
You could do the same thing in Node, if you'd rather not build the XML manually.
var resp = new twilio.TwimlResponse();
resp.say('Welcome to Twilio!')
.pause({ length:3 })
.say('Please let us know if we can help during your development.', {
voice:'woman',
language:'en-us'
})
.play('http://www.example.com/some_sound.mp3');
If you were to take this toString() it would output formatted XML (TwiML):
console.log(resp.toString());
This outputs:
<Response>
<Say>Welcome to Twilio!</Say>
<Pause length="3"></Pause>
<Say voice="woman" language="en-us">Please let us know if we can help during your development.</Say>
<Play>http://www.example.com/some_sound.mp3</Play>
</Response>
Hopefully this clears it up for you.
Scott
Right now I'm trying to figure out what i'm doing wrong when making transition of my YT broadcast to live.
So I make the request and get the following 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"
}
Of course i've read docs many times so I've monitored the LiveStream and was waiting for its "active" state (and my Broadcast has lifeCycleStatus="ready").
Error message doesn't explain real reason why cannot I do the transition.
And... of course I do not have access to logs of Youtube servers :)
What can you suggest?
How to find out where am I wrong?
So even if i've missed something, docs and error message do not help me to understand anything. So anyway it is kind of a "bug" for YT LiveStreaming API...
So a bit unclear rule is:
ensure you have broadcast and livestream created and ready.
and ensure that broadcast lifecycle status is not COMPLETE,
otherwise recreate broadcast
... so ensure that your broadcast lifecycle status is ready
bind broadcast to livestream
start publishing video to livestream
wait for livestream status active
transition to testing (yes, you have to do it instead of moving to live)
wait for broadcast lifeCycleStatus to become testing
transition to live
wait for broadcast lifeCycleStatus to become live
You cannot skip testing and cannot transition from complete to testing or ready.
You can leave 4-7 steps if:
the broadcast's monitor stream was disabled by setting the contentDetails.monitorStream.enableMonitorStream property to false when creating or updating that broadcast.
I meet the same question, finally I found the problem. After post command transiton to testing, the lifeCycleStatus is: liveStarting, we need to wait lifeCycleStatus to become testing. So we should get broadcast status.
here is my code:
liveStreamRequest = youtube.liveStreams()
.list("id,status")
.setId(liveBroadcast.getContentDetails()
.getBoundStreamId());
LiveStreamListResponse returnedList = liveStreamRequest.execute();
List<LiveStream> liveStreams = returnedList.getItems();
if (liveStreams != null && liveStreams.size() > 0) {
LiveStream liveStream = liveStreams.get(0);
if (liveStream != null)
while (!liveStream.getStatus().getStreamStatus()
.equals("active")) {
Thread.sleep(1000);
returnedList = liveStreamRequest.execute();
liveStreams = returnedList.getItems();
liveStream = liveStreams.get(0);
}
}
hope to help someone care about this problem!
I'm developing a YouTube client using the C# API library. On one account when I try to subscribe to a channel I get a TooManyEntries exception even though I only have 40 subscriptions. Anyone know why?
var subscription = new Subscription();
subscription.Type = SubscriptionEntry.SubscriptionType.channel;
subscription.UserName = youTubeId;
var response = _request.Insert(new Uri(YouTubeQuery.CreateSubscriptionUri(null)), subscription);
My guess would be that you're trying to subscribe twice to the same channel. Is that it?