2013-05-22 4 views
10

मुझे एक अजीब आवश्यकता है। उपयोगकर्ता किसी भी प्रारूप (या एक सीमित प्रारूप) के अपने वीडियो अपलोड कर सकते हैं। हमें उन्हें स्टोर करना होगा और उन्हें पर परिवर्तित करना होगा .mp4 प्रारूप ताकि हम इसे हमारी साइट पर चला सकें।किसी भी वीडियो को अपलोड करें और .net4 में कनवर्ट करें .net

ऑडियो फ़ाइलों के लिए भी वही आवश्यकता।

मैंने गुगल किया है लेकिन मुझे कोई उचित विचार नहीं मिल रहा है। कोई मदद या सुझाव .... ??

अग्रिम धन्यवाद

+0

मैं अगर यह मदद मिलेगी पता नहीं है लेकिन वहाँ एक ऑनलाइन कनवर्टर है मिल जाएगा .flv बदलें कृपया - हो सकता है स्रोत देखें? http://video.online-convert.com/convert-to-mp4 –

+0

क्या .net भाषा आप एएसपी/सी तेज का उपयोग कर रहे हैं? –

+0

आप इस ब्लॉग को देखकर https://code.google.com/p/ffmpeg-sharp/ –

उत्तर

9

में आप FFMpeg command line utility साथ mp4/एमपी 3 करने के लिए लगभग किसी भी वीडियो/ऑडियो उपयोगकर्ता फ़ाइलों में बदल सकते हैं। नेट से यह (यह एक अच्छा है, क्योंकि सब कुछ एक DLL में पैक किया जाता है) Video Converter for .NET की तरह आवरण लाइब्रेरी का उपयोग कर कहा जा सकता है:

(new NReco.VideoConverter.FFMpegConverter()).ConvertMedia(pathToVideoFile, pathToOutputMp4File, Formats.mp4) 

ध्यान दें कि वीडियो रूपांतरण महत्वपूर्ण CPU संसाधनों की आवश्यकता है; पृष्ठभूमि में इसे चलाने के लिए अच्छा विचार है।

+0

यह एक अपवाद फेंकता है "प्रकार का एक अपवाद" System.ComponentModel.Win32Exception 'NReco.VideoConverter.dll में हुआ लेकिन उपयोगकर्ता कोड में प्रबंधित नहीं किया गया अतिरिक्त जानकारी: निर्दिष्ट निष्पादन योग्य नहीं है इस ओएस मंच के लिए एक वैध आवेदन। " – haroonxml

8

Your Answer

.mp4 करने के लिए आप अपने जवाब

private bool ReturnVideo(string fileName) 
    { 
     string html = string.Empty; 
     //rename if file already exists 

     int j = 0; 
     string AppPath; 
     string inputPath; 
     string outputPath; 
     string imgpath; 
     AppPath = Request.PhysicalApplicationPath; 
     //Get the application path 
     inputPath = AppPath + "OriginalVideo"; 
     //Path of the original file 
     outputPath = AppPath + "ConvertVideo"; 
     //Path of the converted file 
     imgpath = AppPath + "Thumbs"; 
     //Path of the preview file 
     string filepath = Server.MapPath("~/OriginalVideo/" + fileName); 
     while (File.Exists(filepath)) 
     { 
      j = j + 1; 
      int dotPos = fileName.LastIndexOf("."); 
      string namewithoutext = fileName.Substring(0, dotPos); 
      string ext = fileName.Substring(dotPos + 1); 
      fileName = namewithoutext + j + "." + ext; 
      filepath = Server.MapPath("~/OriginalVideo/" + fileName); 
     } 
     try 
     { 
      this.fileuploadImageVideo.SaveAs(filepath); 
     } 
     catch 
     { 
      return false; 
     } 
     string outPutFile; 
     outPutFile = "~/OriginalVideo/" + fileName; 
     int i = this.fileuploadImageVideo.PostedFile.ContentLength; 
     System.IO.FileInfo a = new System.IO.FileInfo(Server.MapPath(outPutFile)); 
     while (a.Exists == false) 
     { 

     } 
     long b = a.Length; 
     while (i != b) 
     { 

     } 


     string cmd = " -i \"" + inputPath + "\\" + fileName + "\" \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + "\""; 
     ConvertNow(cmd); 
     string imgargs = " -i \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + "\" -f image2 -ss 1 -vframes 1 -s 280x200 -an \"" + imgpath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".jpg" + "\""; 
     ConvertNow(imgargs); 


     return true; 
    } 
    private void ConvertNow(string cmd) 
    { 
     string exepath; 
     string AppPath = Request.PhysicalApplicationPath; 
     //Get the application path 
     exepath = AppPath + "ffmpeg.exe"; 
     System.Diagnostics.Process proc = new System.Diagnostics.Process(); 
     proc.StartInfo.FileName = exepath; 
     //Path of exe that will be executed, only for "filebuffer" it will be "flvtool2.exe" 
     proc.StartInfo.Arguments = cmd; 
     //The command which will be executed 
     proc.StartInfo.UseShellExecute = false; 
     proc.StartInfo.CreateNoWindow = true; 
     proc.StartInfo.RedirectStandardOutput = false; 
     proc.Start(); 

     while (proc.HasExited == false) 
     { 

     } 
    } 
    protected void btn_Submit_Click(object sender, EventArgs e) 
    { 
     ReturnVideo(this.fileuploadImageVideo.FileName.ToString()); 
    } 
+0

@Tejas के लिए दूसरा रूपांतरण क्या है – meda

संबंधित मुद्दे