[FFmpeg-cvslog] movenc: use the "encoder" metadata tag to write stsd Compressorname

Anton Khirnov git at videolan.org
Sun May 18 23:22:41 CEST 2014


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Apr 29 17:40:57 2014 +0200| [0ba5299a805e9ccaef1a757381fc2ada4d54b8a1] | committer: Anton Khirnov

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ba5299a805e9ccaef1a757381fc2ada4d54b8a1
---

 libavformat/movenc.c |    7 +++++--
 libavformat/movenc.h |    1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9087438..cf0158b 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 226a28f..3410080 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;



More information about the ffmpeg-cvslog mailing list