2013-06-03 3 views
1

이것은 내가 오류입니다 "요청이 취소되었습니다"내가 사용하고 어떤의 기본 버전으로 아래로 내 코드를 손질닷넷 유튜브 API 2.0 - 일관성 오류 업로드 -

An unhandled exception of type 'System.Net.WebException' occurred in Google.GData.Client.dll 

Additional information: The request was aborted: The request was canceled. 

:

 YouTubeRequestSettings settings; 
     YouTubeRequest request; 
     string devkey = "AI39si7VBlJSkNcHUWZdk5OPYa8IXZhVo-ak7KRtFYlfkCdt767P6oxPgoWcMXMfUCLL6-Ot3G-NmLe_cIlCWQDRq2FQl3F0aQ"; 
     string username = Username.Text; 
     string password = Password.Text; 
     Upload.Text = "Authenticating..."; 
     settings = new YouTubeRequestSettings("Music to YouTube", devkey, username, password) { Timeout = -1 }; 
     request = new YouTubeRequest(settings); 

     Video newVideo = new Video(); 

     newVideo.Title = Title.Text; 
     newVideo.Description = Description.Text; 
     newVideo.Keywords = Keywords.Text; 
     newVideo.Tags.Add(new MediaCategory("Music", YouTubeNameTable.CategorySchema)); 

     if (Privacy.Text == "Public") 
      newVideo.YouTubeEntry.Private = false; 
     else if (Privacy.Text == "Unlisted") 
      newVideo.YouTubeEntry.AccessControls.Add(new YtAccessControl("list", "denied")); 
     else if (Privacy.Text == "Private") 
      newVideo.YouTubeEntry.Private = true; 

     string fileMusic = "audio"; 
     string fileImage = "image"; 
     string fileTimeName = (DateTime.Now.Ticks/10000).ToString() + ".avi"; 

     File.Copy(MusicPath.Text, Environment.CurrentDirectory + "\\" + fileMusic, true); 
     File.Copy(ImagePath.Text, Environment.CurrentDirectory + "\\" + fileImage, true); 

     Upload.Text = "Mixing Music and Image..."; 
     var mix = Process.Start("ffmpeg.exe", "-loop 1 -r 1 -i " + fileImage + " -i " + fileMusic + " -shortest -vcodec mpeg4 -qscale:v 1 -acodec pcm_alaw -vf scale=\"'iw*max(1280/iw\\,720/ih)':'ih*max(1280/iw\\,720/ih)'\" " + fileTimeName); 

     File.Delete(fileMusic); 
     File.Delete(fileImage); 

     Upload.Text = "Uploading..."; 

     newVideo.YouTubeEntry.MediaSource = new MediaFileSource(fileTimeName, "video/avi"); 
     Video createdVideo = request.Upload(newVideo); 

     Upload.Text = "Uploaded!"; 
     File.Delete(fileTimeName); 

맨 끝에 업로드 요청이 제대로 표시되지 않아 그 이유를 알 수 없습니다. 업로드 된 최종 파일은 FFmpeg에 의해 생성되고, 나는 그것을 철저히 테스트 했으므로, 업로드 된 파일은 아무런 문제가되지 않는다. 크기는 30-40MB 정도이다.

시간 제한은 -1로 설정되므로 이론적으로 트리거되지 않습니다. 내가 추측 할 수있는 유일한 것은 인증이 실패하고 있다는 것입니다.

누군가가 어떤 종류의 경험이 있다면, 나는 이것이 나를 미치게 만들기 때문에 도움을 크게 주심을 감사 할 것입니다.

+0

API는 어떻게 파일을 업로드하나요? KeepAlive를 비활성화하거나 MaxRequestLength를 어딘가에 설정해야 할 수 있습니다. –

답변

0

다음 코드 줄을 추가하면 문제가 해결됩니다. ((GDataRequestFactory) request.Service.RequestFactory) .Timeout = 9999999; ((GDataRequestFactory) request.Service.RequestFactory) .KeepAlive = false;