Youtube API上传视频并添加免费图书馆的音频(C#)

时间:2017-12-12 21:40:40

标签: c# audio youtube-api youtube-data-api

我想要做的是,在上传视频后, 我想通过您可以在创作工作室中添加的免费音频为视频添加音频。 我可以通过编辑视频并转到音频部分手动完成,但我希望软件能够完成。 这是我现在用于将视频上传到youtube的代码:

UserCredential credential;
        using (var stream = new FileStream("client_id.json", FileMode.Open, FileAccess.Read))
        {
            credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                // This OAuth 2.0 access scope allows an application to upload files to the
                // authenticated user's YouTube channel, but doesn't allow other types of access.
                new[] { YouTubeService.Scope.YoutubeUpload },
                "user",
                CancellationToken.None
            );
        }

        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = Assembly.GetExecutingAssembly().GetName().Name
        });

        var video = new Video();
        video.Snippet = new VideoSnippet();
        video.Snippet.Title = "title";
        video.Snippet.Description = "description";
        video.Snippet.Tags = new string[]{"tags"};
        video.Snippet.CategoryId = "22"; 
        video.Status = new VideoStatus();
        video.Status.PrivacyStatus = "public"; 
        var filePath = "video.avi"

        using (var fileStream = new FileStream(filePath, FileMode.Open))
        {
            var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
            videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
            videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;

            await videosInsertRequest.UploadAsync();
        }

我只需要通过编程方式从创建工作室向上传的youtube添加音频。 感谢帮助。

1 个答案:

答案 0 :(得分:0)

Youtube API没有这样的方法。您可以在Videos reference中看到支持的方法。

相关问题