/// <summary> /// The prepare file. /// </summary> /// <param name="request"> /// The request. /// </param> public static AudioUtilityModifiedInfo PrepareFile(FileInfo sourceFile, FileInfo outputFile, AudioUtilityRequest request, DirectoryInfo temporaryFilesDirectory) { var audioUtility = new MasterAudioUtility(temporaryFilesDirectory); var sourceMimeType = MediaTypes.GetMediaType(sourceFile.Extension); var outputMimeType = MediaTypes.GetMediaType(outputFile.Extension); string outputDirectory = Path.GetDirectoryName(outputFile.FullName); if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } audioUtility.Modify( sourceFile, sourceMimeType, outputFile, outputMimeType, request); var result = new AudioUtilityModifiedInfo { TargetInfo = audioUtility.Info(outputFile), SourceInfo = audioUtility.Info(sourceFile), }; return(result); }
public void MasterAudioUtilityCheckRequestValidFailsWhenWavpackIsMissing() { var utility = new MasterAudioUtility( (FfmpegAudioUtility)TestHelper.GetAudioUtilityFfmpeg(), null, (SoxAudioUtility)TestHelper.GetAudioUtilitySox(), (FfmpegRawPcmAudioUtility)TestHelper.GetAudioUtilityFfmpegRawPcm()); var source = PathHelper.GetTestAudioFile("Raw_audio_id_cd6e8ba1-11b4-4724-9562-f6ec893110aa.wv"); Assert.ThrowsException <AudioFormatNotSupportedException>( () => utility.Info(source), "Converting from WavPack is not supported because we cannot find a wvunpack binary."); Assert.ThrowsException <AudioFormatNotSupportedException>( () => utility.Modify(source, MediaTypes.MediaTypeWavpack, PathHelper.GetTempFile(MediaTypes.ExtWav), MediaTypes.MediaTypeWav, new AudioUtilityRequest()), "Converting from WavPack is not supported because we cannot find a wvunpack binary."); }
public void MasterAudioUtilityAllowsOptionalSupportForMp3splt() { // creation should normally fail but MasterAudioUtility was changed so that Mp3Splt was optional var utility = new MasterAudioUtility( (FfmpegAudioUtility)TestHelper.GetAudioUtilityFfmpeg(), null, //(Mp3SpltAudioUtility)TestHelper.GetAudioUtilityMp3Splt(), (WavPackAudioUtility)TestHelper.GetAudioUtilityWavunpack(), (SoxAudioUtility)TestHelper.GetAudioUtilitySox(), (FfmpegRawPcmAudioUtility)TestHelper.GetAudioUtilityFfmpegRawPcm()); // but it throws an exception if we try and segment a mp3 TestHelper.ExceptionMatches <NotSupportedException>( () => utility.Modify( PathHelper.GetTestAudioFile("Currawongs_curlew_West_Knoll_Bees_20091102-183000.mp3"), MediaTypes.MediaTypeMp3, TempFileHelper.NewTempFile(), MediaTypes.MediaTypeWav, new AudioUtilityRequest()), "MP3 conversion not supported because mp3splt utility has not been configured"); }