[英]Using NAudio, ADTS AAC to WAV Transcoding, how to?
I am attempting to implement the following code which I found here 我正在尝试实现在这里找到的以下代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Media;
using NAudio.Wave;
namespace AAC2WAV
{
class Program
{
static void Main(string[] args)
{
// create media foundation reader to read the AAC encoded file
using (MediaFoundationReader reader = new MediaFoundationReader(args[0]))
// resample the file to PCM with same sample rate, channels and bits per sample
using (ResamplerDmoStream resampledReader = new ResamplerDmoStream(reader,
new WaveFormat(reader.WaveFormat.SampleRate, reader.WaveFormat.BitsPerSample, reader.WaveFormat.Channels)))
// create WAVe file
using (WaveFileWriter waveWriter = new WaveFileWriter(args[1], resampledReader.WaveFormat))
{
// copy samples
resampledReader.CopyTo(waveWriter);
}
}
}
}
Input file is *.aac (args[0]) output file should be *.wav (args[ 1 ]). 输入文件为* .aac(args [0]),输出文件应为* .wav(args [1])。 I am running the complied code as a console application and I get no errors, however it just seems to hang once it creates the wav file with 0 KB size 我正在将编译后的代码作为控制台应用程序运行,但没有收到任何错误,但是,一旦它创建了大小为0 KB的wav文件,它似乎就挂起了
I'm wondering is there there is something I am missing or perhaps something I need to further understand. 我想知道是否有某些我想念的东西,或者我需要进一步了解的东西。
Windows is reporting the *.aac files as ADTS. Windows将* .aac文件报告为ADTS。
Perhaps it is that I need to extract and rewrite the header, but I am not familiar with AAC at all so would seek some guidance on that aspect if deemed necessary. 也许是我需要提取并重写标头,但是我完全不熟悉AAC,因此如果认为有必要,可以在这方面寻求一些指导。
When I try to open the file with WMP it says it cannot connect to the server (suggests codec issue) , however I can convert it with FFMPEG to a wav file without any trouble. 当我尝试使用WMP打开文件时,它说它无法连接到服务器(建议编解码器问题) ,但是我可以使用FFMPEG将其转换为wav文件而没有任何麻烦。 Using FFMPEG is not ideal for the particular implementation I am looking at. 对于我正在查看的特定实现,使用FFMPEG并不理想。
Any assistance would be greatly appreciated. 任何帮助将不胜感激。
Info on the actual file: 实际文件上的信息:
General
Complete name : C:\Users\....\AAC2WAV\bin\Debug\0cc409aa-f66c-457a-ac10-6286509ec409.aac
Format : ADIF
Format/Info : Audio Data Interchange Format
File size : 180 KiB
Overall bit rate mode : Constant
Audio
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : Main
Bit rate mode : Constant
Channel(s) : 14 channels
Channel positions : , Back: 14
Sampling rate : 96.0 kHz
Frame rate : 93.750 FPS (1024 spf)
Compression mode : Lossy
Stream size : 180 KiB (100%)
Information gathered from file using: MediaInfo 使用以下方法从文件收集的信息: MediaInfo
I should add here that the lower section of the above info is incorrect I believe. 我应该在这里补充说明,我认为上述信息的下部是错误的。 The sample rate is not 96k it is 22050 and there is only 1 channel 采样率不是96k,而是22050,只有1个通道
You don't need the resampler - MediaFoundationReader
already returns PCM. 您不需要重新采样器MediaFoundationReader
已经返回PCM。 You should also use WaveFileWriter.CreateWaveFile
您还应该使用WaveFileWriter.CreateWaveFile
This should be all you need: 这应该是您所需要的:
using (var reader = new MediaFoundationReader("myfile.aac"))
{
WaveFileWriter.CreateWaveFile("pcm.wav", reader);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.