YouTube API v3 上传速度 [英] YouTube API v3 upload speeds

查看:39
本文介绍了YouTube API v3 上传速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 YouTube API v3 进行一些测试,使用 提供了可续传的上传脚本.

I have been performing some testing with the YouTube API v3, uploading video files existing on my Apache server (VPS running CENTOS 6.7 x86_64 on Virtuozzo, 2GB RAM and a ton of CPU) using the provided resumable upload script.

尝试了所有的东西,我能达到的最大上传速度不超过120KB/s.

Having tried all manor of things, the maximum upload speed I've been able to achieve is not more than 120KB/s.

我一直在玩输出缓冲区,关闭 GZipping,不同的块大小(从 1 到 30MB),并检查服务器带宽速度(在上传方向上始终超过 250 Mb/s).

I've been playing around with output buffers, turning off GZipping, varying chunk sizes (from 1 to 30MB), and checked the server bandwidth speed (consistently over 250 Mb/s in the upload direction).

我很难相信,考虑到您可以通过浏览器上传的速度有多快(我现在无法测试这个理论,因为我的互联网连接速度非常慢 - 但这是基于过去的经验)这是一个YouTube 的限制,除非是故意限制.我无法通过 YouTube 文档或互联网上的任何地方的 API 找到任何有关预期速度的文档.

I struggle to believe, given how fast you can upload through the browser (I can't test this theory right now as I'm on a very slow internet connection - but this is based on past experience) that this is a limitation of YouTube, unless it's intentional throttling. I cannot find any documentation of expected speeds via the API on the YouTube docs or anywhere on the internet.

有没有其他人遇到过上传缓慢的情况,有什么可以做的吗?提前致谢.

Has anyone else encountered slow uploads and is there anything that can be done? Thanks in advance.

推荐答案

在进行了更多测试后,我得出结论,速度缓慢的原因不是因为 YouTube 端的节流,而是更多是在 PHP 本身的核心基础架构内造成的.但是,我确实通过更改 Google 的示例方法,使用 stream_get_contents 而不是 fread(感谢这篇文章.

Having done a bit more testing, I have concluded the slow speeds are caused not because of throttling at at YouTube's end but more within the core infrastructure of PHP itself. However, I did managed to increase the speed using PHP from ~120KB/s to ~770KB/s by changing Google's example approach, using stream_get_contents instead of fread (credit to this post).

但是,如果您仍然需要更多,我建议您使用 Python 方法.通过 API,我在 83 秒内上传了一个 2GB 的文件,大约为 24MB/s.如果有人知道的话,了解速度差异巨大背后的基本编程原因会很有趣,尽管我想赶紧补充一下.

However, if you still need more, I'd suggest going the Python approach. Through the API I uploaded a 2GB file in 83 seconds, which comes out at ~24MB/s. It'd be interesting to know the fundamental programming reasons behind the drastic differences in speeds if anybody knows, though well out of my realm I'd hasten to add.

这篇关于YouTube API v3 上传速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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