|
@@ -1267,6 +1267,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
DASHContext *c = s->priv_data; |
|
|
DASHContext *c = s->priv_data; |
|
|
AVStream *st = s->streams[pkt->stream_index]; |
|
|
AVStream *st = s->streams[pkt->stream_index]; |
|
|
OutputStream *os = &c->streams[pkt->stream_index]; |
|
|
OutputStream *os = &c->streams[pkt->stream_index]; |
|
|
|
|
|
int64_t seg_end_duration, elapsed_duration; |
|
|
int ret; |
|
|
int ret; |
|
|
|
|
|
|
|
|
ret = update_stream_extradata(s, os, st->codecpar); |
|
|
ret = update_stream_extradata(s, os, st->codecpar); |
|
@@ -1294,10 +1295,18 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
if (os->first_pts == AV_NOPTS_VALUE) |
|
|
if (os->first_pts == AV_NOPTS_VALUE) |
|
|
os->first_pts = pkt->pts; |
|
|
os->first_pts = pkt->pts; |
|
|
|
|
|
|
|
|
|
|
|
if (c->use_template && !c->use_timeline) { |
|
|
|
|
|
elapsed_duration = pkt->pts - os->first_pts; |
|
|
|
|
|
seg_end_duration = (int64_t) os->segment_index * c->seg_duration; |
|
|
|
|
|
} else { |
|
|
|
|
|
elapsed_duration = pkt->pts - os->start_pts; |
|
|
|
|
|
seg_end_duration = c->seg_duration; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && |
|
|
if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && |
|
|
pkt->flags & AV_PKT_FLAG_KEY && os->packets_written && |
|
|
pkt->flags & AV_PKT_FLAG_KEY && os->packets_written && |
|
|
av_compare_ts(pkt->pts - os->start_pts, st->time_base, |
|
|
|
|
|
c->seg_duration, AV_TIME_BASE_Q) >= 0) { |
|
|
|
|
|
|
|
|
av_compare_ts(elapsed_duration, st->time_base, |
|
|
|
|
|
seg_end_duration, AV_TIME_BASE_Q) >= 0) { |
|
|
int64_t prev_duration = c->last_duration; |
|
|
int64_t prev_duration = c->last_duration; |
|
|
|
|
|
|
|
|
c->last_duration = av_rescale_q(pkt->pts - os->start_pts, |
|
|
c->last_duration = av_rescale_q(pkt->pts - os->start_pts, |
|
|