[vlc-devel] [PATCH] avcodec: Set time_base for audio encoders, too
Martin Storsjö
martin at martin.st
Thu Jan 26 20:59:57 CET 2012
This is required when encoding audio in libav 0.8, otherwise
it will crash due to a division by zero.
---
A patch for fixing it in libav has been sent, but it might be
a good idea nevertheless to set time_base, to fix usage with
the 0.8 release.
modules/codec/avcodec/encoder.c | 2 ++
modules/stream_out/switcher.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 92c701e..e036a09 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -607,6 +607,8 @@ int OpenEncoder( vlc_object_t *p_this )
SAMPLE_FMT_S16;
p_enc->fmt_in.i_codec = VLC_CODEC_S16N;
p_context->sample_rate = p_enc->fmt_out.audio.i_rate;
+ p_context->time_base.num = 1;
+ p_context->time_base.den = p_context->sample_rate;
p_context->channels = p_enc->fmt_out.audio.i_channels;
if ( p_enc->fmt_out.i_codec == VLC_CODEC_MP4A )
diff --git a/modules/stream_out/switcher.c b/modules/stream_out/switcher.c
index 2732086..372eef8 100644
--- a/modules/stream_out/switcher.c
+++ b/modules/stream_out/switcher.c
@@ -382,6 +382,8 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
}
id->ff_enc_c->sample_rate = p_fmt->audio.i_rate;
+ id->ff_enc_c->time_base.num = 1;
+ id->ff_enc_c->time_base.den = p_fmt->audio.i_rate;
id->ff_enc_c->channels = p_fmt->audio.i_channels;
id->ff_enc_c->bit_rate = p_fmt->i_bitrate;
--
1.7.2.5
More information about the vlc-devel
mailing list