मैं एक वीडियो अपलोडिंग एप्लिकेशन बनाने के लिए .NET का उपयोग कर रहा हूं। यद्यपि यह यूट्यूब के साथ संचार और फ़ाइल अपलोड करने के बाद, की प्रसंस्करण है कि फ़ाइल विफल हो जाती है। यूट्यूब मुझे त्रुटि संदेश देता है, "अपलोड विफल (वीडियो फ़ाइल को परिवर्तित करने में असमर्थ)।" यह माना जाता है कि इसका मतलब है कि "अपने वीडियो एक प्रारूप है कि हमारे कन्वर्टर्स को पहचान नहीं पा में है ..."यूट्यूब - वीडियो अपलोड विफलता - फ़ाइल को कनवर्ट करने में असमर्थ - वीडियो को एन्कोड करना गलत है?
मैं दो अलग अलग वीडियो, जो दोनों के अपलोड और इस प्रक्रिया ठीक है जब मैं कर इसे मैन्युअल साथ प्रयास किए हैं। इसलिए मुझे संदेह है कि मेरा कोड ए है।) वीडियो को ठीक से एन्कोड नहीं कर रहा है और/या बी।) मेरे एपीआई उचित रूप से अनुरोध नहीं भेज रहा है। क्या त्रुटि की सराहना की होगी हो सकता है पर
कोई सुझाव:
नीचे कैसे मैं अपने एपीआई PUT अनुरोध का निर्माण कर रहा हूँ और वीडियो एन्कोडिंग है।
धन्यवाद
पीएस मैं क्लाइंट लाइब्रेरी का उपयोग नहीं कर रहा हूं क्योंकि मेरा एप्लिकेशन पुन: प्रारंभ करने योग्य अपलोड सुविधा का उपयोग करेगा। इस प्रकार, मैं मैन्युअल रूप से अपना एपीआई अनुरोधों का निर्माण कर रहा हूं।
कोड:
// 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" जैसे टैग दोहराएं। उन टैग्स में उन्हें छोड़ दें जहां वे हैं। –