4144

Video file is stuck at 0% percent when being uploaded via YouTube API

Question:

As the title reads, a video file can be uploaded and processed via YouTube's upload function. However, when I try to upload it programmatically (via OAuth2 and YouTube API v3), it gets always stuck at 0% percent processing. Are there any youtubers on SO? Is there some special forum for upload issues? (PS, there is a <a href="https://stackoverflow.com/questions/15575100/status-of-video-uploaded-via-youtube-data-api-is-always-processing-python" rel="nofollow">similar question</a> with no results.)

<strong>UPDATED ERROR</strong>: Digging deeper, it seems to be related to the video metadata. I do get the following error occasionally:

<blockquote>

Failed to start the resumable upload (HTTP 400: youtube.video, The request metadata specifies an invalid video title.)

</blockquote>

Unfortunately, <a href="https://developers.google.com/youtube/v3/docs/errors" rel="nofollow">the error page for YouTube's API v3</a> does not really suffer from logorrhoea... Does anyone know what the error means?

<strong>UPDATED CODE:</strong> At the moment the files are uploaded chunk by chunk (which usually works pretty well but not all the times):

function uploadFile($dbfile) { $client = $this->client; $youtube = new Google_Service_YouTube($client); $htmlBody = ""; try { // Create a snippet with title, description, tags and category ID // Create an asset resource and set its snippet metadata and type. // This example sets the video's title, description, keyword tags, and // video category. $snippet = new Google_Service_YouTube_VideoSnippet(); $snippet->setTitle($dbfile->displayname); // Numeric video category. See // https://developers.google.com/youtube/v3/docs/videoCategories/list $snippet->setCategoryId("22"); // Set the video's status to "private" $status = new Google_Service_YouTube_VideoStatus(); $status->privacyStatus = "private"; // Associate the snippet and status objects with a new video resource. $video = new Google_Service_YouTube_Video(); $video->setSnippet($snippet); $video->setStatus($status); $chunkSizeBytes = 1 * 1024 * 1024; $client->setDefer(true); $insertRequest = $youtube->videos->insert("status,snippet", $video); // Create a MediaFileUpload object for resumable uploads. $media = new Google_Http_MediaFileUpload( $client, $insertRequest, 'video/*', null, true, $chunkSizeBytes ); $media->setFileSize(filesize($dbfile->localfile)); // Read the media file and upload it chunk by chunk. $status = false; $handle = fopen($dbfile->localfile, "rb"); while (!$status && !feof($handle)) { $chunk = fread($handle, $chunkSizeBytes); $status = $media->nextChunk($chunk); } fclose($handle); $client->setDefer(false); $log = array("success" => true, "snippet_id" => $status["id"]); } catch (Google_ServiceException $e) { $log = array("success" => false, "errormsg" => $e->getMessage()); } catch (Google_Exception $e) { $log = array("success" => false, "errormsg" => $e->getMessage()); } return $log; }

Answer1:

Well then, there might be other issues with videos not being processed but mine was that the title of the video to be inserted was simply too long. YouTube has a limitation of <strong>no more than 100 characters</strong>. If you try to insert longer video titles, it throws the above exception. Perhaps they should note this somewhere in their API documentation.

Recommend

  • How to add delay between animations
  • env: ruby_noexec_wrapper: No such file or directory error
  • K8s Ingress rule for multiple paths in same backend service
  • asp.net mvc4 won't properly deserialize and bind Dictionary from json
  • redirect the stdin to come from a different terminal using Bash
  • Haskell logbase error
  • Replace a line in a config file with ansible
  • What is the use and meaning of %2d in the C printf function?
  • Calling SaveAsync method sends email to attendees for existing appointment?
  • How to sort the union datastream of flink without watermark
  • WM_POWERBROADCAST not received by message-only window in Windows XP
  • Fitbit oauth2 public API stopped working. Giving error - Sorry Its not you.. Its us
  • C# Spell checker Problem
  • Simulating argparse command line arguments input while debugging
  • Adding items to an already existing jlist from another class
  • Should the client have the same keystore as the server?
  • Laravel Query Builder Update with Increment
  • Shopify Custom Payment Gateway Implementation
  • Expression.Call GroupBy then Select and Count()?
  • Bundling python(“.py”)files along with java class files for a web application
  • Issue with Terrain Collision using Three.js
  • Unable to start a WebView from an AsyncTask
  • playing mp3 from nsbundle
  • C# code can't “see” the methods in my C++ dll
  • How to change the host IP sent in emails to new GitLab users to a publicly visible IP, not the local
  • Set SelectedIndex of ListView in FlipView_SelectionChanged event
  • Request Access Token in Postman for Azure Function App protected by Azure AD B2C
  • All Event listing on specified date in Google Calender api (V3) in java?
  • Thumbnails for mxml components in Flex
  • How to run chrome.tabs.insertCSS from the background page on each page?
  • How to write seo friendly url's using htaccess?
  • Django, uWSGI & nginx: Process dies for “no reason”
  • using maven pom while creating jar:test-jar some times it says JAR will be empty - no content was ma
  • Drag and drop unicode TText in DelphiXe4
  • Terminal run dalvikvm with am.jar
  • VSTS work items list through REST API
  • How to handle div that is created dynamically in a table
  • Make checkout phone field optional for specific countries in WooCommerce
  • Using Service Component Runtime
  • ReferenceError: TextEncoder is not defined