Skip to content

Commit

Permalink
fix negative subtitle delay (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiayang committed Dec 3, 2020
1 parent c38fe15 commit 4b262b7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions source/muxing/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,18 @@ namespace mux
{
// this is the subtitle delay.
auto delay = subtitleDelay;
auto pts_delay = (delay * ostrm->time_base.den) / ostrm->time_base.num;
pkt->pts += pts_delay;

auto ts_delay = (delay * ostrm->time_base.den) / ostrm->time_base.num;
pkt->pts += ts_delay;

// note: we must also change the dts if the delay was negative, because
// obviously the packet must be decoded before it can be presented. if
// the delay was positive, this doesn't matter.
if(subtitleDelay < 0)
{
while(pkt->dts > pkt->pts)
pkt->dts += ts_delay; // it's already negative, so add it.
}
}

if(pkt->dts == AV_NOPTS_VALUE)
Expand Down

0 comments on commit 4b262b7

Please sign in to comment.