diff options
author | Alessandro Ghedini <alessandro@ghedini.me> | 2014-03-30 19:05:59 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-30 20:04:20 +0200 |
commit | 01e8a9c9e3a28f2beb41a5ee6d902797abdb74f0 (patch) | |
tree | 27261c599952e26dfc7af83e4b83595495c8c21f /common/encode_lavc.c | |
parent | 239dc2851a9001ff3c69c613d621125c9a95e8ae (diff) | |
download | mpv-01e8a9c9e3a28f2beb41a5ee6d902797abdb74f0.tar.bz2 mpv-01e8a9c9e3a28f2beb41a5ee6d902797abdb74f0.tar.xz |
encode_lavc: copy metadata to output file
Closes #684
Signed-off-by: wm4 <wm4@nowhere>
Includes some minor cosmetic changes additional to the original PR.
Diffstat (limited to 'common/encode_lavc.c')
-rw-r--r-- | common/encode_lavc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/common/encode_lavc.c b/common/encode_lavc.c index 5d9853673b..39e5607e41 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -244,10 +244,15 @@ struct encode_lavc_context *encode_lavc_init(struct encode_output_conf *options, return ctx; } +void encode_lavc_set_metadata(struct encode_lavc_context *ctx, + struct mp_tags *metadata) +{ + ctx->metadata = metadata; +} + int encode_lavc_start(struct encode_lavc_context *ctx) { AVDictionaryEntry *de; - unsigned i; if (ctx->header_written < 0) return 0; @@ -257,6 +262,7 @@ int encode_lavc_start(struct encode_lavc_context *ctx) CHECK_FAIL(ctx, 0); if (ctx->expect_video) { + unsigned i; for (i = 0; i < ctx->avc->nb_streams; ++i) if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) break; @@ -267,6 +273,7 @@ int encode_lavc_start(struct encode_lavc_context *ctx) } } if (ctx->expect_audio) { + unsigned i; for (i = 0; i < ctx->avc->nb_streams; ++i) if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) break; @@ -296,6 +303,13 @@ int encode_lavc_start(struct encode_lavc_context *ctx) MP_INFO(ctx, "Opening muxer: %s [%s]\n", ctx->avc->oformat->long_name, ctx->avc->oformat->name); + if (ctx->metadata) { + for (int i = 0; i < ctx->metadata->num_keys; i++) { + av_dict_set(&ctx->avc->metadata, + ctx->metadata->keys[i], ctx->metadata->values[i], 0); + } + } + if (avformat_write_header(ctx->avc, &ctx->foptions) < 0) { encode_lavc_fail(ctx, "could not write header\n"); return 0; |