放弃处理 无法处理视频 - Youtube API?
Processing abandoned The video could not be processed - Youtube API?
我正在使用 youtube 数据 v3 api 通过我的网站上传 mp4 视频,http post 请求如下所示:
access_token = request.session['access_token']
url = "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet"
payload = {
'snippet':{
"categoryId": "22",
"description": "Description of uploaded video.",
"title": "Test video upload."
}
}
files = [
('media_body', request.FILES['media_body'])
]
headers = {
'Content-Type': 'video/mp4',
'Authorization': 'Bearer '+access_token,
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text.encode('utf8'))
context = {
'r': response
}
return render_to_response('dashboard/manage_content/youtube.html', context)
这是我得到的回复:
{ "kind": "youtube#video", "etag": "yS7DhsHOhsDM-vXZiGUmLXcKST0", "id": "dII224dYC2o", "snippet": { "publishedAt": "2020-07-03T12:11:43Z", "channelId": "UCmv2Sec30iBc13b7ntf93Ow", "title": "unknown", "description": "", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/dII224dYC2o/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/dII224dYC2o/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/dII224dYC2o/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "Nikhil Dhoot", "categoryId": "20", "liveBroadcastContent": "none", "localized": { "title": "unknown", "description": "" } } }
但是在视频选项卡上,我收到错误消息:放弃处理无法处理视频。
视频响应成功消息的事实意味着它之前的所有认证过程已经成功。但是,如果需要,我也可以编辑和共享该代码。
将视频上传到 YouTube 分为两步:
调用 Videos.insert
API endpoint, posting to that a proper JSON text describing 您的视频。
在 API 调用后,从 API 端点响应中获取实际上传视频内容的位置。然后进行实际的内容上传操作。
一定要仔细检查 source code Google 在 YouTube 上公开的 w.r.t 上传视频。您将了解我上面概述的算法的所有具体细节。
如果您想更深入地了解函数 resumable_upload
中的调用 request.next_chunk()
是如何工作的,请阅读文件中的相关部分——方法 HttpRequest.next_chunk
Google 的 API 客户端库的 http.py
Python。
我正在使用 youtube 数据 v3 api 通过我的网站上传 mp4 视频,http post 请求如下所示:
access_token = request.session['access_token']
url = "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet"
payload = {
'snippet':{
"categoryId": "22",
"description": "Description of uploaded video.",
"title": "Test video upload."
}
}
files = [
('media_body', request.FILES['media_body'])
]
headers = {
'Content-Type': 'video/mp4',
'Authorization': 'Bearer '+access_token,
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text.encode('utf8'))
context = {
'r': response
}
return render_to_response('dashboard/manage_content/youtube.html', context)
这是我得到的回复:
{ "kind": "youtube#video", "etag": "yS7DhsHOhsDM-vXZiGUmLXcKST0", "id": "dII224dYC2o", "snippet": { "publishedAt": "2020-07-03T12:11:43Z", "channelId": "UCmv2Sec30iBc13b7ntf93Ow", "title": "unknown", "description": "", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/dII224dYC2o/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/dII224dYC2o/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/dII224dYC2o/hqdefault.jpg", "width": 480, "height": 360 } }, "channelTitle": "Nikhil Dhoot", "categoryId": "20", "liveBroadcastContent": "none", "localized": { "title": "unknown", "description": "" } } }
但是在视频选项卡上,我收到错误消息:放弃处理无法处理视频。 视频响应成功消息的事实意味着它之前的所有认证过程已经成功。但是,如果需要,我也可以编辑和共享该代码。
将视频上传到 YouTube 分为两步:
调用
Videos.insert
API endpoint, posting to that a proper JSON text describing 您的视频。在 API 调用后,从 API 端点响应中获取实际上传视频内容的位置。然后进行实际的内容上传操作。
一定要仔细检查 source code Google 在 YouTube 上公开的 w.r.t 上传视频。您将了解我上面概述的算法的所有具体细节。
如果您想更深入地了解函数 resumable_upload
中的调用 request.next_chunk()
是如何工作的,请阅读文件中的相关部分——方法 HttpRequest.next_chunk
Google 的 API 客户端库的 http.py
Python。