获取具有FFMPEG样品的总数
Obtain the total number of samples with FFMpeg
当前我的应用程序基于while-realloc循环读取音频文件:
// Pseudocode
float data* = nullptr;
int size = 0;
AVFrame* frame;
while(readFrame(formatContext, frame))
{
data = realloc(data, size + frame.nSamples);
size += frame.nSamples;
/* Read frame samples into data */
}
有没有办法在开始时获得流中的样本总数?我希望能够用new[]
而不是malloc
创建数组。
供参考,此处回答:FFMPEG:如何估计音频流中的样本数?
我在代码中使用了以下内容:
int total_samples = (int) ((format_context->duration / (float) AV_TIME_BASE) * SAMPLE_RATE * NUMBER_CHANNELS);
注意:我的测试表明,此计算很可能大于实际的样本数量,因此请确保您在代码中补偿了该样本。我将所有剩余的" Unset"样本设置为零。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 使用指针从C++中的数组中获取最大值
- 如何获取std::result_of函数的返回类型
- 如何在openssl-ecc中获取十六进制格式的私钥
- 使用Unreal C++获取VR耳机的世界位置/方向
- 如何在 c++ 中使用 ffmpeg 获取 DirectShow 设备列表?
- 如何使用ffmpeg获取歌词
- 如何使用C 中的FFMPEG获取视频fps
- 如何使用FFMPEG使用DXVA2来解码并获取框架
- 获取具有FFMPEG样品的总数
- ffmpeg,C++-在程序中获取fps
- 使用FFmpeg解码视频帧时获取的撕裂图像
- FFmpeg - 如何获取打开 ALAC 编解码器所需的额外数据
- 如何从FFMPEG获取文件描述符
- 从AVPicture中获取RGB值,并在FFMPEG中更改为灰度
- 获取ffmpeg格式的帧时间
- 如何从ffmpeg打开的文件中获取流信息
- 如何获取 ffmpeg 中可用的所有编解码器的列表