简体   繁体   English

ffmpeg-用音频样本填充音频帧

[英]ffmpeg - Fill audio frame with audio sample

I'm trying to encode an audio stream to a file. 我正在尝试将音频流编码为文件。 I'm receiving the audio buffers and using avcodec_fill_audio_frame to create an AVFrame and send it to avcodec_encode_audio2 (with some other thing in between - I`m using ffmpeg muxing.c as an example) 我正在接收音频缓冲区,并使用avcodec_fill_audio_frame创建一个AVFrame并将其发送到avcodec_encode_audio2 (介于两者之间-我使用ffmpeg muxing.c作为示例)

The thing is: The audio buffer I'm getting contains 480 samples, the codec I'm using has a frame_size of 1152 (MP2). 问题是:我正在获取的音频缓冲区包含480个样本,我正在使用的编解码器的frame_size为1152(MP2)。 The result is that the output audio file is kinda "chopped". 结果是输出音频文件被“切碎”了。 It sounds like every audio frame has some silent samples in the end. 听起来每个音频帧最后都有一些静音样本。

How can I fix this? 我怎样才能解决这个问题? Thanks!! 谢谢!!

You must fill the AVFrame with up to frame_size (1152 in your case) samples before you pass the frame to avcodec_encode_audio2 . 您必须填写AVFrame高达frame_size (在你的情况下,1152)样本,通过帧之前avcodec_encode_audio2

It sounds like your frame is too small. 听起来您的相框太小。 How are you setting it up? 您如何设置? Can you show some code? 你能显示一些代码吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM