我想使用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/