php - 尝试分配内存不足-API YouTube php(上传视频)

标签 php youtube youtube-api

我想使用api-youtube最新版本将视频上传到youtube
当我上传小于300M的视频时,脚本运行良好
但是当我要ypload大于300M的视频时出现此错误:

Fatal error: Out of memory (allocated 1217134592) (tried to allocate 1619703661 bytes) in ...\google-api-php-upload\src\service\Google_MediaFileUpload.php on line ..


ini_set('memory_limit', '65048M');
$path_to_video_to_upload = 'video.mp4';///////////////

    // Get the Mimetype of your video
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime_type = finfo_file($finfo, $path_to_video_to_upload);

    // Build the Needed Video Information
    $snippet = new Google_VideoSnippet();
    $snippet->setTitle($title);/////////
     $snippet->setDescription($title);/////////
    $snippet->setTags($tag);/////////
    $snippet->setCategoryId(22);/////////

    // Build the Needed video Status
    $status = new Google_VideoStatus();
    $status->setPrivacyStatus('public'); // or public, unlisted

    // Set the Video Info and Status in the Main Tag
    $video = new Google_Video();
    $video->setSnippet($snippet);
    $video->setStatus($status);
    echo "ook";
    // Send the video to the Google Youtube API
    $x = $youtube->videos->insert('snippet,status', $video, array('data' => file_get_contents($path_to_video_to_upload),'mimeType' => $mime_type));

最佳答案

如果可以访问php.ini,则更改内存限制变量。

如果还没有,请让您的托管服务提供商为您更改它。

也许您的提供商(共享主机)已禁用

ini_set('memory_limit', '65048M');

用于阻止您和其他人分配服务器上的ram的函数。

关于php - 尝试分配内存不足-API YouTube php(上传视频),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31224579/

相关文章:

python - 从YouTube channel 逐页获取所有视频

youtube - 是否可以从youtube-dl获得口语?

iframe - 视频上方和下方的YouTube iframe播放器空白

jquery - 播放 YouTube 视频时停止 jQuery 内容 slider

php - 使用 Codeigniter 日期助手获取时区位置

php - 如果返回 0 行,则 MySQL 返回结果

jquery - 在Bootstrap模式下停止一些YouTube视频的灵活方法

html - Youtube视频全屏制作页面全屏

java - 将 java 纪元字符串与 php 纪元日期进行比较

php - 如何使用 JSONP 下载客户端 javascript 对象?