[vlc-commits] avcodec: Set time_base for audio encoders, too

Martin Storsjö git at videolan.org
Fri Jan 27 01:17:20 CET 2012


vlc/vlc-2.0 | branch: master | Martin Storsjö <martin at martin.st> | Thu Jan 26 21:59:57 2012 +0200| [caf2a08a0507ab9e9ae34038854f3f218e820581] | committer: Jean-Baptiste Kempf

avcodec: Set time_base for audio encoders, too

This is required when encoding audio in libav 0.8, otherwise
it will crash due to a division by zero.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 25fc1243b81a46a100e37db5ec477bd5096b979a)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=caf2a08a0507ab9e9ae34038854f3f218e820581
---

 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;
 



More information about the vlc-commits mailing list