#include <unistd.h>
#endif
+#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
+#include "libavutil/rational.h"
#include "libavutil/time_internal.h"
#include "avc.h"
const char *single_file_name;
const char *init_seg_name;
const char *media_seg_name;
+ AVRational min_frame_rate, max_frame_rate;
+ int ambiguous_frame_rate;
} DASHContext;
static int dash_write(void *opaque, uint8_t *buf, int buf_size)
}
if (c->has_video) {
- avio_printf(out, "\t\t<AdaptationSet contentType=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">\n");
+ avio_printf(out, "\t\t<AdaptationSet contentType=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"");
+ if (c->max_frame_rate.num && !c->ambiguous_frame_rate)
+ avio_printf(out, " %s=\"%d/%d\"", (av_cmp_q(c->min_frame_rate, c->max_frame_rate) < 0) ? "maxFrameRate" : "frameRate", c->max_frame_rate.num, c->max_frame_rate.den);
+ avio_printf(out, ">\n");
+
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
OutputStream *os = &c->streams[i];
if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
- avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height);
+ avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\"", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height);
+ if (st->avg_frame_rate.num)
+ avio_printf(out, " frameRate=\"%d/%d\"", st->avg_frame_rate.num, st->avg_frame_rate.den);
+ avio_printf(out, ">\n");
+
output_segment_list(&c->streams[i], out, c);
avio_printf(out, "\t\t\t</Representation>\n");
}
c->single_file = 1;
if (c->single_file)
c->use_template = 0;
+ c->ambiguous_frame_rate = 0;
av_strlcpy(c->dirname, s->filename, sizeof(c->dirname));
ptr = strrchr(c->dirname, '/');
// already before being handed to this muxer, so we don't have mismatches
// between the MPD and the actual segments.
s->avoid_negative_ts = ctx->avoid_negative_ts;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ AVRational avg_frame_rate = s->streams[i]->avg_frame_rate;
+ if (avg_frame_rate.num > 0) {
+ if (av_cmp_q(avg_frame_rate, c->min_frame_rate) < 0)
+ c->min_frame_rate = avg_frame_rate;
+ if (av_cmp_q(c->max_frame_rate, avg_frame_rate) < 0)
+ c->max_frame_rate = avg_frame_rate;
+ } else {
+ c->ambiguous_frame_rate = 1;
+ }
c->has_video = 1;
- else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
c->has_audio = 1;
+ }
set_codec_str(s, st->codec, os->codec_str, sizeof(os->codec_str));
os->first_pts = AV_NOPTS_VALUE;