C# Youtube API上载持续时间太短
我尝试用c#上传视频,上传本身可以但 视频总是太短(例如,youtube上的2:14视频变为00:29视频,00:45视频变为00:05视频) 我在上传过程中没有收到任何错误消息或异常 这是我正在使用的代码C# Youtube API上载持续时间太短,c#,video,youtube,google-api,youtube-api,C#,Video,Youtube,Google Api,Youtube Api,我尝试用c#上传视频,上传本身可以但 视频总是太短(例如,youtube上的2:14视频变为00:29视频,00:45视频变为00:05视频) 我在上传过程中没有收到任何错误消息或异常 这是我正在使用的代码 UserCredential credential; ClientSecrets secrets = new ClientSecrets(); secrets.ClientId = "clientid"; secrets.Cli
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示例,通过使用ffmpeg命令行对视频进行转码:
- ffmpeg-i%source%%target%.mp4
ffmpeg的输出比原来的短。ffmpeg输出确实显示了一些关于未找到NAL单元的错误消息,这意味着输入流被加密,上载的视频实际上比VLC media Player显示的视频短。听起来您正在上载的视频的帧速率不稳定或非常低。您是否也可以发布一些关于您正在上传的视频的信息,例如mediainfo的输出?当然可以,持续时间:02:14;比特率:1300kb;fps:29。您还需要什么?您可能已经知道是否有恒定帧速率。。。但在保持沉默之前,我还是要问:mediainfo告诉了你关于帧速率模式和帧速率模式的什么?你能发布一个链接到你上传的视频吗?对不起,我在哪里找到mediainfo?我也很抱歉,我总是认为任何处理视频内容的人都已经知道了: