From 0ba5299a805e9ccaef1a757381fc2ada4d54b8a1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 29 Apr 2014 17:40:57 +0200 Subject: movenc: use the "encoder" metadata tag to write stsd Compressorname This mirrors the demuxer behaviour and avoids accessing AVCodecContext.codec, which should not be done in muxers. --- libavformat/movenc.c | 7 +++++-- libavformat/movenc.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 9087438998..cf0158be52 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1003,6 +1003,7 @@ static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track) static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) { + AVDictionaryEntry *encoder; int64_t pos = avio_tell(pb); char compressor_name[32] = { 0 }; @@ -1036,8 +1037,9 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) avio_wb16(pb, 1); /* Frame count (= 1) */ /* FIXME not sure, ISO 14496-1 draft where it shall be set to 0 */ - if (track->mode == MODE_MOV && track->enc->codec && track->enc->codec->name) - av_strlcpy(compressor_name, track->enc->codec->name, 32); + if (track->mode == MODE_MOV && + (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) + av_strlcpy(compressor_name, encoder->value, 32); avio_w8(pb, strlen(compressor_name)); avio_write(pb, compressor_name, 31); @@ -3366,6 +3368,7 @@ static int mov_write_header(AVFormatContext *s) MOVTrack *track= &mov->tracks[i]; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); + track->st = st; track->enc = st->codec; track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); if (track->language < 0) diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 226a28f165..3410080780 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -91,6 +91,7 @@ typedef struct MOVTrack { int language; int track_id; int tag; ///< stsd fourcc + AVStream *st; AVCodecContext *enc; int vos_len; -- cgit v1.2.3