2014-10-29 22:00 GMT+09:00 Martin Storsjö <[email protected]>:

> On Wed, 29 Oct 2014, Yusuke Nakamura wrote:
>
>  2014-10-29 19:14 GMT+09:00 Martin Storsjö <[email protected]>:
>>
>>  Similarly to the omit_tfhd_offset flag added in e7bf085b, this
>>> avoids writing absolute byte positions to the file, making them
>>> more easily streamable.
>>>
>>> This is a new feature from 14496-12:2012, so application support
>>> isn't necessarily too widespread yet (support for it in libav was
>>> added in 20f95f21f in July 2014).
>>> ---
>>>  doc/muxers.texi      | 7 +++++++
>>>  libavformat/movenc.c | 7 ++++++-
>>>  libavformat/movenc.h | 1 +
>>>  3 files changed, 14 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>>> index e00a162..ee3edb9 100644
>>> --- a/doc/muxers.texi
>>> +++ b/doc/muxers.texi
>>> @@ -340,6 +340,13 @@ cause failures when the file is reprocessed with
>>> certain tagging programs.
>>>  @item -movflags omit_tfhd_offset
>>>  Don't write any absolute base_data_offset in tfhd atoms. This avoids
>>>  tying fragments to absolute byte positions in the file/streams.
>>> +@item -movflags default_base_moof
>>> +Similarly to the omit_tfhd_offset, this flag avoids writing the
>>> +absolute base_data_offset field in tfhd atoms, but does so by using
>>> +the new default-base-is-moof flag instead. This flag is new from
>>> +14496-12:2012. This may make the fragments easier to parse in certain
>>> +circumstances (avoiding basing track fragment location calculations
>>> +on the implicit end of the previous track fragment).
>>>  @end table
>>>
>>>  Smooth Streaming content can be pushed in real time to a publishing
>>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>>> index 30c500e..b843dad 100644
>>> --- a/libavformat/movenc.c
>>> +++ b/libavformat/movenc.c
>>> @@ -58,6 +58,7 @@ static const AVOption options[] = {
>>>      { "faststart", "Run a second pass to put the index (moov atom) at
>>> the
>>> beginning of the file", 0, AV_OPT_TYPE_CONST, {.i64 =
>>> FF_MOV_FLAG_FASTSTART}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM,
>>> "movflags" },
>>>      { "omit_tfhd_offset", "Omit the base data offset in tfhd atoms", 0,
>>> AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_OMIT_TFHD_OFFSET}, INT_MIN,
>>> INT_MAX,
>>> AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
>>>      { "disable_chpl", "Disable Nero chapter atom", 0, AV_OPT_TYPE_CONST,
>>> {.i64 = FF_MOV_FLAG_DISABLE_CHPL}, INT_MIN, INT_MAX,
>>> AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
>>> +    { "default_base_moof", "Set the default-base-is-moof flag in tfhd
>>> atoms", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF},
>>> INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
>>>      FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
>>>      { "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext,
>>> iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
>>> AV_OPT_FLAG_ENCODING_PARAM},
>>>      { "iods_audio_profile", "iods audio profile atom.",
>>> offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 =
>>> -1},
>>> -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
>>> @@ -2386,6 +2387,10 @@ static int mov_write_tfhd_tag(AVIOContext *pb,
>>> MOVMuxContext *mov,
>>>      }
>>>      if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET)
>>>          flags &= ~MOV_TFHD_BASE_DATA_OFFSET;
>>> +    if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) {
>>> +        flags &= ~MOV_TFHD_BASE_DATA_OFFSET;
>>> +        flags |= MOV_TFHD_DEFAULT_BASE_IS_MOOF;
>>> +    }
>>>
>>>      /* Don't set a default sample size, the silverlight player refuses
>>>       * to play files with that set. Don't set a default sample duration,
>>> @@ -2457,7 +2462,7 @@ static int mov_write_trun_tag(AVIOContext *pb,
>>> MOVMuxContext *mov,
>>>
>>>      avio_wb32(pb, track->entry); /* sample count */
>>>      if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
>>> -        !(mov->flags & FF_MOV_FLAG_SEPARATE_MOOF) &&
>>> +        !(mov->flags & (FF_MOV_FLAG_SEPARATE_MOOF |
>>> FF_MOV_FLAG_DEFAULT_BASE_MOOF)) &&
>>>          !mov->first_trun)
>>>          avio_wb32(pb, 0); /* Later tracks follow immediately after the
>>> previous one */
>>>      else
>>> diff --git a/libavformat/movenc.h b/libavformat/movenc.h
>>> index a463a8d..56e2647 100644
>>> --- a/libavformat/movenc.h
>>> +++ b/libavformat/movenc.h
>>> @@ -178,6 +178,7 @@ typedef struct MOVMuxContext {
>>>  #define FF_MOV_FLAG_FASTSTART 128
>>>  #define FF_MOV_FLAG_OMIT_TFHD_OFFSET 256
>>>  #define FF_MOV_FLAG_DISABLE_CHPL 512
>>> +#define FF_MOV_FLAG_DEFAULT_BASE_MOOF 1024
>>>
>>>  int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
>>>
>>> --
>>> 1.9.3 (Apple Git-50)
>>>
>>> _______________________________________________
>>> libav-devel mailing list
>>> [email protected]
>>> https://lists.libav.org/mailman/listinfo/libav-devel
>>>
>>>
>> This patch produces out-of-spec files about the file format compatibility.
>> Fragmented files with default-base-is-moof shall not contain brands
>> earlier
>> than iso5.
>> I know such broken files exist e.g. DASH-IF test vectors, but the spec
>> clearly says that default-base-is-moof shall not be set under the earlier
>> brands even if moof contains only one traf.
>>
>
> Right, so would it be ok if I'd add something like this:
>
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -2881,8 +2881,12 @@ static int mov_write_ftyp_tag(AVIOContext *pb,
> AVFormatCo
>          ffio_wfourcc(pb, "piff");
>          ffio_wfourcc(pb, "iso2");
>      } else {
> -        ffio_wfourcc(pb, "isom");
> -        ffio_wfourcc(pb, "iso2");
> +        if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) {
> +            ffio_wfourcc(pb, "iso5");
> +        } else {
> +            ffio_wfourcc(pb, "isom");
> +            ffio_wfourcc(pb, "iso2");
> +        }
>          if (has_h264)
>              ffio_wfourcc(pb, "avc1");
>      }
>

> (Possibly the same also for the ISM case above.)
>

Still insufficient because of major_brand when mov->mode == MODE_MP4.
And "brand" option could also produce broken files.


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


By the way, tfdt is defined in iso6 or later brands.
So, adding iso6 brand is strongly preferable for writing tfdt by another
preceding patch.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to