【问题标题】:Youtube API upload video and add audio from the free library (C#)Youtube API 从免费库上传视频和添加音频 (C#)
【发布时间】:2018-05-26 16:38:09
【问题描述】:

我想做的是,上传视频后, 我想从您可以在创作者工作室中添加的免费音频中将音频添加到视频中。 我可以通过编辑视频并转到音频部分来手动完成,但我希望软件能够做到这一点。 这是我现在将视频上传到 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。 感谢您的帮助。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2015-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-19
      • 2014-05-25
      • 1970-01-01
      • 2016-01-11
      • 2013-10-26
      相关资源
      最近更新 更多