[FFmpeg-cvslog] avformat/movenc: write reel_name metadata to tmcd atom
Mark Reid
git at videolan.org
Sat Aug 9 03:33:32 CEST 2014
ffmpeg | branch: master | Mark Reid <mindmark at gmail.com> | Fri Aug 8 10:37:06 2014 -0700| [d6af706eee48cf8e1c545b3097b2bebcffa7ab1d] | committer: Michael Niedermayer
avformat/movenc: write reel_name metadata to tmcd atom
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6af706eee48cf8e1c545b3097b2bebcffa7ab1d
---
libavformat/movenc.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 86dbe7f..6a38e89 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;
More information about the ffmpeg-cvslog
mailing list