Commit 24a64e04 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Paul B Mahol

lavf/webm_chunk: Correct duration if start time > 0

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: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
parent 8c6ee762
...@@ -52,7 +52,7 @@ typedef struct WebMChunkContext { ...@@ -52,7 +52,7 @@ typedef struct WebMChunkContext {
int chunk_index; int chunk_index;
char *http_method; char *http_method;
uint64_t duration_written; uint64_t duration_written;
int prev_pts; int64_t prev_pts;
ff_const59 AVOutputFormat *oformat; ff_const59 AVOutputFormat *oformat;
AVFormatContext *avf; AVFormatContext *avf;
} WebMChunkContext; } WebMChunkContext;
...@@ -129,6 +129,7 @@ static int webm_chunk_write_header(AVFormatContext *s) ...@@ -129,6 +129,7 @@ static int webm_chunk_write_header(AVFormatContext *s)
wc->oformat = av_guess_format("webm", s->url, "video/webm"); wc->oformat = av_guess_format("webm", s->url, "video/webm");
if (!wc->oformat) if (!wc->oformat)
return AVERROR_MUXER_NOT_FOUND; return AVERROR_MUXER_NOT_FOUND;
wc->prev_pts = AV_NOPTS_VALUE;
ret = chunk_mux_init(s); ret = chunk_mux_init(s);
if (ret < 0) if (ret < 0)
...@@ -216,9 +217,10 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -216,9 +217,10 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret; int ret;
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts, if (wc->prev_pts != AV_NOPTS_VALUE)
st->time_base, wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts,
(AVRational) {1, 1000}); st->time_base,
(AVRational) {1, 1000});
wc->prev_pts = pkt->pts; wc->prev_pts = pkt->pts;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment