Example #1
0
 protected void Run(string arguments)
 {
     Console.WriteLine("Running FFmpeg with following arguments:");
     Console.WriteLine(arguments);
     _process.Run(arguments);
     _minFps = 0;
 }
        /// <summary>
        /// Encodes specified audio file according to settings. The script file must already be written.
        /// </summary>
        /// <param name="settings">An object containing the encoding settings.</param>
        /// <returns>The endoding completion status..</returns>
        public static CompletionStatus EncodeAudio(MediaEncoderSettings settings)
        {
            CompletionStatus    Result  = CompletionStatus.Success;
            string              WavFile = PathManager.GetAudioFile(settings.JobIndex, AudioActions.Wav);
            ProcessStartOptions Options = new ProcessStartOptions(settings.JobIndex, "Exporting Audio", false).TrackProcess(settings);

            if (!File.Exists(WavFile))
            {
                EncoderBusiness.SaveAudioToWav(settings, WavFile, Options);
                if (settings.CompletionStatus == CompletionStatus.Cancelled)
                {
                    File.Delete(WavFile);
                    return(CompletionStatus.Cancelled);
                }
                if (!File.Exists(WavFile))
                {
                    settings.Cancel();
                    return(CompletionStatus.Error);
                }
            }

            string DestFile = PathManager.GetAudioFile(settings.JobIndex, settings.AudioAction);

            if (!File.Exists(DestFile))
            {
                Options.Title = "Encoding Audio";
                if (settings.AudioAction == AudioActions.Opus)
                {
                    string        Args   = string.Format(@"--bitrate {0} ""{1}"" ""{2}""", settings.AudioQuality, WavFile, DestFile);
                    FFmpegProcess Worker = new FFmpegProcess(Options);
                    Result = Worker.Run("Encoder\\opusenc.exe", Args);
                }
                else if (settings.AudioAction == AudioActions.Aac || settings.AudioAction == AudioActions.Flac)
                {
                    Result = MediaEncoder.Encode(WavFile, null,
                                                 settings.AudioAction == AudioActions.Flac ? "flac" : "aac",
                                                 string.Format("-b:a {0}k", settings.AudioQuality),
                                                 DestFile,
                                                 Options);
                }
            }

            if (Result != CompletionStatus.Success || !File.Exists(DestFile))
            {
                File.Delete(DestFile);
                settings.Cancel();
            }
            return(Result);
        }
Example #3
0
        public static void LoadDevices()
        {
            Console.WriteLine("Running FFmpeg");
            var ffmpeg = new FFmpegProcess();

            ffmpeg.OutputDataReceived += Ffmpeg_ProcessDeviceLine;

            Console.WriteLine("");
            ffmpeg.Run("-f decklink -list_devices 1 -i dummy");
            ffmpeg.WaitForExit();
            Console.WriteLine("");

            for (int i = 0; i < Devices.Count; i++)
            {
                Console.WriteLine("Found Decklink device #{0}: {1}", i + 1, Devices[i].Name);
            }
        }
Example #4
0
        public static void LoadDeviceModes()
        {
            for (int i = 0; i < Devices.Count; i++)
            {
                Console.WriteLine("Loading supported modes for device #{0} {1}", i + 1, Devices[i].Name);

                var ffmpeg = new FFmpegProcess();
                ffmpeg.OutputDataReceived += (a, b) => { Ffmpeg_ProcessDeviceModeLine(Devices[i], b.Data); };

                Console.WriteLine("");
                ffmpeg.Run(string.Format("-f decklink -list_formats 1 -i \"{0}\"", Devices[i].Name));
                ffmpeg.WaitForExit();
                Console.WriteLine("");
            }

            for (int i = 0; i < Devices.Count; i++)
            {
                Console.WriteLine("#{0} {1} supports {2} modes", i + 1, Devices[i].Name, Devices[i].Modes.Count);
            }
        }