【发布时间】:2021-03-22 13:23:03
【问题描述】:
考虑以下sn-p:(来自https://ffmpeg.org/doxygen/trunk/encode_audio_8c-example.html)
for (i = 0; i < 200; i++) {
/* make sure the frame is writable -- makes a copy if the encoder
* kept a reference internally */
ret = av_frame_make_writable(frame);
if (ret < 0)
exit(1);
samples = (uint16_t*)frame->data[0];
for (j = 0; j < c->frame_size; j++) {
samples[2*j] = (int)(sin(t) * 10000);
for (k = 1; k < c->channels; k++)
samples[2*j + k] = samples[2*j];
t += tincr;
}
encode(c, frame, pkt, f);
}
如果我正确理解了这个例子,生成的音频流正好包含 200 个大小为 c->frame_size 的帧,这些帧经过编码并保存到磁盘。
但是,如果我想编码大小为soundsize 的通用数据流,我将有一定数量的固定大小的帧c->frame_size,即size_t nframes = soundsize / c->frame_size;加上最后一帧大小: size_t rem_lastframe = soundsize % c->frame_size;
你能解释一下如何处理最后一帧吗? frame_size 似乎是由编解码器固定和选择的。
【问题讨论】:
标签: ffmpeg