[FFmpeg-devel] [PATCH] avformat/mov: parse rtmd track timecode

Paul B Mahol onemda at gmail.com
Sat Jun 25 17:30:21 CEST 2016


On 6/25/16, Clement Boesch <u at pkh.me> wrote:
> On Sat, Jun 25, 2016 at 11:36:05AM +0200, Paul B Mahol wrote:
>> Hi,
>>
>> patch attached.
>
>> From fbf2d600e048a417183ab32fdb2e7e2bcf238071 Mon Sep 17 00:00:00 2001
>> From: Paul B Mahol <onemda at gmail.com>
>> Date: Sat, 25 Jun 2016 11:33:46 +0200
>> Subject: [PATCH] avformat/mov: parse rtmd track timecode
>>
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavformat/mov.c | 30 +++++++++++++++++++++++++++++-
>>  1 file changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index d75605d..34ce246 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -4674,6 +4674,31 @@ static int
>> parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st,
>>      return 0;
>>  }
>>
>> +static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)
>> +{
>> +    MOVStreamContext *sc = st->priv_data;
>> +    char buf[AV_TIMECODE_STR_SIZE];
>> +    int64_t cur_pos = avio_tell(sc->pb);
>> +    int dd, hh, mm, ss;
>> +
>> +    if (!st->nb_index_entries)
>> +        return -1;
>> +
>> +    avio_seek(sc->pb, st->index_entries->pos, SEEK_SET);
>> +    avio_skip(s->pb, 13);
>> +    dd = avio_r8(s->pb);
>> +    hh = avio_r8(s->pb);
>> +    mm = avio_r8(s->pb);
>
>> +    avio_skip(s->pb, 1);
>
> isn't this the drop flag? if so you should probably honor it as as ';' in
> the timecode string

Fixed locally.

>
>> +    ss = avio_r8(s->pb);
>> +    snprintf(buf, AV_TIMECODE_STR_SIZE, "%02d:%02d:%02d:%02d",
>> +             dd, hh, mm, ss);
>> +    av_dict_set(&st->metadata, "timecode", buf, 0);
>> +
>> +    avio_seek(sc->pb, cur_pos, SEEK_SET);
>> +    return 0;
>> +}
>> +
>>  static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
>>  {
>>      MOVStreamContext *sc = st->priv_data;
>> @@ -4952,8 +4977,11 @@ static int mov_read_header(AVFormatContext *s)
>>          if (mov->chapter_track > 0 && !mov->ignore_chapters)
>>              mov_read_chapters(s);
>>          for (i = 0; i < s->nb_streams; i++)
>> -            if (s->streams[i]->codecpar->codec_tag == AV_RL32("tmcd"))
>> +            if (s->streams[i]->codecpar->codec_tag == AV_RL32("tmcd")) {
>>                  mov_read_timecode_track(s, s->streams[i]);
>> +            } else if (s->streams[i]->codecpar->codec_tag ==
>> AV_RL32("rtmd")) {
>> +                mov_read_rtmd_track(s, s->streams[i]);
>> +            }
>>      }
>>
>>      /* copy timecode metadata from tmcd tracks to the related video
>> streams */
>
>
> --
> Clement B.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list