skishore119 / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
0 stars 0 forks source link

youtube video upload problem #356

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. upload a media using the google api php client (Videos: insert)

What is the expected output? What do you see instead?
The video status is stuck on "processing"

What version of the product are you using? On what operating system?
google api php client 0.6.4 linux

Please provide any additional information below.
(Videos: list) output
Array
(
    [status] => Array
        (
            [uploadStatus] => uploaded
            [privacyStatus] => public
            [license] => youtube
            [embeddable] => 1
            [publicStatsViewable] => 1
        )
    [processingDetails] => Array
        (
            [processingStatus] => processing
            [fileDetailsAvailability] => inProgress
            [processingIssuesAvailability] => inProgress
            [tagSuggestionsAvailability] => inProgress
            [editorSuggestionsAvailability] => inProgress
            [thumbnailsAvailability] => inProgress
        )

)

Original issue reported on code.google.com by peb...@gmail.com on 29 Jul 2013 at 1:20

GoogleCodeExporter commented 8 years ago
You might want to try with the Youtube team to identify the type of the 
problem? http://stackoverflow.com/questions/ask?tags=youtube-api - if the issue 
is client specific, then feel free to raise that here. 

Original comment by ianbar...@google.com on 29 Jul 2013 at 1:50

GoogleCodeExporter commented 8 years ago
Hi,
Thank you for this answer.
But when I upload the same video through the video manager on youtube, 
everything goes well.
The problem is when i upload it via the php api client.
Don't you have any problem reported by other developers ?

Original comment by peb...@gmail.com on 29 Jul 2013 at 4:41

GoogleCodeExporter commented 8 years ago
Not on the PHP client, but maybe in other clients - that's why I suggested 
asking on stackoverflow first just in case.

Original comment by ianbar...@google.com on 29 Jul 2013 at 4:42

GoogleCodeExporter commented 8 years ago
Hi,
I've done some tests and i think the problem is client specific
http://stackoverflow.com/questions/17929673/youtube-video-processing-status-stuc
k-on-processing-after-an-upload-with-the-g

Original comment by peb...@gmail.com on 30 Jul 2013 at 7:49

GoogleCodeExporter commented 8 years ago
OK. Could you provide a minimal code sample that demonstrates the problem? 

Original comment by ianbar...@google.com on 30 Jul 2013 at 10:53

GoogleCodeExporter commented 8 years ago
This code is not fully functional, but it demonstrates the different steps :

<?php

require_once 'lib/ncw/infos/google-api-php-client/src/Google_Client.php';
require_once 
'lib/ncw/infos/google-api-php-client/src/contrib/Google_YouTubeService.php';

$client = new Google_Client();
$client->setApplicationName($application_name);
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setDeveloperKey($developer_key);
$client->setRedirectUri($redirect);

$youtube = new Google_YoutubeService($client);

$snippet = new Google_VideoSnippet();
$snippet->setTitle($title);
$snippet->setDescription($description);
$snippet->setTags($tags);
$snippet->setCategoryId("25");

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

$media = new Google_MediaFileUpload('video/mp4', null, true);
$media->setFileSize(filesize($path));

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

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

Original comment by peb...@gmail.com on 30 Jul 2013 at 4:56

GoogleCodeExporter commented 8 years ago
Still no news on this problem ?

Original comment by peb...@gmail.com on 19 Aug 2013 at 9:06

GoogleCodeExporter commented 8 years ago
** UPDATE **

The processingDetails has change lately, but the status is still stuck on 
"processing"

Array
(
    [status] => Array
        (
            [uploadStatus] => uploaded
            [privacyStatus] => public
            [license] => youtube
            [embeddable] => 1
            [publicStatsViewable] => 1
        )
    [fileDetails] => Array
        (
            [fileType] => video
            [container] => mov
        )
    [processingDetails] => Array
        (
            [processingStatus] => processing
            [fileDetailsAvailability] => available
            [processingIssuesAvailability] => available
            [tagSuggestionsAvailability] => inProgress
            [editorSuggestionsAvailability] => inProgress
            [thumbnailsAvailability] => inProgress
        )
    [suggestions] => Array
        (
            [processingHints] => Array
                (
                    [0] => nonStreamableMov
                )
        )
)

