protected override string ConstructModifyArgs(FileInfo source, FileInfo output, AudioUtilityRequest request) { string codec; // we're going to assume that the bytes are always signed and in little endian order // since this conversion is basically for working with byte-only files there's no way to check // https://trac.ffmpeg.org/wiki/audio%20types // DE s16le PCM signed 16 - bit little - endian // DE s24le PCM signed 24 - bit little - endian // DE s32le PCM signed 32 - bit little - endian // DE s8 PCM signed 8 - bit // DE u8 PCM unsigned 8 - bit switch (request.BitDepth) { case 8: // only 8-bit wav is unsigned codec = "u8"; break; case 16: codec = "s16le"; break; case 24: codec = "s24le"; break; case 32: codec = "s32le"; break; default: throw new NotSupportedException(); } var args = new StringBuilder(FfmpegAudioUtility.ArgsOverwrite); // input format args.Append($" -f {codec}"); args.Append($" -ar {request.TargetSampleRate.Value}"); args.Append($" -ac {request.Channels.Length}"); args.Append(FfmpegAudioUtility.ArgsSource.Format2(source.FullName)); if (request.MixDownToMono == true) { args.AppendFormat(FfmpegAudioUtility.ArgsChannelCount, 1); } FfmpegAudioUtility.FormatFfmpegOffsetArgs(request, args); // output codec args.Append($" -acodec pcm_{codec}"); args.Append($" \"{output.FullName}\" "); return(args.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="MasterAudioUtility"/> class. /// Creates a new audio utility that can be used to convert and segment audio, and to get information about audio. /// </summary> public MasterAudioUtility() { this.wvunpackUtility = AppConfigHelper.WvunpackExe != null ? new WavPackAudioUtility(AppConfigHelper.WvunpackExe.ToFileInfo()) : null; this.ffmpegUtility = new FfmpegAudioUtility(new FileInfo(AppConfigHelper.FfmpegExe), new FileInfo(AppConfigHelper.FfprobeExe)); this.ffmpegRawPcmUtility = new FfmpegRawPcmAudioUtility(new FileInfo(AppConfigHelper.FfmpegExe)); this.soxUtility = new SoxAudioUtility(new FileInfo(AppConfigHelper.SoxExe)); this.TemporaryFilesDirectory ??= TempFileHelper.TempDir(); this.Validate(); }
/// <summary> /// Initializes a new instance of the <see cref="MasterAudioUtility"/> class. /// Creates a new audio utility that can be used to convert and segment audio, and to get information about audio. /// The given audio utility instances will be used. /// </summary> /// <param name="ffmpegUtility">ffmpeg utility. /// </param> /// <param name="wvunpackUtility">wxunpack utility. /// </param> /// <param name="soxUtility">sox utility. /// </param> /// <param name="ffmpegRawPcmUtility">The ffmpeg utility for converting raw PCM data.</param> /// <param name="temporaryFilesDirectory">Directory for temporary files.</param> public MasterAudioUtility( FfmpegAudioUtility ffmpegUtility, WavPackAudioUtility wvunpackUtility, SoxAudioUtility soxUtility, FfmpegRawPcmAudioUtility ffmpegRawPcmUtility, DirectoryInfo temporaryFilesDirectory = null) { this.wvunpackUtility = wvunpackUtility; this.ffmpegUtility = ffmpegUtility; this.ffmpegRawPcmUtility = ffmpegRawPcmUtility; this.soxUtility = soxUtility; this.TemporaryFilesDirectory = temporaryFilesDirectory ?? TempFileHelper.TempDir(); this.Validate(); }
/// <summary> /// Initializes a new instance of the <see cref="MasterAudioUtility"/> class. /// Creates a new audio utility that can be used to convert and segment audio, and to get information about audio. /// </summary> public MasterAudioUtility() { this.wvunpackUtility = new WavPackAudioUtility(new FileInfo(AppConfigHelper.WvunpackExe)); var mp3SpltExe = AppConfigHelper.Mp3SpltExe; if (mp3SpltExe != null) { this.mp3SpltUtility = new Mp3SpltAudioUtility(new FileInfo(mp3SpltExe)); } this.ffmpegUtility = new FfmpegAudioUtility(new FileInfo(AppConfigHelper.FfmpegExe), new FileInfo(AppConfigHelper.FfprobeExe)); this.ffmpegRawPcmUtility = new FfmpegRawPcmAudioUtility(new FileInfo(AppConfigHelper.FfmpegExe)); this.soxUtility = new SoxAudioUtility(new FileInfo(AppConfigHelper.SoxExe)); this.TemporaryFilesDirectory = this.TemporaryFilesDirectory ?? TempFileHelper.TempDir(); this.Validate(); }