#6368 closed defect (fixed)
audio_preload broken
| Reported by: | Alex | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avformat |
| Version: | git-master | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
When audio_preload option is set output media stream a/v interleaving is broken because of "wrong sign issue" in interleave_compare_dts.
I'm willing to provide patch solving this issue and also enabling audio stream shift in both directions (currently audio_preload is 0-int_max).
Probably audio_preload can be renamed to something like audio_shift? (it seems no one uses audio_preload option because of this issue)
libavformat/mux.c: (master branch)
static int interleave_compare_dts(AVFormatContext *s, AVPacket *next,
AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
AVStream *st2 = s->streams[next->stream_index];
int comp = av_compare_ts(next->dts, st2->time_base, pkt->dts,
st->time_base);
if (s->audio_preload && ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) != (st2->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))) {
int64_t ts = av_rescale_q(pkt ->dts, st ->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st ->codecpar->codec_type == AVMEDIA_TYPE_AUDIO);
int64_t ts2= av_rescale_q(next->dts, st2->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st2->codecpar->codec_type == AVMEDIA_TYPE_AUDIO);
if (ts == ts2) {
ts= ( pkt ->dts* st->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st ->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)* st->time_base.den)*st2->time_base.den
-( next->dts*st2->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st2->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)*st2->time_base.den)* st->time_base.den;
ts2=0;
}
comp= (ts>ts2) - (ts<ts2); ///////// there should be (ts2>ts) - (ts2<ts) obviously
}
if (comp == 0)
return pkt->stream_index < next->stream_index;
return comp > 0;
}
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 5 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Fixed in 1889e3166cc5780780d7f40ac2271e5308f32b8e.
comment:3 by , 5 years ago
| Keywords: | audio_preload removed |
|---|
Note:
See TracTickets
for help on using tickets.



Please either explain how to reproduce the issue or send a patch made with
git format-patchto the FFmpeg development mailing list where patches are reviewed.