Commit 09585e37 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '30411836'

* commit '30411836':
  dashenc: Heuristically fill in the duration of packets that need it
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 76fef5cd 30411836
......@@ -69,6 +69,7 @@ typedef struct OutputStream {
int nb_segments, segments_size, segment_index;
Segment **segments;
int64_t first_pts, start_pts, max_pts;
int64_t last_dts;
int bit_rate;
char bandwidth_str[64];
......@@ -654,6 +655,7 @@ static int dash_write_header(AVFormatContext *s)
set_codec_str(s, st->codec, os->codec_str, sizeof(os->codec_str));
os->first_pts = AV_NOPTS_VALUE;
os->max_pts = AV_NOPTS_VALUE;
os->last_dts = AV_NOPTS_VALUE;
os->segment_index = 1;
}
......@@ -866,6 +868,16 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0)
return ret;
// Fill in a heuristic guess of the packet duration, if none is available.
// The mp4 muxer will do something similar (for the last packet in a fragment)
// if nothing is set (setting it for the other packets doesn't hurt).
// By setting a nonzero duration here, we can be sure that the mp4 muxer won't
// invoke its heuristic (this doesn't have to be identical to that algorithm),
// so that we know the exact timestamps of fragments.
if (!pkt->duration && os->last_dts != AV_NOPTS_VALUE)
pkt->duration = pkt->dts - os->last_dts;
os->last_dts = pkt->dts;
// If forcing the stream to start at 0, the mp4 muxer will set the start
// timestamps to 0. Do the same here, to avoid mismatches in duration/timestamps.
if (os->first_pts == AV_NOPTS_VALUE &&
......
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