【问题标题】:Youtube API upload duration too shortYoutube API 上传时间太短
【发布时间】:2018-04-11 23:20:38
【问题描述】:

我正在尝试使用 c# 上传视频,上传本身可以工作但是

视频总是太短(例如,2:14 的视频在 youtube 上变成了 00:29 的视频,00:45 的视频变成了 00:05 的视频)。

上传期间我没有收到错误消息或异常

这是我正在使用的代码

        UserCredential credential;
        ClientSecrets secrets = new ClientSecrets();
        secrets.ClientId = "clientid";
        secrets.ClientSecret = "clientsecret";
        credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
            secrets,
            new[] { YouTubeService.Scope.YoutubeUpload },
            "username", 
            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 = "Default Video Title";
        video.Snippet.Description = "Default Video Description";
        video.Snippet.Tags = new string[] { "tag1", "tag2" };
        video.Snippet.CategoryId = "22";
        video.Status = new VideoStatus();
        video.Status.PrivacyStatus = "public";
        var filePath = @"filepath";
        using (var fileStream = new FileStream(filePath, FileMode.Open))
        {
            var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet, status", fileStream, "video/mp4");

            videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
            videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
            videosInsertRequest.Upload();
        }

To 代码来源于一个 google-api 示例

【问题讨论】:

  • 听起来您上传的视频的帧率变化不定或非常低。您是否还可以发布有关您正在上传的视频的一些信息,例如mediainfo 的输出?
  • 当然,持续时间:02:14;比特率:1300kb; fps: 29. 你还需要什么?
  • 你可能已经知道你是否有恒定的帧率......但无论如何我在保持沉默之前问:mediainfo告诉你帧率模式和FrameRate_Mode_Original - 你可以发布一个链接到你的上传视频?
  • 抱歉,我在哪里可以找到 Mediainfo?
  • 很抱歉,我一直认为任何处理视频内容的人都知道:mediaarea.net/en/MediaInfo/Download

标签: c# video youtube google-api youtube-api


【解决方案1】:

通过使用 ffmpeg 命令行对视频进行转码:

  • ffmpeg -i %source% %target%.mp4

我们发现使用 mediainfo

ffmpeg 的输出比原来的短。 ffmpeg 输出确实显示了一些关于未找到 NAL 单元的错误消息,这意味着输入流被打乱,上传的视频实际上比 VLC 媒体播放器显示的短。

【讨论】:

    猜你喜欢
    • 2018-05-31
    • 2013-04-12
    • 1970-01-01
    • 2016-08-10
    • 2017-03-19
    • 2011-11-14
    • 1970-01-01
    • 2013-06-09
    • 2018-07-02
    相关资源
    最近更新 更多