Original comment by peb...@gmail.com on 6 Sep 2013 at 11:50

GoogleCodeExporter commented 8 years ago
Hi

can we have an answer for this problem. We have rewritten many times our 
script. We have tried many different videos. We have tried different php 
versions. 

We really need help.

The upload is always ok (eg for id:L_kiiFa7gM8)

    [contentDetails] => Array
        (
            [duration] => PT0S
            [dimension] => 2d
            [definition] => sd
            [caption] => false
            [licensedContent] => 
        )

    [status] => Array
        (
            [uploadStatus] => uploaded
            [privacyStatus] => private
            [license] => youtube
            [embeddable] => 1
            [publicStatsViewable] => 1
        )

But in the processing details, we see that we are stuck at "inProgress"

    [processingDetails] => Array
        (
            [processingStatus] => processing
            [fileDetailsAvailability] => inProgress
            [processingIssuesAvailability] => inProgress
            [tagSuggestionsAvailability] => inProgress
            [editorSuggestionsAvailability] => inProgress
            [thumbnailsAvailability] => inProgress
        )

Could you help us ? Can we try anything ?

Original comment by fxb...@gmail.com on 2 Oct 2013 at 8:11

GoogleCodeExporter commented 8 years ago
Here is a new video id : CV1zx3CDVWE

Original comment by fxb...@gmail.com on 2 Oct 2013 at 9:47

GoogleCodeExporter commented 8 years ago
When you upload, does the upload fully complete? E.g. do you read to the full 
end of the file? I am wondering if something is causing an error, and the 
upload is not being retried. You could log out after each chunk, and make sure 
the total uploaded equals the total file size expected. 

You're uploading as mp4 as well - is that the correct file type for the video?

You're setting the filesize OK, so the code seems all right as far as I can 
see. 

Can you query the API for information about the API - does it otherwise return 
as you expected (proper metadata and so on, just hte video stuck on in 
progress)?

Original comment by ianbar...@google.com on 2 Oct 2013 at 5:30

GoogleCodeExporter commented 8 years ago
I've done even better. I've appended to a local file all the chunks that I sent 
with the API method :

      $chunk = fread($handle, $media->chunkSize);
      $uploadStatus = $media->nextChunk($result, $chunk);
      fwrite($out, $chunk);

When I open the output file ($out) ... everything is ok. So all the bytes are 
well sent to the youtube servers.

I do not really understand what you mean with your last sentence.

Here is a what I receive when I call listVideos with all the fields :

Array
(
    [kind] => youtube#video
    [etag] => "ype-3BkvaoSsqLvz1gN_E-uoDcs/M9vRY8hWn9CkHzQhBfNW9u1qx0s"
    [id] => m9w-tpQkheY
    [snippet] => Array
        (
            [publishedAt] => 2013-10-02T19:23:59.000Z
            [channelId] => UCeMBj3jTDAKLuFm0GUl3tsw
            [title] => la france
            [description] => La France, en forme longue la République française, est une république constitutionnelle unitaire ayant un régime parlementaire à tendance\
 présidentielle
            [thumbnails] => Array
                (
                    [default] => Array
                        (
                            [url] => https://i1.ytimg.com/s_vi/m9w-tpQkheY/default.jpg?sqp=CLjosZIF&rs=AOn4CLAnCA96pmi32kK1SlH5mIpYUD89Fg
                        )

                    [medium] => Array
                        (
                            [url] => https://i1.ytimg.com/s_vi/m9w-tpQkheY/mqdefault.jpg?sqp=CLjosZIF&rs=AOn4CLA9aTCZHdtQwelzf9W_xu0TsgdcJg
                        )

                    [high] => Array
                        (
                            [url] => https://i1.ytimg.com/s_vi/m9w-tpQkheY/hqdefault.jpg?sqp=CLjosZIF&rs=AOn4CLA63fn-Qn6G4qLniaU4pAH3i8R8mA
                        )

                )

            [channelTitle] => François-Xavier Bois
            [tags] => Array
                (
                    [0] => france
                )

            [categoryId] => 22
        )

    [contentDetails] => Array
        (
            [duration] => PT0S
            [dimension] => 2d
            [definition] => sd
            [caption] => false
            [licensedContent] =>
        )

    [status] => Array
        (
            [uploadStatus] => uploaded
            [privacyStatus] => private
            [license] => youtube
            [embeddable] => 1
            [publicStatsViewable] => 1
        )

    [statistics] => Array
        (
            [viewCount] => 0
            [likeCount] => 0
            [dislikeCount] => 0
            [favoriteCount] => 0
            [commentCount] => 0
        )

    [player] => Array
        (
            [embedHtml] => <iframe type='text/html' src='http://www.youtube.com/embed/m9w-tpQkheY' width='640' height='360' frameborder='0' allowfullscreen='true'/>
        )

    [processingDetails] => Array
        (
            [processingStatus] => processing
            [fileDetailsAvailability] => inProgress
            [processingIssuesAvailability] => inProgress
            [tagSuggestionsAvailability] => inProgress
            [editorSuggestionsAvailability] => inProgress
            [thumbnailsAvailability] => inProgress
        )

)

