示例#1
0
        public static async Task <string> getVersion()
        {
            CommandTask command = new CommandTask();

            command.enableMultiTask = true;
            var res   = "";
            var count = 0;

            command.onRes = (dat) =>
            {
                //if (count < 2)
                res += dat + "\r\n";

                count++;
            };
            await command.exec(ffmp, " -version ");

            return(res);
        }
示例#2
0
        public async Task getInfo(string file)
        {
            if (file == "")
            {
                throw new ExceptionFFmpeg(dfv.lang.dat.Please_add_file_name);
            }

            fileName = file;
            var ext = dfv.getFileExt(file);

            if (ext == "avs")
            {
                info.format.format_name = "avs";
                info.streams.Add(getAvs(file));
                return;
            }

            CommandTask command = new CommandTask();
            var         json    = "";

            command.onRes = (dat) =>
            {
                json += dat;
            };
            await command.exec(ffprobe, " -print_format json -v quiet -show_error -show_format -show_streams -show_chapters  \"" + file + "\" ");

            infoObj = JsonConvert.DeserializeObject <MediaFileObj>(json);
            info    = infoObj.toMediaFile();

            if (infoObj.error.message != "")
            {
                throw new ExceptionFFmpeg(infoObj.error.message);
            }

            info.format.durationMilli = dfv.timeStrToLong(info.format.duration);
        }
示例#3
0
        private async Task execOne(string cmd, int nPass)
        {
#if DEBUG
            dfv.log(cmd);
#endif
            cmd = cmd.Replace("\r", "").Replace("\n", " ");

            cmd += " -hide_banner";


            processPercent = 0;
            processSpeed   = "";
            processFPS     = "";
            processTime    = "";
            string err = "";

            string      errPrev = "";
            CommandTask command = new CommandTask();
            command.onErr = (dat) =>
            {
                if (onResLine != null)
                {
                    onResLine(dat);
                }

                parseInfo(dat);

                onProcess(dat, nPass);


                if (dat.StartsWith("[") ||
                    dat.StartsWith("Incompatible ") ||
                    dat.StartsWith("Error ") ||
                    dat.StartsWith("Invalid ") ||
                    dat.Contains("[error]") ||
                    dat.StartsWith("Unknown ")
                    )
                {
                    errPrev += dat + "\r\n";
                }
                else
                {
                    err = dat;
                }
            };
            await command.exec(ffmp, cmd);

            if (command.isUserKill)
            {
                throw new ExceptionFFmpeg(dfv.lang.dat.Task_aborted, true);
            }

            if (command.exitCode != 0)
            {
                var allErr = errPrev + err;
                if (allErr != "At least one output file must be specified")
                {
                    throw new ExceptionFFmpeg(errPrev + err);
                }
            }


            processPercent = 100;
        }