###前提・実現したいこと
NAudioを利用して、mp3ファイルをaacに変換したい。
###発生している問題・エラーメッセージ
encoder.Encode(outputFilenameTextBox.Text, reader)にて以下のエラーが発生。
System.ArgumentException{"値が有効な範囲にありません。"} 値が有効な範囲にありません。 場所 NAudio.MediaFoundation.MediaFoundationInterop.MFCreateSinkWriterFromURL(String pwszOutputURL, IMFByteStream pByteStream, IMFAttributes pAttributes, IMFSinkWriter& ppSinkWriter) 場所 NAudio.Wave.MediaFoundationEncoder.CreateSinkWriter(String outputFile) 場所 NAudio.Wave.MediaFoundationEncoder.Encode(String outputFile, IWaveProvider inputProvider) 場所 naudiotest.Form1.Button3_Click(Object sender, EventArgs e) 場所 E:\work\MSテスト\naudio\naudiotest\naudiotest\Form1.vb:行 25 場所 System.Windows.Forms.Control.OnClick(EventArgs e) 場所 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 場所 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 場所 System.Windows.Forms.Control.WndProc(Message& m) 場所 System.Windows.Forms.ButtonBase.WndProc(Message& m) 場所 System.Windows.Forms.Button.WndProc(Message& m) 場所 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 場所 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 場所 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 場所 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 場所 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 場所 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 場所 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 場所 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() 場所 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) 場所 naudiotest.My.MyApplication.Main(String[] Args) 場所 17d14f5c-a337-4978-8281-53493378c1071.vb:行 81 場所 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 場所 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 場所 System.Threading.ThreadHelper.ThreadStart()
###該当のソースコード
vb
1 Dim reader As New MediaFoundationReader(inputFilenameTextBox.Text) 2 3 4 Dim mediaType = MediaFoundationEncoder.SelectMediaType( 5 NAudio.MediaFoundation.AudioSubtypes.MFAudioFormat_AAC, 6 reader.WaveFormat, 7 reader.WaveFormat.BitsPerSample) 8 Using encoder As New MediaFoundationEncoder(mediaType) 9 encoder.Encode(outputFilenameTextBox.Text, reader) 10 End Using
###試したこと
入力ファイルは、Windows7のおまけのKalimba.mp3を利用
wavファイルの作成は確認済み。
wavからmp3への変換はOSにコーディックをインストールしていないためか、SelectMediaTypeでNothingが返ってきました。
入力をwavにしても同様のエラーが発生します。
###補足情報(言語/FW/ツール等のバージョンなど)
OS:Windows7 64bit
.net framework 3.5
Visual Studio 2012
NAudio 1.8.0.0(https://naudio.codeplex.com/よりダウンロードし手動で参照設定)
参考URL
https://so-zou.jp/software/tech/programming/c-sharp/media/audio/naudio/

あなたの回答
tips
プレビュー