diff mbox series

[FFmpeg-devel] avformat/movenc: allow ISMV timescale to be user-set

Message ID 20200123122659.23249-1-ffmpeg@gyani.pro
State New
Headers show
Series [FFmpeg-devel] avformat/movenc: allow ISMV timescale to be user-set
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Gyan Doshi Jan. 23, 2020, 12:26 p.m. UTC
As per the PIFF standard, the timescale of 10000000
is recommended but not mandatory, so don't override
the user-set value.

A warning is shown for non-recommended values.
---
 libavformat/movenc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Gyan Doshi Jan. 25, 2020, 5:34 a.m. UTC | #1
On 23-01-2020 05:56 pm, Gyan Doshi wrote:
> As per the PIFF standard, the timescale of 10000000
> is recommended but not mandatory, so don't override
> the user-set value.
>
> A warning is shown for non-recommended values.
> ---
>   libavformat/movenc.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index fb44ee2c71..5bf434c325 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -6389,6 +6389,8 @@ static int mov_init(AVFormatContext *s)
>               }
>               if (mov->video_track_timescale) {
>                   track->timescale = mov->video_track_timescale;
> +                if (mov->mode == MODE_ISM && mov->video_track_timescale != 10000000)
> +                    av_log(s, AV_LOG_WARNING, "Warning: some tools, like mp4split, assume a timescale of 10000000 for ISMV.\n");
>               } else {
>                   track->timescale = st->time_base.den;
>                   while(track->timescale < 10000)
> @@ -6486,10 +6488,14 @@ static int mov_init(AVFormatContext *s)
>           }
>           if (!track->height)
>               track->height = st->codecpar->height;
> -        /* The ism specific timescale isn't mandatory, but is assumed by
> -         * some tools, such as mp4split. */
> -        if (mov->mode == MODE_ISM)
> -            track->timescale = 10000000;
> +        /* The Protected Interoperable File Format (PIFF) standard, used by ISMV recommends but
> +           doesn't mandate a track timescale of 10,000,000. The muxer allows a custom timescale
> +           for video tracks, so if user-set, it isn't overwritten */
> +        if (mov->mode == MODE_ISM &&
> +            (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
> +            (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !mov->video_track_timescale))) {
> +             track->timescale = 10000000;
> +        }
>   
>           avpriv_set_pts_info(st, 64, 1, track->timescale);
>   

Will push tonight.

Gyan
Gyan Doshi Jan. 25, 2020, 4:07 p.m. UTC | #2
On 25-01-2020 11:04 am, Gyan wrote:
>
>
> On 23-01-2020 05:56 pm, Gyan Doshi wrote:
>> As per the PIFF standard, the timescale of 10000000
>> is recommended but not mandatory, so don't override
>> the user-set value.
>>
>> A warning is shown for non-recommended values.
>> ---
>>   libavformat/movenc.c | 14 ++++++++++----
>>   1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> index fb44ee2c71..5bf434c325 100644
>> --- a/libavformat/movenc.c
>> +++ b/libavformat/movenc.c
>> @@ -6389,6 +6389,8 @@ static int mov_init(AVFormatContext *s)
>>               }
>>               if (mov->video_track_timescale) {
>>                   track->timescale = mov->video_track_timescale;
>> +                if (mov->mode == MODE_ISM && 
>> mov->video_track_timescale != 10000000)
>> +                    av_log(s, AV_LOG_WARNING, "Warning: some tools, 
>> like mp4split, assume a timescale of 10000000 for ISMV.\n");
>>               } else {
>>                   track->timescale = st->time_base.den;
>>                   while(track->timescale < 10000)
>> @@ -6486,10 +6488,14 @@ static int mov_init(AVFormatContext *s)
>>           }
>>           if (!track->height)
>>               track->height = st->codecpar->height;
>> -        /* The ism specific timescale isn't mandatory, but is 
>> assumed by
>> -         * some tools, such as mp4split. */
>> -        if (mov->mode == MODE_ISM)
>> -            track->timescale = 10000000;
>> +        /* The Protected Interoperable File Format (PIFF) standard, 
>> used by ISMV recommends but
>> +           doesn't mandate a track timescale of 10,000,000. The 
>> muxer allows a custom timescale
>> +           for video tracks, so if user-set, it isn't overwritten */
>> +        if (mov->mode == MODE_ISM &&
>> +            (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
>> +            (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && 
>> !mov->video_track_timescale))) {
>> +             track->timescale = 10000000;
>> +        }
>>             avpriv_set_pts_info(st, 64, 1, track->timescale);
>
> Will push tonight.

Pushed as 75d1d9eb349462bf72ed38004c06a53e0b79173c

Gyan
diff mbox series

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index fb44ee2c71..5bf434c325 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6389,6 +6389,8 @@  static int mov_init(AVFormatContext *s)
             }
             if (mov->video_track_timescale) {
                 track->timescale = mov->video_track_timescale;
+                if (mov->mode == MODE_ISM && mov->video_track_timescale != 10000000)
+                    av_log(s, AV_LOG_WARNING, "Warning: some tools, like mp4split, assume a timescale of 10000000 for ISMV.\n");
             } else {
                 track->timescale = st->time_base.den;
                 while(track->timescale < 10000)
@@ -6486,10 +6488,14 @@  static int mov_init(AVFormatContext *s)
         }
         if (!track->height)
             track->height = st->codecpar->height;
-        /* The ism specific timescale isn't mandatory, but is assumed by
-         * some tools, such as mp4split. */
-        if (mov->mode == MODE_ISM)
-            track->timescale = 10000000;
+        /* The Protected Interoperable File Format (PIFF) standard, used by ISMV recommends but
+           doesn't mandate a track timescale of 10,000,000. The muxer allows a custom timescale
+           for video tracks, so if user-set, it isn't overwritten */
+        if (mov->mode == MODE_ISM &&
+            (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
+            (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && !mov->video_track_timescale))) {
+             track->timescale = 10000000;
+        }
 
         avpriv_set_pts_info(st, 64, 1, track->timescale);