Commit f856d9c2 authored by Martin Storsjö's avatar Martin Storsjö

dashenc: Don't require the stream bitrate to be known

Don't write any bitrate attribute if it isn't known. As long as one
doesn't want automatic bitrate switching, playback can work just
fine even if it isn't set.

If strict standard compliance is requested, this is still considered
an error, since the attribute is mandatory according to the spec.

Based on a patch by Rodger Combs.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent eec7f032
...@@ -59,6 +59,7 @@ typedef struct OutputStream { ...@@ -59,6 +59,7 @@ typedef struct OutputStream {
int nb_segments, segments_size, segment_index; int nb_segments, segments_size, segment_index;
Segment **segments; Segment **segments;
int64_t first_dts, start_dts, end_dts; int64_t first_dts, start_dts, end_dts;
char bandwidth_str[64];
char codec_str[100]; char codec_str[100];
} OutputStream; } OutputStream;
...@@ -368,7 +369,7 @@ static int write_manifest(AVFormatContext *s, int final) ...@@ -368,7 +369,7 @@ static int write_manifest(AVFormatContext *s, int final)
OutputStream *os = &c->streams[i]; OutputStream *os = &c->streams[i];
if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO) if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
continue; continue;
avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\" bandwidth=\"%d\" width=\"%d\" height=\"%d\">\n", i, os->codec_str, st->codec->bit_rate, 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\">\n", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height);
output_segment_list(&c->streams[i], out, c); output_segment_list(&c->streams[i], out, c);
avio_printf(out, "\t\t\t</Representation>\n"); avio_printf(out, "\t\t\t</Representation>\n");
} }
...@@ -381,7 +382,7 @@ static int write_manifest(AVFormatContext *s, int final) ...@@ -381,7 +382,7 @@ static int write_manifest(AVFormatContext *s, int final)
OutputStream *os = &c->streams[i]; OutputStream *os = &c->streams[i];
if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO) if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
continue; continue;
avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\" bandwidth=\"%d\" audioSamplingRate=\"%d\">\n", i, os->codec_str, st->codec->bit_rate, st->codec->sample_rate); avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->sample_rate);
avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codec->channels); avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codec->channels);
output_segment_list(&c->streams[i], out, c); output_segment_list(&c->streams[i], out, c);
avio_printf(out, "\t\t\t</Representation>\n"); avio_printf(out, "\t\t\t</Representation>\n");
...@@ -439,10 +440,17 @@ static int dash_write_header(AVFormatContext *s) ...@@ -439,10 +440,17 @@ static int dash_write_header(AVFormatContext *s)
AVDictionary *opts = NULL; AVDictionary *opts = NULL;
char filename[1024]; char filename[1024];
if (!s->streams[i]->codec->bit_rate) { if (s->streams[i]->codec->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i); snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
ret = AVERROR(EINVAL); " bandwidth=\"%d\"", s->streams[i]->codec->bit_rate);
goto fail; } else {
int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
AV_LOG_ERROR : AV_LOG_WARNING;
av_log(s, level, "No bit rate set for stream %d\n", i);
if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
ret = AVERROR(EINVAL);
goto fail;
}
} }
ctx = avformat_alloc_context(); ctx = avformat_alloc_context();
......
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