[FFmpeg-devel] [PATCH] wrong time base for audio in AVI

Reimar Döffinger Reimar.Doeffinger
Sat Apr 12 18:35:36 CEST 2008

currently ffplay currently fails playing e.g.
"http://samples.mplayerhq.hu/amv/Shakira - Hips Don't Lie.amv"
> ffplay: libavformat/utils.c:640: update_initial_durations: Assertion `pkt->duration && !st->cur_dts' failed.
This problem seems to be because the time base of the audio stream is
set to 1/10 based on the frame rate instead of 1/sample_rate and thus
the packet duration after av_rescale in compute_pkt_fields in
utils.c:669 becomes 0.
Attached patch is one possible way to fix this.

Reimar D?ffinger
-------------- next part --------------
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 0d02f02..7926a46 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -494,6 +494,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
                         av_log(s, AV_LOG_WARNING, "sample size (%d) != block align (%d)\n", ast->sample_size, st->codec->block_align);
                         ast->sample_size= st->codec->block_align;
+                    if (st->codec->sample_rate)
+                        av_set_pts_info(st, 64, 1, st->codec->sample_rate);
                     if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
                         url_fskip(pb, 1);
                     /* Force parsing as several audio frames can be in

More information about the ffmpeg-devel mailing list