如何获得一个加载返回值



我正在尝试为我的函数创建一个加载进度条:

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");

        }

当调用命令"proc.WaitForExit()"时,我希望能够返回某种类型的负载百分比。在前端,我只有一个gif加载图像,但我想要能够显示进度,有办法做到这一点吗?

这篇文章解释了如何做到这一点,它是用ruby编写的,但是你可以在里面找到一些信息

最新更新