示例#1
0
        /// <summary>
        ///     Saves audio from a specific video file to disk.
        /// </summary>
        /// <param name="source">Source video file.</param>
        /// <param name="output">Output audio file.</param>
        /// <returns>Success state.</returns>
        public FileInfo ExtractAudio(VideoInfo source, FileInfo output)
        {
            FFMpegHelper.ConversionExceptionCheck(source.ToFileInfo(), output);
            FFMpegHelper.ExtensionExceptionCheck(output, FileExtension.Mp3);

            var args = ArgumentsStringifier.Input(source) +
                       ArgumentsStringifier.Disable(Channel.Video) +
                       ArgumentsStringifier.Output(output);

            if (!RunProcess(args, output))
            {
                throw new FFMpegException(FFMpegExceptionType.Operation, "Could not extract the audio from the requested video.");
            }

            output.Refresh();

            return(output);
        }
示例#2
0
        /// <summary>
        ///     Strips a video file of audio.
        /// </summary>
        /// <param name="source">Source video file.</param>
        /// <param name="output">Output video file.</param>
        /// <returns></returns>
        public VideoInfo Mute(VideoInfo source, FileInfo output)
        {
            FFMpegHelper.ConversionExceptionCheck(source.ToFileInfo(), output);
            FFMpegHelper.ConversionSizeExceptionCheck(source);
            FFMpegHelper.ExtensionExceptionCheck(output, source.Extension);

            var args = ArgumentsStringifier.Input(source) +
                       ArgumentsStringifier.Copy() +
                       ArgumentsStringifier.Disable(Channel.Audio) +
                       ArgumentsStringifier.Output(output);

            if (!RunProcess(args, output))
            {
                throw new FFMpegException(FFMpegExceptionType.Operation, "Could not mute the requested video.");
            }

            return(new VideoInfo(output));
        }