我尝试使用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();
}
代码来自google-api示例
答案 0 :(得分:1)
使用ffmpeg命令行对视频进行转码:
我们发现使用mediainfo
ffmpeg的输出比原始输出短。 ffmpeg输出确实指示一些错误有关未找到的NAL单元的消息,这意味着输入流被抓取,并且上传的视频实际上比VLC媒体播放器节目更短。