diff options
author | Mark Reid <mindmark@gmail.com> | 2014-08-08 10:37:06 -0700 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-09 03:08:25 +0200 |
commit | d6af706eee48cf8e1c545b3097b2bebcffa7ab1d (patch) | |
tree | 1218aaec7fcc7af421e5a586a03c54b7d08bf393 | |
parent | 4b63bcef907b410facfb337340fb81fe9f1e58f7 (diff) | |
download | ffmpeg-d6af706eee48cf8e1c545b3097b2bebcffa7ab1d.tar.gz |
avformat/movenc: write reel_name metadata to tmcd atom
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/movenc.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 86dbe7f30d..6a38e89d20 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1340,12 +1340,23 @@ static int mov_write_rtp_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } +static int mov_write_source_reference_tag(AVIOContext *pb, MOVTrack *track, const char *reel_name){ + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, "name"); /* Data format */ + avio_wb16(pb, strlen(reel_name)); /* string size */ + avio_wb16(pb, track->language); /* langcode */ + avio_write(pb, reel_name, strlen(reel_name)); /* reel name */ + return update_size(pb,pos); +} + static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); #if 1 int frame_duration = av_rescale(track->timescale, track->enc->time_base.num, track->enc->time_base.den); int nb_frames = 1.0/av_q2d(track->enc->time_base) + 0.5; + AVDictionaryEntry *t = NULL; if (nb_frames > 255) { av_log(NULL, AV_LOG_ERROR, "fps %d is too large\n", nb_frames); @@ -1361,8 +1372,15 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) avio_wb32(pb, track->timescale); /* Timescale */ avio_wb32(pb, frame_duration); /* Frame duration */ avio_w8(pb, nb_frames); /* Number of frames */ - avio_wb24(pb, 0); /* Reserved */ - /* TODO: source reference string */ + avio_w8(pb, 0); /* Reserved */ + + if (track->st) + t = av_dict_get(track->st->metadata, "reel_name", NULL, 0); + + if (t && utf8len(t->value)) + mov_write_source_reference_tag(pb, track, t->value); + else + avio_wb16(pb, 0); /* zero size */ #else avio_wb32(pb, 0); /* size */ @@ -3809,6 +3827,9 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde if (tc.flags & AV_TIMECODE_FLAG_DROPFRAME) track->timecode_flags |= MOV_TIMECODE_FLAG_DROPFRAME; + /* set st to src_st for metadata access*/ + track->st = src_st; + /* encode context: tmcd data stream */ track->enc = avcodec_alloc_context3(NULL); track->enc->codec_type = AVMEDIA_TYPE_DATA; |