Http 如何为YouTube Livestreams添加字幕?
YouTube提供了在直播流中发送字幕的可能性。然而,本指南引用了一个来自Youtube Studio Classic的链接,该链接已不存在。在新的现场控制室,我只能找到一个字幕链接,看起来像Http 如何为YouTube Livestreams添加字幕?,http,post,youtube,live-streaming,youtube-livestreaming-api,Http,Post,Youtube,Live Streaming,Youtube Livestreaming Api,YouTube提供了在直播流中发送字幕的可能性。然而,本指南引用了一个来自Youtube Studio Classic的链接,该链接已不存在。在新的现场控制室,我只能找到一个字幕链接,看起来像 http://upload.youtube.com/closedcaption?cid=.... 并且不包含ns或sparams等参数 如何为现场控制室提供字幕?在其他页面上也有一些误导性的信息——我可以只使用一个简单的HTTP帖子,还是需要购买一个 如果不能使用POST,我可以使用Livestream
http://upload.youtube.com/closedcaption?cid=....
并且不包含ns或sparams等参数
如何为现场控制室提供字幕?在其他页面上也有一些误导性的信息——我可以只使用一个简单的HTTP帖子,还是需要购买一个
如果不能使用POST,我可以使用Livestreaming API吗?我可以使用下面的python代码
import time
import requests
from datetime import datetime
word = "this is caption " + str(seq)
ytlink = "http://upload.youtube.com/closedcaption?cid=xxx-xxx-xxx-xxx="+str(seq)
post_fields = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + ' \n' + word + '\n'
headers = {'content-type': 'text/plain'}
r = requests.post(url=ytlink, data=post_fields.encode('utf-8'),
headers=headers)
print(ytlink)
print(r.text)
基本上,不再需要其他人了 它也适用于c。抱歉,我认为这不是正确的代码示例,我第一次尝试回答任何问题
string CAPTION_TEXT = "This text is displayed as caption.<br>"; // note, br used for linebreak in caption
string STREAM_ID = "aaaa-bbbb-cccc-dddd-eeee";
int sequence = 1;
string url = "http://upload.youtube.com/closedcaption?cid="+STREAM_ID+"&seq="+sequence; // increment sequence every time you send
string message = dateTime.ToString("yyyy-MM-dd") + "T" +
dateTime.ToString("HH") + ":" +
dateTime.ToString("mm") + ":" +
dateTime.ToString("ss.fff")+
" region:reg1#cue1\n"+
CAPTION_TEXT+"\n"
var content = new StringContent(message);
var client = new HttpClient();
var response = await client.PostAsync(url, content);
int statusCode = (int)response.StatusCode;
if(statusCode == "200") SUCCESS();