Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using the following code to upload large files onto Youtube, but it chunks the large files into different parts, and rather than sending them separately and upload them at once it uploads them separately.

So at the end I have a long list of unloadable different parts of the file on youtube rather than a single file.

if you cant help with following code Do you know of any other sample code or alternative method?

if ($client->getAccessToken()) {
  $videoPath = "path/to/foo.mp4";
  $snippet = new Google_VideoSnippet();
  $snippet->setTitle("Test title2");
  $snippet->setDescription("Test descrition");
  $snippet->setTags(array("tag1", "tag2"));
  $snippet->setCategoryId("22");

  $status = new Google_VideoStatus();
  $status->privacyStatus = "private";

  $video = new Google_Video();
  $video->setSnippet($snippet);
  $video->setStatus($status);

  $chunkSizeBytes = 1 * 1024 * 1024;
  $media = new Google_MediaFileUpload('video/mp4', null, true, $chunkSizeBytes);
  $media->setFileSize(filesize($videoPath));

  $result = $youtube->videos->insert("status,snippet", $video,
      array('mediaUpload' => $media));

  $status = false;
  $handle = fopen($videoPath, "rb");
  while (!$status && !feof($handle)) {
    $chunk = fread($handle, $chunkSizeBytes);
    $uploadStatus = $media->nextChunk($result, $chunk);
  }

  fclose($handle);
}

I found this question which its answer code is similar to google_mediaFileupload but I am not sure how to use it.

share|improve this question
1  
do you have permissions to upload large videos? – Wh1T3h4Ck5 11 hours ago
I just turned on the youtube api did not make any request should I ? if yes how to do that? although I suppose I should change the code in a way to send different parts and then upload all the parts as a whole. – Jack Ramzi 11 hours ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.