For the past couple weeks my co workers and me have been working on trying to get captions on our clients YouTube video's through the v3 API. After about week we were finally able to get the captions to upload just fine but, YouTube would give us this message in the UI "Track content is not processed" and doesn't display the caption's that we upload. However, we can download the original format that was upload; so we know the file was uploaded successfully.
We also were able to get the sync flag to work that tells YouTube to run through the transcript and set timings for the video but, it doesn't actually work. It returns telling us that it is syncing but when we go to the UI for the video it just shows the caption track name and give's us the message "Track content is not processed.". We've used up all the hours that we had and we're now working on our own time to solve this problem but still no luck.
Has anyone ran into this problem before? If so, what were you able to do to get this to work?
I will post a snippet of my code below that shows the upload portion of our script.
# Insert a video caption.
# Create a caption snippet with video id, language, name and draft status.
$captionSnippet = new Google_Service_YouTube_CaptionSnippet();
$captionSnippet->setVideoId($videoId);
$captionSnippet->setLanguage($captionLanguage);
$captionSnippet->setName($captionName);
$captionSnippet->setIsDraft( true );
# Create a caption with snippet.
$caption = new Google_Service_YouTube_Caption();
$caption->setSnippet($captionSnippet);
// Setting the defer flag to true tells the client to return a request which can be called
$client->setDefer(false);
// Get the file content's of the uploaded file
$file = file_get_contents( $captionFile['tmp_name'] );
// Create a request for the API's captions.insert method to create and upload a caption.
$insertRequest = $youtube->captions->insert("snippet", $caption, array(
'sync' => true,
'data' => $file,
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart' )
);
echo '<pre>'; print_r( $insertRequest ); echo '</pre>';
// // Read the caption file and upload it chunk by chunk.
$status = $insertRequest;
fclose($handle);
// If you want to make other calls after the file upload, set setDefer back to false
$client->setDefer(false);
Thank you,
Tyler Steinhaus
Have you tried to achieve what you want using the functions Google have posted themselves?
Below taken from https://developers.google.com/youtube/v3/code_samples/php
I was able to reproduce this problem, and found a possible fix. The key was the content of the uploaded caption file. The hint was where it says in the documentation:
The tweak that made it work for me was to add in some dummy time codes that I knew were incorrect, and set
'sync' => 'true',
so that the YouTube service would correct them. For example, here is the.sbv
file that did NOT work:When I used this file I got the same error you did, i.e.
Track content is not processed
, but when I changed it to this it worked:When I downloaded the processed
.sbv
file from YouTube it looked like this:Granted, I only tried this for a VERY trivial video, and I don't think they did a very good job with the timings, but hopefully it will scale up to work with your system.