I use PHP to send videos via direct upload to Youtube. It works great for smaller videos, but when I try to send 390 MB of video, I get the following error:
PHP Fatal error: Out of memory (3932160 allocated) (tried to allocate 390201902 bytes)
I tried to increase memory_limit, but it does not help.
if ($isFile) {
ini_set('memory_limit', '2G')
$data = file_get_contents($data);
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$out = curl_exec($ch);
curl_close($ch);
return $out;
I also tried running curl through exec(), but then even weirder things happen:
http://uploads.gdata.youtube.com/feeds/api/users/default/uploads-H 'POST/feeds/api/users/default/uploads HTTP/1.1 '-H' Host: uploads.gdata.youtube.com '-H ': OAuth [snip oauth info] "'-H' GData-Version: 2 '-H" X-GData-Client: www.mywebsite.com "-H 'X-GData-Key: key = [snip]' -H 'Slug: video.AVI' -H 'Content-Type: /; border =" iUI5C0hzisAHkx9SvaRJ" '-H 'Content-Length: 390193710' -H ': close' -d /tmp/youtube.xml
/tmp/youtube.xml - , . , ?
6 , , , :
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
...
0 0 0 0 0 0 0 0 --:--:-- 0:06:00 --:--:-- 0
curl: (52) Empty reply from server
EDIT:
OAuth, API PHP . XML , XML ,
I , . Youtube 411, "Content-Length". , . fsockopen() cURL. [ , , , "\n" "\ r\n". . ]
2:
, "\ r\n" , , Youtube.
Curl, ? .