核心音频指定要解码的音轨
Core Audio specify which audio track to decode
我能够使用Core Audio API成功获取音频文件的解码PCM数据。以下是还原代码,该代码显示了我如何做:
CFStringRef urlStr = CFStringCreateWithCString(kCFAllocatorDefault, "file.m4a", kCFStringEncodingUTF8);
CFURLRef urlRef = CFURLCreateWithFileSystemPath(NULL, urlStr, kCFURLPOSIXPathStyle, false);
ExtAudioFileOpenURL(urlRef, &m_audioFile);
bzero(&m_outputFormat, sizeof(AudioStreamBasicDescription));
m_outputFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;
m_outputFormat.mSampleRate = m_inputFormat.mSampleRate;
m_outputFormat.mFormatID = kAudioFormatLinearPCM;
m_outputFormat.mChannelsPerFrame = m_inputFormat.mChannelsPerFrame;
m_outputFormat.mBytesPerFrame = sizeof(short) * m_outputFormat.mChannelsPerFrame;
m_outputFormat.mBitsPerChannel = sizeof(short) * 8;
m_outputFormat.mFramesPerPacket = 1;
m_outputFormat.mBytesPerPacket = m_outputFormat.mBytesPerFrame * m_outputFormat.mFramesPerPacket;
ExtAudioFileSetProperty(m_audioFile, kExtAudioFileProperty_ClientDataFormat, sizeof(m_outputFormat), &m_outputFormat)
short* transformData = new short[sampleCount];
AudioBufferList fillBufList;
fillBufList.mNumberBuffers = 1;
fillBufList.mBuffers[0].mNumberChannels = channels;
fillBufList.mBuffers[0].mDataByteSize = m_sampleCount * sizeof(short);
fillBufList.mBuffers[0].mData = (void*)(&transformData[0]);
ExtAudioFileRead(m_audioFile, &m_frameCount, &fillBufList);
我对感兴趣,如何指定我要解码的音轨(假设媒体文件包含多个)?
一种方法是将所有轨道解码,然后将所需的曲目数据(复制)数据(用于交错的立体声等)中提取到另一个缓冲区,数组或文件中。与解码时间相比,额外的复制时间微不足道。
相关文章:
- 无法解码base64+deflate数据
- 正在解码MSVC 32位版本的程序集(作业).没有手术做什么
- 使用已使用 java 编码的 openssl 解码数据
- 如何使用 OpenCV 解码在两个 UWP 应用之间发送的图像字节?
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- 从原始字节解码协议缓冲区(以 C++为单位)
- FFmpeg——使用硬件加速进行视频解码
- 如何从WIC解码器确定自上而下/自下而上?
- 如何正确声明变音字母的char8_t?
- 使用公钥加密消息:BER 解码错误
- 在CRC-16 CCITT中将数据从二进制解码为文本,我应该输入一个码字,使用CRC生成器进行编码
- 在 GLFW 窗口中显示 FFMPEG 解码帧
- 如何将 MJPEG 解码为原始 RGB(或 YUV)数据
- 编译时 Base64 解码 C++
- 使用超强音频套件在音轨之间正确过渡
- 核心音频指定要解码的音轨
- 获取音轨的编码
- 如何在音轨中找到无声部分
- 如何在c++中使用ffmpeg动态更改视频的音轨
- 如何从 mac os x 上通过 USB 连接的多轨混音器获取输入