放弃处理无法处理视频-Youtube API? [英] Processing abandoned The video could not be processed - Youtube API?

查看:63
本文介绍了放弃处理无法处理视频-Youtube API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用youtube数据v3 api通过我的网站上传mp4视频,并且http发布请求如下:

I am uploading mp4 videos through my website using youtube data v3 api and the http post request looks like:

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": "" } } }

但是在视频"标签上,我收到错误消息:放弃处理无法处理视频.视频响应成功消息的事实意味着成功之前的所有身份验证过程.但是,如果需要,我也可以编辑和共享该代码.

But on the videos tab, I get the error: Processing abandoned The video could not be processed. The fact that the video responds a success message means that all the authentication process before it has been successful. However, if required I can edit and share that code too.

推荐答案

将视频上传到YouTube的过程分为两个步骤:

Uploading a video to YouTube is a two-step process:

  1. 调用 Videos.insert API端点,并向其发布适当的 JSON文本描述您的视频.

在API调用上,从API端点响应中获取实际上传视频内容的位置.然后执行实际的内容上传操作.

Upon the API call, get the location where to actually upload the video content from the API endpoint response. Then do the actual content uploading operation.

请仔细检查Google制作的源代码在YouTube上上传视频可公开获得.您将学到我上面概述的算法的所有具体细节.

Do scrutinize the source code Google made publicly available w.r.t uploading videos on YouTube. You'll learn all the concrete details of the algorithm I sketched above.

如果您想深入了解函数 resumable_upload 中的调用 request.next_chunk()的工作方式,请阅读相关部分-方法 HttpRequest.next_chunk -在文件

If you'd like to go deeper into how the call request.next_chunk() in function resumable_upload works, then go read the relevant part -- the method HttpRequest.next_chunk -- in file http.py of Google's API Client Library for Python.

这篇关于放弃处理无法处理视频-Youtube API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