On 03/07/14 22:18, Martin Storsjö wrote:
> On Wed, 2 Jul 2014, Luca Barbato wrote:
> 
>> ---
>> libavformat/mov.c | 39 +++++++++++++++++++++++++++++++--------
>> 1 file changed, 31 insertions(+), 8 deletions(-)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 4a2d265..c78a7d9 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -506,6 +506,8 @@ static int mov_read_hdlr(MOVContext *c,
>> AVIOContext *pb, MOVAtom atom)
>>     AVStream *st;
>>     uint32_t type;
>>     uint32_t av_unused ctype;
>> +    uint32_t val;
>> +    char buf[1024];
>>
>>     if (c->fc->nb_streams < 1) // meta before first trak
>>         return 0;
>> @@ -532,8 +534,16 @@ static int mov_read_hdlr(MOVContext *c,
>> AVIOContext *pb, MOVAtom atom)
>>         st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
>>
>>     avio_rb32(pb); /* component  manufacture */
>> -    avio_rb32(pb); /* component flags */
>> -    avio_rb32(pb); /* component flags mask */
>> +    val = avio_rb32(pb); /* component flags */
>> +    if (val) {
>> +        snprintf(buf, sizeof(buf), "%d", val);
>> +        av_dict_set(&st->metadata, "mov-component-flags", buf, 0);
>> +    }
>> +    val = avio_rb32(pb); /* component flags mask */
>> +    if (val) {
>> +        snprintf(buf, sizeof(buf), "%d", val);
>> +        av_dict_set(&st->metadata, "mov-component-mask", buf, 0);
>> +    }
>>
>>     return 0;
>> }
>> @@ -2389,7 +2399,8 @@ static int mov_read_tkhd(MOVContext *c,
>> AVIOContext *pb, MOVAtom atom)
>>     AVStream *st;
>>     MOVStreamContext *sc;
>>     int version;
>> -    int flags;
>> +    int val;
>> +    char buf[256];
>>
>>     if (c->fc->nb_streams < 1)
>>         return 0;
>> @@ -2397,8 +2408,10 @@ static int mov_read_tkhd(MOVContext *c,
>> AVIOContext *pb, MOVAtom atom)
>>     sc = st->priv_data;
>>
>>     version = avio_r8(pb);
>> -    flags = avio_rb24(pb);
>> -    st->disposition |= (flags & MOV_TKHD_FLAG_ENABLED) ?
>> AV_DISPOSITION_DEFAULT : 0;
>> +    val = avio_rb24(pb);
>> +    snprintf(buf, sizeof(buf), "%d", val);
>> +    av_dict_set(&st->metadata, "mov-flags", buf, 0);
>> +    st->disposition |= (val & MOV_TKHD_FLAG_ENABLED) ?
>> AV_DISPOSITION_DEFAULT : 0;
> 
> Hmm... We will always be exporting this value, regardless of what value
> it is, which means that whenever we do stream copy, we will never use
> the original logic in movenc, we will always overwrite it with whatever
> was in the input file. I don't remember these fields too well off-hand,
> but perhaps that the desired behaviour (instinctively I'd like to only
> copy them verbatim if these are set to something odd, like with the
> component flags/mask).

I guess I can implement an avoption in the muxer to copy this kind of
metadata and have it off by default might be an option to keep the
current behaviour.

>> +    av_dict_set(&st->metadata, "mov-alternate-group", buf, 0);
> 
> Hmm, this one is always exported but not the others?

0 is valid value and sadly not the default, stream grouping is actually
the item I'd like to expose and edit mainly.

Some users might get confusing results if we group all the audio streams
in a single alternate group and they expect to have separate streams
that can be active or not on demand.

I can write some code so that if more than 1 stream of some kind is set
to active every stream lives in a group for the default behaviour.

> All in all doesn't seem too bad this either. Very fringe use case, and
> we'll be littering the output metadata with a lot of internals, but we
> already do that with e.g. the ftyp atom anyway.

I can implement a (generic) avoption for that, we might this kind of
mess also for the DASH-based formats (in this case st->id might be
leveraged though).

this way who needs to access those would use -format_specific_metadata
on both sides to get all the information and optionally copy/edit it.

lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to