From f856d9c2f314c493c672dfb9c876da182525da3d Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Wed, 19 Nov 2014 13:49:31 +0200 Subject: dashenc: Don't require the stream bitrate to be known MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Martin Storsjö --- libavformat/dashenc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'libavformat/dashenc.c') diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index cacaf922b8..41caf6dcff 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -59,6 +59,7 @@ typedef struct OutputStream { int nb_segments, segments_size, segment_index; Segment **segments; int64_t first_dts, start_dts, end_dts; + char bandwidth_str[64]; char codec_str[100]; } OutputStream; @@ -368,7 +369,7 @@ static int write_manifest(AVFormatContext *s, int final) OutputStream *os = &c->streams[i]; if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO) continue; - avio_printf(out, "\t\t\t\n", i, os->codec_str, st->codec->bit_rate, st->codec->width, st->codec->height); + avio_printf(out, "\t\t\t\n", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height); output_segment_list(&c->streams[i], out, c); avio_printf(out, "\t\t\t\n"); } @@ -381,7 +382,7 @@ static int write_manifest(AVFormatContext *s, int final) OutputStream *os = &c->streams[i]; if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO) continue; - avio_printf(out, "\t\t\t\n", i, os->codec_str, st->codec->bit_rate, st->codec->sample_rate); + avio_printf(out, "\t\t\t\n", i, os->codec_str, os->bandwidth_str, st->codec->sample_rate); avio_printf(out, "\t\t\t\t\n", st->codec->channels); output_segment_list(&c->streams[i], out, c); avio_printf(out, "\t\t\t\n"); @@ -439,10 +440,17 @@ static int dash_write_header(AVFormatContext *s) AVDictionary *opts = NULL; char filename[1024]; - if (!s->streams[i]->codec->bit_rate) { - av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i); - ret = AVERROR(EINVAL); - goto fail; + if (s->streams[i]->codec->bit_rate) { + snprintf(os->bandwidth_str, sizeof(os->bandwidth_str), + " bandwidth=\"%d\"", s->streams[i]->codec->bit_rate); + } 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(); -- cgit v1.2.3