dqaq59269 2019-05-07 20:27
浏览 419

通过API v3上传到YouTube时“正在处理视频”

I am trying to upload a video in mp4 format to YouTube and am using code from the developer page. I tried so much and eventually looked into the source code. Now I am finally at a point where I see a video in my creator studio. Problem is, it's a black thumbnail and just says processing and will forever stay in that state (Didn't finish a week later). My videos are about 10 min long, only 13mb or so big and I suspect that the code I got from the google page is old and has not been held up to date, which makes me really frustrated.

I tried different code snippets and edited the parameters. I got my code from: https://developers.google.com/youtube/v3/docs/videos/insert?apix=true

This is my code at the moment:

$client = new Google_Client();
$client->setApplicationName('API code samples');
$client->setScopes([
    'https://www.googleapis.com/auth/youtube.upload'
]);

$client->setAuthConfig('assets/client_id.json');
$client->setAccessType('offline');

// Request authorization from the user.
$authUrl = $client->createAuthUrl();
printf("Open this link in your browser:
%s
", $authUrl);
print('Enter verification code: ');
$authCode = trim(fgets(STDIN));

// Exchange authorization code for an access token.
$accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
$client->setAccessToken($accessToken);

// Define service object for making API requests.
$service = new Google_Service_YouTube($client);

// Define the $video object, which will be uploaded as the request body.
$video = new Google_Service_YouTube_Video();

// Add 'localizations' object to the $video object.
$localizations = new Google_Service_YouTube_VideoLocalization();
$video->setLocalizations($localizations);

$queryParams = [
    'autoLevels' => true,
    'notifySubscribers' => true,
    'stabilize' => false,
    'data' => file_get_contents("./content/$id/_$thread_name.mp4"),
    'mimeType' => 'video/mp4',
    'uploadType' => 'multipart'
];

$response = $service->videos->insert(
    'snippet',
    $video,
    $queryParams
);

echo "https://youtu.be/".$response->id;

I am expecting my code to run, upload the video and give me a link afterwards. At this moment I don't get any errors and I do get a link. The link just doesn't show a working video.

Example video I uploaded (all of them look the same): https://youtu.be/iOB_i-ZD5io

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP