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

标签 php youtube youtube-api youtube-data-api

我刚刚开始使用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/

相关文章:

api - 使用YOUTUBE google-api-php-client更新视频

php - 如何使用标签表和对象表查找 "This value is also used moSTLy with that value"?

html - 为什么嵌入视频不是通过 z-index?

php - 带两位小数的浮点值

iphone - youTube iFrame 嵌入代码是否适用于移动设备? (iPhone, 安卓)

javascript - Youtube 播放器 iFrame 的高度和宽度 = 窗口大小

java - youtube api 显示 channel 视频 android

java - Youtube API V3 - 如何使用 channel 图标字段搜索视频?

php - 退出 Smarty 手动完成

php - 选择并获取 mysql 上重复次数最多的事件