gpt4 book ai didi

php - 5至10个 block (服务器到服务器)后,YouTube API视频上传停止

转载 作者:行者123 更新时间:2023-12-03 05:36:38 25 4
gpt4 key购买 nike

我刚刚开始使用YouTube数据API并在块大小方面苦苦挣扎。

这是在文档的PHP代码示例中如何设置块大小的方法:

// Specify the size of each chunk of data, in bytes. Set a higher value for
// reliable connection as fewer chunks lead to faster uploads. Set a lower
// value for better recovery on less reliable connections.
$chunkSizeBytes = 1 * 1024 * 1024;

经过更多测试后,我发现YouTube仅接受 的前5-10个块,然后上传停止(有时2分钟后会继续,但再上传几块,然后永远停止)。

然后,我将块大小增加到10MB(10 * 1024 * 1024),但仍然遇到相同的问题。大于50-100MB的文件会在几个块之后中止。

现在,我已将块大小设置为100MB(100 * 1024 * 1024),到目前为止,它可以正常工作,但是我尚未对1GB +的文件进行过测试。

为什么会发生这种情况,我该如何解决?

我无法想象如果要上传20GB的视频,发送5GB的块是最佳做法,是吗?

最佳答案

尝试使用Resumable Uploads。与简单的上传相比,可恢复的上传是为较大的文件设计的。

Using resumable uploads is especially useful in any of the following cases:

  • You are transferring large files.
  • The likelihood of a network interruption is high.
  • Uploads are originating from a device with a low-bandwidth or unstable Internet connection, such as a mobile device.

To start a resumable video upload, send a POST request to the following URL. In the URL, set the part parameter value to the appropriate value for your request. Remember that the parameter value identifies the parts the contain properties that you are setting, and it also identifies the parts that you want the API response to include. Parameter values in the request URL must be URL-encoded.


https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=PARTS

关于php - 5至10个 block (服务器到服务器)后,YouTube API视频上传停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40849838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com