Up until now, it was simply presumed that the first packet had a pts of zero; otherwise the duration of the first chunk was wrong.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@googlemail.com> --- libavformat/webm_chunk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 391fee721a..d45ebfb1e5 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -52,7 +52,7 @@ typedef struct WebMChunkContext { int chunk_index; char *http_method; uint64_t duration_written; - int prev_pts; + int64_t prev_pts; ff_const59 AVOutputFormat *oformat; AVFormatContext *avf; } WebMChunkContext; @@ -124,6 +124,7 @@ static int webm_chunk_write_header(AVFormatContext *s) wc->oformat = av_guess_format("webm", s->url, "video/webm"); if (!wc->oformat) return AVERROR_MUXER_NOT_FOUND; + wc->prev_pts = AV_NOPTS_VALUE; ret = chunk_mux_init(s); if (ret < 0) @@ -211,9 +212,10 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt) int ret; if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { - wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts, - st->time_base, - (AVRational) {1, 1000}); + if (wc->prev_pts != AV_NOPTS_VALUE) + wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts, + st->time_base, + (AVRational) {1, 1000}); wc->prev_pts = pkt->pts; } -- 2.19.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".