Exemplo n.º 1
0
        private string ConstructArguments()
        {
            string template = "{1} -i \"{0}\" -f image2 -vframes 1 -y \"{2}\"";
            //{0} is input video
            //{1} is -ss TIME or blank (inaccurate but fast because it's before -i)
            //{2} is output image

            string input = _owner.textBoxIn.Text;

            if (string.IsNullOrWhiteSpace(input))
            {
                _message = "No input file!";
                return(null);
            }
            if (!File.Exists(input))
            {
                _message = "Input file doesn't exist";
                return(null);
            }

            float time = 0.0f;

            try
            {
                time = MainForm.ParseTime(_owner.boxCropFrom.Text);
            }
            catch (Exception)
            {
                //ParseTime will throw if the time is invalid, in this case we just set the time to zero if that happens
            }


            _message = string.Format("Previewing video at {0}", TimeSpan.FromSeconds(time));
            if (time == 0.0f)
            {
                _message += "\nTo preview at a different time, input a valid trim start time";
            }
            //We can actually allow invalid times here: we just use the preview from the very start of the video (0.0) in that case

            return(string.Format(template, input, "-ss " + time, _previewFile));
        }