summaryrefslogtreecommitdiff
path: root/libavformat/rmenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-11-15 16:48:59 +0100
committerAnton Khirnov <anton@khirnov.net>2015-12-12 21:19:08 +0100
commit1f008f34d5b2b5f6217521747e7acfe3efc0e666 (patch)
treef7387b8a95cdd2b688470b5f77d9cac63a68a89a /libavformat/rmenc.c
parent458e53f51fc75d08df884f8e9eb3d7ded23e97b3 (diff)
rmenc: do not use AVCodecContext.frame_size
It will not be set if the stream codec context is not the encoding context. Use av_get_audio_frame_duration() instead, it should work for all audio codecs supported by the muxer.
Diffstat (limited to 'libavformat/rmenc.c')
-rw-r--r--libavformat/rmenc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index ad2c17d529..bbfd550a3b 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -185,9 +185,10 @@ static int rv10_write_header(AVFormatContext *ctx,
if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
int coded_frame_size, fscode, sample_rate;
+ int frame_size = av_get_audio_frame_duration(stream->enc, 0);
sample_rate = stream->enc->sample_rate;
coded_frame_size = (stream->enc->bit_rate *
- stream->enc->frame_size) / (8 * sample_rate);
+ frame_size) / (8 * sample_rate);
/* audio codec info */
avio_write(s, ".ra", 3);
avio_w8(s, 0xfd);
@@ -315,6 +316,7 @@ static int rm_write_header(AVFormatContext *s)
for(n=0;n<s->nb_streams;n++) {
AVStream *st = s->streams[n];
+ int frame_size;
s->streams[n]->id = n;
codec = s->streams[n]->codec;
@@ -327,7 +329,8 @@ static int rm_write_header(AVFormatContext *s)
switch(codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
rm->audio_stream = stream;
- stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size;
+ frame_size = av_get_audio_frame_duration(codec, 0);
+ stream->frame_rate = (float)codec->sample_rate / (float)frame_size;
/* XXX: dummy values */
stream->packet_max_size = 1024;
stream->nb_packets = 0;