By the way, I just installed everything on a other server and used other oauth 
tokens to be sure.

I am now completely helpless and really need somes advices. 

(Do you see some details about the above file m9w-tpQkheY on your server ?)  

Original comment by fxb...@gmail.com on 2 Oct 2013 at 7:38

GoogleCodeExporter commented 8 years ago
We don't have access to any files, this is just the issue tracker for generic 
client issues unfortunately. 

You didn't confirm that the video was mp4 format. If you run 'file <video file 
name>" in the command line, what output does it give you?

Original comment by ianbar...@google.com on 3 Oct 2013 at 2:58

GoogleCodeExporter commented 8 years ago
Here is the output of ffmpeg -i

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2013-10-02 08:11:43
    model           : iPhone 5
    model-fra       : iPhone 5
    encoder         : 7.0.2
    encoder-fra     : 7.0.2
    date            : 2013-10-02T10:11:43+0200
    date-fra        : 2013-10-02T10:11:43+0200
    location        : +48.8364+002.3241+064.972/
    location-fra    : +48.8364+002.3241+064.972/
    make            : Apple
    make-fra        : Apple
  Duration: 00:00:02.74, start: 0.000023, bitrate: 13189 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 13134 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc
    Metadata:
      rotate          : 180
      creation_time   : 2013-10-02 08:11:43
      handler_name    : Core Media Data Handler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 62 kb/s
    Metadata:
      creation_time   : 2013-10-02 08:11:43
      handler_name    : Core Media Data Handler

Original comment by fxb...@gmail.com on 3 Oct 2013 at 3:03

GoogleCodeExporter commented 8 years ago
Can you try your upload again with the mimetype set to:

$media = new Google_MediaFileUpload('video/quicktime', null, true);

Original comment by ianbar...@google.com on 3 Oct 2013 at 3:05

GoogleCodeExporter commented 8 years ago
If ve just tried with
$media = new Google_MediaFileUpload('video/quicktime', null, true);

Original comment by fxb...@gmail.com on 3 Oct 2013 at 3:10

GoogleCodeExporter commented 8 years ago
the id of the video is : m9w-tpQkheY

Original comment by fxb...@gmail.com on 3 Oct 2013 at 3:12

GoogleCodeExporter commented 8 years ago
Any difference in the video status?

Original comment by ianbar...@google.com on 3 Oct 2013 at 3:25

