Example #1
0
 private void run_yamdi(object sender, EventArgs e)
 {
     if (!File.Exists(this.file_ff))
     {
         this.run_getimg(null, null);
     }
     this.p_encoder            = new ProcessCaller(this.formobj);
     this.p_encoder.FileName   = Application.StartupPath + @"\yamdi.exe";
     this.p_encoder.Arguments  = "-i \"" + this.file_ff + " \" -o \"" + this.file_out + "\" -l";
     this.p_encoder.Cancelled += new EventHandler(this.run_Canceled);
     if (this.configini.ReadBool("encoder", "mobilevideo", false))
     {
         this.p_encoder.Completed += new EventHandler(this.run_mobilevideo);
     }
     else
     {
         this.p_encoder.Completed += new EventHandler(this.run_getimg);
     }
     this.p_encoder.tsn           = "";
     this.p_encoder.PriorityClass = this.cpu_pri;
     this.statini.WriteString("encoder", "enmsg", "正在写入关键帧...");
     this.AppendLog("开始yamdi命令:" + this.p_encoder.FileName + " " + this.p_encoder.Arguments);
     this.p_encoder.Start();
 }
Example #2
0
        private void run_ffmpeg(object sender, EventArgs e)
        {
            string str;
            string str2;
            int    height;
            string str3;
            string str4 = "";
            string str5 = this.file_in;

            if (!(string.IsNullOrEmpty(this.file_me) || !File.Exists(this.file_me)))
            {
                str5 = this.file_me;
            }
            this.e_Height      = func.GetInt(this.configini.ReadString("encoder", "height", ""));
            this.e_Width       = func.GetInt(this.configini.ReadString("encoder", "width", ""));
            this.e_FrameRate   = func.GetInt(this.configini.ReadString("encoder", "fps", ""));
            this.e_vBit        = func.GetInt(this.configini.ReadString("encoder", "vbit", ""));
            this.e_aBit        = func.GetInt(this.configini.ReadString("encoder", "abit", ""));
            this.e_MobileVideo = this.configini.ReadString("encoder", "mobilevideo", "");
            string path = this.configini.ReadString("logo", "logo_img", "");
            int    @int = func.GetInt(this.configini.ReadString("logo", "logo_top", ""));
            int    num3 = func.GetInt(this.configini.ReadString("logo", "logo_bot", ""));
            int    num4 = func.GetInt(this.configini.ReadString("logo", "logo_left", ""));
            int    num5 = func.GetInt(this.configini.ReadString("logo", "logo_right", ""));
            string str7 = this.configini.ReadString("logo", "logo_ali", "");
            string str8 = this.configini.ReadString("logo", "logo_type", "图片水印");

            if (this.e_FrameRate < 15)
            {
                this.e_FrameRate = 15;
            }
            if (str8 == "文字水印")
            {
                path = Application.StartupPath + @"\images\logotext.png";
            }
            if (this.m_Width > 0)
            {
                height = (this.m_Height * this.e_Width) / this.m_Width;
            }
            else
            {
                height = 0;
            }
            if ((height % 2) != 0)
            {
                height--;
            }
            if (height <= 0)
            {
                height = this.m_Height;
            }
            string str9 = string.Concat(new object[] { " -s ", this.e_Width, "x", height });

            if (!(this.configini.ReadBool("encoder", "allwh", true) || (this.e_Width <= this.m_Width)))
            {
                str9 = "";
            }
            switch (str7)
            {
            case "0":
                str = num4.ToString() + ":" + @int.ToString();
                break;

            case "1":
                str = "main_w/2-overlay_w/2:" + @int;
                break;

            case "2":
                str = string.Concat(new object[] { "main_w-overlay_w-", num5, ":", @int });
                break;

            case "3":
                str = num4 + ":main_h/2-overlay_h/2";
                break;

            case "4":
                str = "main_w/2-overlay_w/2:main_h/2-overlay_h/2";
                break;

            case "5":
                str = "main_w-overlay_w-" + num5 + ":main_h/2-overlay_h/2";
                break;

            case "6":
                str = num4 + ":main_h-overlay_h-" + num3;
                break;

            case "7":
                str = "main_w/2-overlay_w/2:main_h-overlay_h-" + num3;
                break;

            case "8":
                str = string.Concat(new object[] { "main_w-overlay_w-", num5, ":main_h-overlay_h-", num3 });
                break;

            default:
                str = "";
                break;
            }
            str = " -vf \"movie=0:png:" + path.Replace(@"\", "/") + " [wm];[in][wm] overlay=" + str + ":1 [out]\" ";
            if (!File.Exists(path))
            {
                str = "";
            }
            if (this.m_isf4v)
            {
                int num6 = func.GetInt(this.configini.ReadString("encoder", "f4vsplit", ""));
                if (num6 > 0)
                {
                    str4 = " -ss 00:00:" + num6 + " ";
                }
            }
            if ((this.e_MobileVideo == "是") || this.m_isAudio)
            {
                //                str2 = " -deinterlace -subq 5 -me_method umh -me_range 16 -bf 0  -i_qfactor 1.4 -b_qfactor 1.3 -flags +loop -level 31 ";
                //ljj@2016-5-27:去掉反隔行相关命令。提升画面清晰度。
                str2 = " -bf 0  -i_qfactor 1.4 -b_qfactor 1.3 -flags +loop -level 31 ";
            }
            else
            {
                //str2 = " -deinterlace -subq 7 -me_method umh -me_range 16 -bf 3  -i_qfactor 1.4 -b_qfactor 1.3 -coder 1 -refs 3 -qmin 10 -qmax 51 -sc_threshold 40 -flags2 +dct8x8  -flags +loop -trellis 1 ";
                //ljj@2016-5-27:去掉反隔行相关命令。提升画面清晰度。
                str2 = " -bf 3  -i_qfactor 1.4 -b_qfactor 1.3 -coder 1 -refs 3 -qmin 10 -qmax 51 -sc_threshold 40 -flags2 +dct8x8  -flags +loop -trellis 1 ";
            }
            if (this.outfiletype == "mp4")
            {
                str3 = this.file_out;
            }
            else
            {
                str3 = this.file_ff;
            }
            string str10 = string.Concat(new object[] {
                "-i \"", str5, "\" ", str4, " -y -async 1 -vsync 1 -acodec libfaac -ab ", this.e_aBit, "k -ac 2 ", str9, " -vcodec libx264 -x264opts keyint= ", this.e_FrameRate, str2, " -threads 0  -b ", this.e_vBit, "k -maxrate 5000k -bufsize 1 -g ", this.e_FrameRate, " -r ", this.e_FrameRate,
                " ", str, "\"", str3, "\" "
            });

            this.p_encoder                 = new ProcessCaller(this.formobj);
            this.p_encoder.FileName        = Application.StartupPath + @"\ffmpeg\ffmpeg.exe";
            this.p_encoder.Arguments       = str10;
            this.p_encoder.StdErrReceived += new DataReceivedHandler(this.writeStreamInfo);
            this.p_encoder.StdOutReceived += new DataReceivedHandler(this.writeStreamInfo);
            if (this.outfiletype == "mp4")
            {
                if (this.configini.ReadBool("encoder", "mobilevideo", false))
                {
                    this.p_encoder.Completed += new EventHandler(this.run_mobilevideo);
                }
                else
                {
                    this.p_encoder.Completed += new EventHandler(this.run_getimg);
                }
            }
            else
            {
                this.p_encoder.Completed += new EventHandler(this.run_yamdi);
            }
            this.p_encoder.Cancelled    += new EventHandler(this.run_Canceled);
            this.p_encoder.tsn           = this.fcode;
            this.p_encoder.PriorityClass = this.cpu_pri;
            this.statini.WriteString("encoder", "enmsg", "");
            this.AppendLog("开始ffmpeg转码:" + this.p_encoder.FileName + " " + this.p_encoder.Arguments);
            this.runtype = "ffmpeg";
            this.p_encoder.Start();
        }
Example #3
0
        private void run()
        {
            ProcessStartInfo info;
            Process          process;

            this.file_pdf = this.file_in;
            FileInfo info2 = new FileInfo(this.file_in);
            string   str   = info2.Extension.ToLower();

            if (str != ".pdf")
            {
                this.file_pdf = this.file_in + ".pdf";
                if (".jpg|.png|.gif|.tif|.bmp|.psd|.pcx|.zip".IndexOf(str) >= 0)
                {
                    string str2 = this.file_in;
                    if (str == ".zip")
                    {
                        string str3 = Application.StartupPath + @"\zipimg\";
                        if (Directory.Exists(str3))
                        {
                            try
                            {
                                func.DelDir(str3);
                            }
                            catch
                            {
                            }
                        }
                        if (this.UnZip(this.file_in, str3))
                        {
                            str2 = Application.StartupPath + @"\zipimg";
                        }
                    }
                    ProcessStartInfo info3 = new ProcessStartInfo();
                    info3.FileName        = Application.StartupPath + @"\img2pdf\img2pdf.exe";
                    info3.Arguments       = " -o \"" + this.file_pdf + "\" \"" + str2 + "\"";
                    info3.CreateNoWindow  = true;
                    info3.UseShellExecute = false;
                    info = info3;
                    this.AppendLog("开始转换图片为pdf:" + info.FileName + " " + info.Arguments);
                    this.statini.WriteString("encoder", "enmsg", "正在处理图片");
                    process = Process.Start(info);
                    process.WaitForExit(0x7530);
                    if (!process.HasExited)
                    {
                        process.Kill();
                    }
                }
                else
                {
                    int tout = this.configini.ReadInteger("doc", "d_outtime", 300);
                    try
                    {
                        new convert(tout).topdf(this.file_in, this.file_pdf);
                        this.AppendLog("开始转换为pdf文件:" + this.file_pdf);
                        this.statini.WriteString("encoder", "enmsg", "正在处理文档");
                    }
                    catch (Exception exception)
                    {
                        this.AppendLog("错误:" + exception.Message.ToString());
                        this.statini.WriteString("encoder", "enmsg", "错误:" + exception.Message.ToString());
                    }
                }
            }
            if (!File.Exists(this.file_pdf))
            {
                this.tmchk.Enabled = true;
                this.taskfail(null, null);
            }
            if (!Directory.Exists(this.file_out))
            {
                Directory.CreateDirectory(this.file_out);
            }
            int    num2  = this.configini.ReadInteger("doc", "d_flashversion", 9);
            bool   flag  = this.configini.ReadBool("doc", "d_dislink", false);
            bool   flag2 = this.configini.ReadBool("doc", "d_enzip", true);
            bool   flag3 = this.configini.ReadBool("doc", "d_shapes", false);
            bool   flag4 = this.configini.ReadBool("doc", "d_usefont", false);
            bool   flag5 = this.configini.ReadBool("doc", "d_poly2bitmap", false);
            int    num3  = this.configini.ReadInteger("doc", "d_dpi", 0x48);
            string path  = this.configini.ReadString("doc", "d_pdflogo", "");

            if (File.Exists(path))
            {
                string           str5  = this.file_pdf + "_logo.pdf";
                ProcessStartInfo info4 = new ProcessStartInfo();
                info4.FileName        = Application.StartupPath + @"\pdftk.exe";
                info4.Arguments       = " \"" + this.file_pdf + "\" stamp \"" + path + "\" output \"" + str5 + "\"";
                info4.CreateNoWindow  = true;
                info4.UseShellExecute = false;
                info = info4;
                this.AppendLog("开始添加水印:" + info.FileName + " " + info.Arguments);
                this.statini.WriteString("encoder", "enmsg", "正在添加水印");
                process = Process.Start(info);
                process.WaitForExit(0x2bf20);
                if (!process.HasExited)
                {
                    process.Kill();
                }
                else if (File.Exists(str5))
                {
                    File.Delete(this.file_pdf);
                    File.Move(str5, this.file_pdf);
                }
                this.iswmark = true;
            }
            else
            {
                this.iswmark = false;
            }
            if (num3 <= 1)
            {
                num3 = 0x48;
            }
            string str6 = "\"" + this.file_pdf + "\" \"" + this.file_out + "\\paper%.swf\" -s flashversion=" + num2.ToString();

            if (flag2)
            {
                str6 = str6 + " -s enablezlib";
            }
            if (flag)
            {
                str6 = str6 + " -s disablelinks";
            }
            if (flag4)
            {
                str6 = str6 + " -s storeallcharacters";
            }
            if (flag3 || (this.errcount > 0))
            {
                str6 = str6 + " -S";
            }
            if (flag5 && (".ppt|.pptx|.pptm|.pot|.potx".IndexOf(str) >= 0))
            {
                str6 = str6 + " -s poly2bitmap";
            }
            if (num3 != 0x48)
            {
                str6 = str6 + " -s zoom=" + num3;
            }
            if (Directory.Exists(@"C:\xpdf\xpdf-chinese-simplified"))
            {
                str6 = str6 + @" -s languagedir=C:\xpdf\xpdf-chinese-simplified";
            }
            ProcessCaller caller2 = new ProcessCaller(this);

            caller2.FileName  = Application.StartupPath + @"\swftools\pdf2swf.exe";
            caller2.Arguments = str6;
            ProcessCaller caller = caller2;

            caller.StdErrReceived += new DataReceivedHandler(this.writeStreamInfo);
            caller.StdOutReceived += new DataReceivedHandler(this.writeStreamInfo);
            caller.Completed      += new EventHandler(this.run_getimg);
            caller.Cancelled      += new EventHandler(this.taskfail);
            caller.tsn             = this.fcode;
            this.statini.WriteString("encoder", "enmsg", "正在生成swf文件");
            this.AppendLog("开始转换为flash文件:" + caller.FileName + " " + caller.Arguments);
            caller.Start();
        }