.NET을 사용하여 비디오 업로드 응용 프로그램을 만듭니다. 은 YouTube와 통신하고 파일을 업로드하지만 파일 처리가 실패합니다. YouTube에서 '업로드가 실패했습니다. (동영상 파일을 변환 할 수 없습니다.)'오류 메시지가 표시됩니다. 이것은 아마 내가 그것을 수동으로 할 때 및 프로세스 벌금을 업로드 둘 다 두 개의 서로 다른 비디오와 시도를 한youtube - 비디오 업로드 실패 - 파일을 변환 할 수 없습니다 - 비디오 인코딩을 잘못 인코딩 했습니까?
"... 당신의 비디오는 우리의 컨버터가 인식 할 수없는 형식으로되어"있다는 것을 의미. 따라서 내 코드가 가.) 비디오를 올바르게 인코딩하지 않았거나 b) 내 API를 제대로 보내지 못했습니다. 요청이 적절합니다.
어떤 제안 오류가 극명하게 될 것이다 될 수 있는지에 : 내 API의 PUT 요청을 구성하고 비디오를 인코딩 얼마나 아래
이다.
감사합니다.
P. 내 응용 프로그램은 재개 가능한 업로드 기능을 사용하기 때문에 클라이언트 라이브러리를 사용하지 않습니다. 따라서 수동으로 내 API 요청을 작성하고 있습니다.
코드 :
// new PUT request for sending video
WebRequest putRequest = WebRequest.Create(uploadURL);
// set properties
putRequest.Method = "PUT";
putRequest.ContentType = getMIME(file); //the MIME type of the uploaded video file
//encode video
byte[] videoInBytes = encodeVideo(file);
public static byte[] encodeVideo(string video)
{
try
{
byte[] fileInBytes = File.ReadAllBytes(video);
Console.WriteLine("\nSize of byte array containing " + video + ": " + fileInBytes.Length);
return fileInBytes;
}
catch (Exception e)
{
Console.WriteLine("\nException: " + e.Message + "\nReturning an empty byte array");
byte [] empty = new byte[0];
return empty;
}
}//encodeVideo
//encode custom headers in a byte array
byte[] PUTbytes = encode(putRequest.Headers.ToString());
public static byte[] encode(string headers)
{
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] bytes = encoding.GetBytes(headers);
return bytes;
}//encode
//entire request contains headers + binary video data
putRequest.ContentLength = PUTbytes.Length + videoInBytes.Length;
//send request - correct?
sendRequest(putRequest, PUTbytes);
sendRequest(putRequest, videoInBytes);
public static void sendRequest(WebRequest request, byte[] encoding)
{
Stream stream = request.GetRequestStream(); // The GetRequestStream method returns a stream to use to send data for the HttpWebRequest.
try
{
stream.Write(encoding, 0, encoding.Length);
}
catch (Exception e)
{
Console.WriteLine("\nException writing stream: " + e.Message);
}
}//sendRequest
제목에 ".NET"과 같은 태그를 반복하지 마십시오. 그들이 속한 태그에 두십시오. –