Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Created Unassigned: Exception When Calling MediaFoundationEncoder.EncodeToWma [16406]

$
0
0
I have been trying to use the new media foundation facilities in NAudio version 1.7 pre release (downloaded 2013-08-05 @ 15:20 UTC) and have come across the following issue. I am writing a program called TelephoneTrack which needs to convert a recorded WAV file into either a M4A or WMA file. In my code when I call my routine ConvertWAVToM4A routine it works but when I call the ConvertWAVToWMA it fails.

I know this is pre-release but I thought you would like to know about this issue. NAudio is an excellent library by the way and I am very impressed with your efforts so far with the media foundation add-on.

```
public static void ConvertWAVToM4A(string outputFile, string inputFile)
{
FileInfo fileInfo = new FileInfo(outputFile);
if (fileInfo.Extension.ToUpper() != ".M4A")
{
fileInfo = new FileInfo(outputFile + ".m4a");
}

if (fileInfo.Exists)
{
fileInfo.Delete();
}

using (var reader = new MediaFoundationReader(inputFile))
{
MediaFoundationEncoder.EncodeToAac(reader, fileInfo.FullName, 192000);
}
}


public static void ConvertWAVToWMA(string outputFile, string inputFile)
{

FileInfo fileInfo = new FileInfo(outputFile);
if (fileInfo.Extension.ToUpper() != ".WMA")
{
fileInfo = new FileInfo(outputFile + ".wma");
}

if (fileInfo.Exists)
{
fileInfo.Delete();
}

using (var reader = new MediaFoundationReader(inputFile))
{
MediaFoundationEncoder.EncodeToWma(reader, fileInfo.FullName, 192000);
}
}

```
It throws an exception:

Exception has been thrown by the target of an invocation.

InnerException
Message:Object reference not set to an instance of an object.
Source:NAudio
StackTrace:
at NAudio.Wave.MediaFoundationEncoder.Dispose(Boolean disposing) in c:\SVN\NAudio\NAudio\Wave\WaveOutputs\MediaFoundationEncoder.cs:line 278
at NAudio.Wave.MediaFoundationEncoder.Dispose() in c:\SVN\NAudio\NAudio\Wave\WaveOutputs\MediaFoundationEncoder.cs:line 289
at NAudio.Wave.MediaFoundationEncoder.EncodeToWma(IWaveProvider inputProvider, String outputFile, Int32 desiredBitRate) in c:\SVN\NAudio\NAudio\Wave\WaveOutputs\MediaFoundationEncoder.cs:line 84
at TelephoneTrack.ApplicationCommon.ConvertWAVToWMA(String outputFile, String inputFile) in c:\SVN\TelephoneTrack\TelephoneTrack\ApplicationCommon.cs:line 755
at TelephoneTrack.View.MainView..ctor() in c:\SVN\TelephoneTrack\TelephoneTrack\View\MainView.xaml.cs:line 47

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>