[FFmpeg-cvslog] Merge commit 'dce2929efa8e82b0832a828f7e8cb81ff8c20a4e'
Rodger Combs
git at videolan.org
Tue Sep 26 20:33:03 EEST 2017
ffmpeg | branch: master | Rodger Combs <rodger.combs at gmail.com> | Tue Sep 26 14:11:50 2017 -0300| [5c9373385d1a1d940b84f71fb583dc5519b17b8a] | committer: James Almer
Merge commit 'dce2929efa8e82b0832a828f7e8cb81ff8c20a4e'
* commit 'dce2929efa8e82b0832a828f7e8cb81ff8c20a4e':
dashenc: copy language and role metadata from streams assigned to sets
Merged-by: Rodger Combs <rodger.combs at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5c9373385d1a1d940b84f71fb583dc5519b17b8a
---
libavformat/dashenc.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5a966fe3ad..ab6bf21dbd 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -54,6 +54,7 @@ typedef struct Segment {
typedef struct AdaptationSet {
char id[10];
enum AVMediaType media_type;
+ AVDictionary *metadata;
} AdaptationSet;
typedef struct OutputStream {
@@ -181,6 +182,8 @@ static void dash_free(AVFormatContext *s)
int i, j;
if (c->as) {
+ for (i = 0; i < c->nb_as; i++)
+ av_dict_free(&c->as[i].metadata);
av_freep(&c->as);
c->nb_as = 0;
}
@@ -336,14 +339,22 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind
{
DASHContext *c = s->priv_data;
AdaptationSet *as = &c->as[as_index];
+ AVDictionaryEntry *lang, *role;
int i;
avio_printf(out, "\t\t<AdaptationSet id=\"%s\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"",
as->id, as->media_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
if (as->media_type == AVMEDIA_TYPE_VIDEO && 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);
+ lang = av_dict_get(as->metadata, "language", NULL, 0);
+ if (lang)
+ avio_printf(out, " lang=\"%s\"", lang->value);
avio_printf(out, ">\n");
+ role = av_dict_get(as->metadata, "role", NULL, 0);
+ if (role)
+ avio_printf(out, "\t\t\t<Role schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
+
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
@@ -596,6 +607,14 @@ static int write_manifest(AVFormatContext *s, int final)
return 0;
}
+static int dict_copy_entry(AVDictionary **dst, const AVDictionary *src, const char *key)
+{
+ AVDictionaryEntry *entry = av_dict_get(src, key, NULL, 0);
+ if (entry)
+ av_dict_set(dst, key, entry->value, AV_DICT_DONT_OVERWRITE);
+ return 0;
+}
+
static int dash_init(AVFormatContext *s)
{
DASHContext *c = s->priv_data;
@@ -637,6 +656,7 @@ static int dash_init(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
+ AdaptationSet *as = &c->as[os->as_idx - 1];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
@@ -654,6 +674,10 @@ static int dash_init(AVFormatContext *s)
return AVERROR(EINVAL);
}
+ // copy AdaptationSet language and role from stream metadata
+ dict_copy_entry(&as->metadata, s->streams[i]->metadata, "language");
+ dict_copy_entry(&as->metadata, s->streams[i]->metadata, "role");
+
ctx = avformat_alloc_context();
if (!ctx)
return AVERROR(ENOMEM);
======================================================================
diff --cc libavformat/dashenc.c
index 5a966fe3ad,8b70278b39..ab6bf21dbd
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@@ -340,10 -462,15 +344,17 @@@ static int write_adaptation_set(AVForma
avio_printf(out, "\t\t<AdaptationSet id=\"%s\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"",
as->id, as->media_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
+ if (as->media_type == AVMEDIA_TYPE_VIDEO && 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);
+ lang = av_dict_get(as->metadata, "language", NULL, 0);
+ if (lang)
+ avio_printf(out, " lang=\"%s\"", lang->value);
avio_printf(out, ">\n");
+ role = av_dict_get(as->metadata, "role", NULL, 0);
+ if (role)
+ avio_printf(out, "\t\t\t<Role schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"%s\"/>\n", role->value);
+
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
@@@ -589,14 -706,18 +600,22 @@@ static int write_manifest(AVFormatConte
avio_printf(out, "</MPD>\n");
avio_flush(out);
ff_format_io_close(s, &out);
- return ff_rename(temp_filename, s->filename);
+
+ if (use_rename)
+ return avpriv_io_move(temp_filename, s->filename);
+
+ return 0;
}
+ static int dict_copy_entry(AVDictionary **dst, const AVDictionary *src, const char *key)
+ {
+ AVDictionaryEntry *entry = av_dict_get(src, key, NULL, 0);
+ if (entry)
+ av_dict_set(dst, key, entry->value, AV_DICT_DONT_OVERWRITE);
+ return 0;
+ }
+
-static int dash_write_header(AVFormatContext *s)
+static int dash_init(AVFormatContext *s)
{
DASHContext *c = s->priv_data;
int ret = 0, i;
@@@ -650,13 -775,21 +670,17 @@@
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;
- }
+ if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
+ return AVERROR(EINVAL);
}
+ // copy AdaptationSet language and role from stream metadata
+ dict_copy_entry(&as->metadata, s->streams[i]->metadata, "language");
+ dict_copy_entry(&as->metadata, s->streams[i]->metadata, "role");
+
ctx = avformat_alloc_context();
- if (!ctx) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
+ if (!ctx)
+ return AVERROR(ENOMEM);
os->ctx = ctx;
ctx->oformat = oformat;
ctx->interrupt_callback = s->interrupt_callback;
More information about the ffmpeg-cvslog
mailing list