2011-08-30 116 views
0

我想创建我的功能的加载进度条装载返回值:如何获得

private string ConvertToFLV(string phyicalFilePath) 
     { 
      if (Path.GetExtension(phyicalFilePath).Equals(".flv")) return phyicalFilePath; 

       var argument = string.Format(@"-i ""{0}"" -vcodec flv -f flv -r 29.97 -s 320x240 -aspect 4:3 -b 300k -g 160 -cmp dct -subcmp dct -mbd 2 -flags +aic+cbp+mv0+mv4 -trellis 1 -ac 1 -ar 22050 -ab 56k ""{1}""", phyicalFilePath, Path.ChangeExtension(phyicalFilePath, "flv")); 
       // var argument = string.Format("-i {0} -crf 35.0 -vcodec libx264 -acodec libfaac -ar 48000 -ab 128k -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -threads 0 {1}", phyicalFilePath, Path.ChangeExtension(phyicalFilePath, "mp4")); 
       File.Delete(Path.ChangeExtension(phyicalFilePath, "flv")); 

       ProcessStartInfo process = new ProcessStartInfo(ffmpegPhysicalPath, argument); 
       Process proc = new Process(); 
       proc.StartInfo = process; 
       proc.Start(); 
       proc.WaitForExit(); 

       return Path.ChangeExtension(phyicalFilePath, "flv"); 



     } 

了when他命令“proc.WaitForExit()”被调用时,我希望能够返回某种类型的负载百分比。在前端,我只是有一个gif加载图像,但我希望能够显示这方面的进展,有没有办法做到这一点?

回答

1

This post是解释如何做到这一点,它是红宝石,但你可以找到它的一些信息。