diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 3d62003872..0186c4f068 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4721,7 +4721,10 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt) // duration, but only helps for this particular track, not // for the other ones that are flushed at the same time. trk->track_duration = pkt->dts - trk->start_dts; - trk->end_pts = pkt->pts; + if (pkt->pts != AV_NOPTS_VALUE) + trk->end_pts = pkt->pts; + else + trk->end_pts = pkt->dts; mov_auto_flush_fragment(s, 0); } }