GoogleCodeExporter commented 8 years ago
no difference

    [status] => Array
        (
            [uploadStatus] => uploaded
            [privacyStatus] => private
            [license] => youtube
            [embeddable] => 1
            [publicStatsViewable] => 1
        )

    [statistics] => Array
        (
            [viewCount] => 0
            [likeCount] => 0
            [dislikeCount] => 0
            [favoriteCount] => 0
            [commentCount] => 0
        )

    [player] => Array
        (
            [embedHtml] => <iframe type='text/html' src='http://www.youtube.com/embed/m9w-tpQkheY' width='640' height='360' frameborder='0' allowfullscreen='true'/>
        )

    [processingDetails] => Array
        (
            [processingStatus] => processing
            [fileDetailsAvailability] => inProgress
            [processingIssuesAvailability] => inProgress
            [tagSuggestionsAvailability] => inProgress
            [editorSuggestionsAvailability] => inProgress
            [thumbnailsAvailability] => inProgress
        )

Original comment by fxb...@gmail.com on 3 Oct 2013 at 3:42

GoogleCodeExporter commented 8 years ago
Sorry, I'm not sure what to suggest. There should be a new version of the 
library out in a few weeks, so it may be worth checking in then. It looks like 
the video is getting uploaded OK, so I'm not sure why it is not processing. 

Original comment by ianbar...@google.com on 3 Oct 2013 at 4:09

GoogleCodeExporter commented 8 years ago
Are you sure people using this library are able to send video ?
I haven't any post on the this.
Can't we go further and do more test ? Can't you you add debug info to the 
library so that I can send you more traces ?

Original comment by fxb...@gmail.com on 4 Oct 2013 at 7:23

GoogleCodeExporter commented 8 years ago
I just tried your script again the current (0.6.6) version of the PHP client 
library, and it properly uploaded an mp4 video, so it definitely works - the 
upload is processed and visible on youtube. What I would do:

* Make sure you're using the user you expect - e.g. that the token is for the 
correct user. 
* Try uploading the same video with the python upload.py script on here: 
https://developers.google.com/youtube/v3/guides/uploading_a_video
* If that works, and the PHP one does not, then try logging the request and 
response in nextChunk ~line 230 in Google_MediaFileUpload.php - see if anything 
unexpected is in there. 

Original comment by ianbar...@google.com on 4 Oct 2013 at 5:40

GoogleCodeExporter commented 8 years ago
I've tested the python library and ... it worked.
I looked at client_secrets.json and saw "urn:ietf:wg:oauth:2.0:oob". I googled 
it and detected that it was linked to "Client ID for installed applications". 
So I create such an ID (I add created "Client ID for web applications") and 
this time ... it worked.

So I think you should mention this in your documentation or throw an error when 
you detect such invalid type of client id.

Thank you for your precious help ... the python trick was a good advice

Original comment by fxb...@gmail.com on 6 Oct 2013 at 7:29

GoogleCodeExporter commented 8 years ago
That's great, really glad to hear it. What type of client ID was the previous 
one you were using, out of interest?

Original comment by ianbar...@google.com on 6 Oct 2013 at 1:43

GoogleCodeExporter commented 8 years ago
I used "Client ID for web applications"

Original comment by fxb...@gmail.com on 6 Oct 2013 at 1:56

GoogleCodeExporter commented 8 years ago
Argh ... my problems are not resolved.

My success was on a personal computer (C2) with a specifi oauth account.

I ve just tried on the initial computer (C1) and when I try to upload I often 
have the error bellow (select/poll) after a few seconds 
Array
(
    [range] => bytes=0-7226554
    [x-range-md5] => bdb2db754b2ec6c9e29e57a877bc95b7
    [date] => Sun, 06 Oct 2013 17:21:49 GMT
    [server] => HTTP Upload Server Built on Oct 1 2013 11:24:15 (1380651855)
    [content-length] => 0
    [content-type] => text/html; charset=UTF-8
    [alternate-protocol] => 443:quic
)
041/227 19:21:49------------
Array
(
    [content-range] => bytes 7226555-7406033/59268599
    [content-type] => application/json; charset=UTF-8
    [content-length] => 262144
    [expect] =>
)
HTTP Error: (308) select/poll returned error

Moreover, with this computer (C1) the processing never end (always inProgress)

One difference between C1 and C2 is that the Oauth account on C1 have billing 
infos associated ... do you think it can explain something ?

Original comment by fxb...@gmail.com on 6 Oct 2013 at 5:37