Quicktime - Specify a Movie Header timescale of 24000

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
When I run my 24fps Quicktime mov files through an FFmpeg transcode they are coming out with a Movie Header timescale of 1000, when the source file has a timescale of 24000. This low timescale value is causing issues in some professional software tools when seeking the file.

In my case the source file is a Quicktime with 1 x video track (DNx115) and 1 x data track (Timecode). I'm transcoding it to DNx36.

I can force the video timescale to 24000 by adding "-video_track_timescale 24000", but this does not affect anything other than the video track.

The command is as follows:

ffmpeg -i input.mov -c:v dnxhd -b:v 36M -pix_fmt yuv422p -video_track_timescale 24000 output.mov

Uncut console output:

ffmpeg version N-90214-gdd3f1e3a11-tessus Copyright (c) 2000-2018 the FFmpeg developers
      built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
      configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
      libavutil      56.  8.100 / 56.  8.100
      libavcodec     58. 13.102 / 58. 13.102
      libavformat    58. 10.100 / 58. 10.100
      libavdevice    58.  2.100 / 58.  2.100
      libavfilter     7. 12.100 /  7. 12.100
      libswscale      5.  0.102 /  5.  0.102
      libswresample   3.  0.101 /  3.  0.101
      libpostproc    55.  0.100 / 55.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
      Metadata:
        major_brand     : qt  
        minor_version   : 537199360
        compatible_brands: qt  
        creation_time   : 2018-03-06T10:45:16.000000Z
        timecode        : 01:14:25:22
      Duration: 00:00:30.00, start: 0.000000, bitrate: 116392 kb/s
        Stream #0:0(eng): Video: dnxhd (DNXHD) (AVdn / 0x6E645641), yuv422p(tv, bt709), 1920x1080, 116391 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24k tbn, 24k tbc (default)
        Metadata:
          creation_time   : 2018-03-06T10:45:16.000000Z
          handler_name    : Apple Alias Data Handler
          encoder         : Avid DNxHD Codec
        Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
        Metadata:
          creation_time   : 2018-03-06T10:45:20.000000Z
          handler_name    : Apple Alias Data Handler
          timecode        : 01:14:25:22
    Stream mapping:
      Stream #0:0 -> #0:0 (dnxhd (native) -> dnxhd (native))
    Press [q] to stop, [?] for help
    Output #0, mov, to 'output.mov':
      Metadata:
        major_brand     : qt  
        minor_version   : 537199360
        compatible_brands: qt  
        timecode        : 01:14:25:22
        encoder         : Lavf58.10.100
        Stream #0:0(eng): Video: dnxhd (DNXHD) (AVdn / 0x6E645641), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-1024, 36000 kb/s, 0.04 fps, 24k tbn, 24 tbc (default)
        Metadata:
          creation_time   : 2018-03-06T10:45:16.000000Z
          handler_name    : Apple Alias Data Handler
          encoder         : Lavc58.13.102 dnxhd
    frame=  720 fps=151 q=4.0 Lsize=  132482kB time=00:00:29.95 bitrate=36226.7kbits/s speed=6.28x

I have checked the timescale value in Atom Inspector and can clearly see that the mvhd (Movie Header) is changed to 1000 in the output.mov when the input.mov was set to 24000.

1000 is too low for accurate seeking.

Using Atom Inspector to manually change this header timescale to 24000 and alter the duration fields to what they should be based on this timescale, the file works as expected.

Is there anyway to set the Movie Header timescale value as an option in FFmpeg?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Carl Eugen Hoyos-2
2018-03-07 1:13 GMT+01:00, Mark Burton <[hidden email]>:
> When I run my 24fps Quicktime mov files through an FFmpeg transcode they are
> coming out with a Movie Header timescale of 1000, when the source file has a
> timescale of 24000. This low timescale value is causing issues in some
> professional software tools when seeking the file.

Could you elaborate a little?
What kind of issues?

Does it help if you edit MOV_TIMESCALE in libavformat/movenc.h?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
On 7 Mar 2018, at 00:24, Carl Eugen Hoyos <[hidden email]> wrote:
> Could you elaborate a little?
> What kind of issues?
>
> Does it help if you edit MOV_TIMESCALE in libavformat/movenc.h?

The files are being used in software (Conformalizer) that seeks to specific points in the Quicktime file, but with the FFmpeg generated files, its landing on the wrong frame, usually 1 frame out. The original Quicktime files (with a timescale of 24000), seek just fine when used in the same software.

With regards to changing the MOV_TIMESCALE in libavformat/movenc.h, I’m afraid I’m not an experienced developer unfortunately and don’t have the know how to compile ffmpeg myself having made changes. I do think your right though, this could well be the answer to the problem. Some Quicktime software sets this value to 45000 as its then divisible by 24, 25 and 30fps. Is there is specific reason this value is currently being set to 1000? This is not divisible by 24.

Thanks
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
On 7 Mar 2018, at 00:45, Mark Burton <[hidden email]> wrote:
> Does it help if you edit MOV_TIMESCALE in libavformat/movenc.h?

What are the chances that this value could be changed to a much higher and more useful value?
Does anyone know why 1000 was chosen?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Carl Eugen Hoyos-2
2018-03-07 17:58 GMT+01:00, Mark Burton <[hidden email]>:
> On 7 Mar 2018, at 00:45, Mark Burton <[hidden email]> wrote:
>> Does it help if you edit MOV_TIMESCALE in libavformat/movenc.h?
>
> What are the chances that this value could be changed to a much
> higher and more useful value?

It is zero as long as nobody confirms that this would fix the issue you see.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
On 8 Mar 2018, at 11:03, Carl Eugen Hoyos <[hidden email]> wrote:
> It is zero as long as nobody confirms that this would fix the issue you see.

Understood. A better option would no doubt be the ability to specify this value in the same way we can specify the video_track_timescale value.

For the record, I have used a 3rd party tool to alter the timescale to 24000 and it completely fixed the issue with the ffmpeg output files.

Since I don’t have the know how to make changes to the FFmpeg code (changing MOV_TIMESCALE to a higher value in libavformat/movenc.h), I’ll need to find someone who is willing to either test, or even better, build a binary for me to test with.

Is there anyone out there willing to do this?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Carl Eugen Hoyos-2
2018-03-08 15:57 GMT+01:00, Mark Burton <[hidden email]>:
> On 8 Mar 2018, at 11:03, Carl Eugen Hoyos <[hidden email]> wrote:
>> It is zero as long as nobody confirms that this would fix the issue you
>> see.
>
> Understood. A better option would no doubt be the ability to specify this
> value in the same way we can specify the video_track_timescale value.

If it would not fix your issue why would it be a good option?

[...]

> Since I don’t have the know how to make changes to the FFmpeg code
> (changing MOV_TIMESCALE to a higher value in libavformat/movenc.h),

Sorry, this is not an acceptable answer:
movenc.h is a textfile that can be changed with any text editor.

> I’ll need to find someone who is willing to either test,

This sounds difficult with the given information.

> or even better, build a binary for me to test with.

Could you elaborate why you cannot compile yourself?
FFmpeg is supposed to build out-of-the-box on every common
operating system and an a few very uncommon OS's.
This is the right mailing list for compilation help.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
On 8 Mar 2018, at 16:38, Carl Eugen Hoyos <[hidden email]> wrote:
> 2018-03-08 15:57 GMT+01:00, Mark Burton <[hidden email]>:
>>
>> Understood. A better option would no doubt be the ability to specify this
>> value in the same way we can specify the video_track_timescale value.
> If it would not fix your issue why would it be a good option?

Fair enough. The current ffmpeg default is 1000. This is not divisible by 24, 30 or 60fps. The default in the Quicktime specification is 600. This is cleanly divisible by 24, 25, 30, 50, 60, so is a very good value for the majority of professional fixed frame rates. I accept these do not represent all fixed frame rates, but it is evidently a better value than 1000.

https://developer.apple.com/library/content/documentation/QuickTime/RM/Fundamentals/QTOverview/QTOverview_Document/QuickTimeOverview.html <https://developer.apple.com/library/content/documentation/QuickTime/RM/Fundamentals/QTOverview/QTOverview_Document/QuickTimeOverview.html>
"Media Time Scale
A QuickTime movie always has a time scale, expressed in units per second. You can specify a time scale when you create a movie, but the time scale cannot be changed once a movie exists. When you perform operations on a QuickTime movie, you frequently need to specify a point in the movie timeline at which to begin the operation; this is specified using a time value, expressed in movie time scale units. You may also need to specify a duration; this is also expressed in movie time scale units. The default movie time scale is 600…"

>> Since I don’t have the know how to make changes to the FFmpeg code
>> (changing MOV_TIMESCALE to a higher value in libavformat/movenc.h),
> Sorry, this is not an acceptable answer:
> movenc.h is a textfile that can be changed with any text editor.
I understand that, but I do not yet know how to bring the files locally, edit the values and then compile everything into a binary. I have absolutely tried this a number of ways, following the Compilation Guide https://trac.ffmpeg.org/wiki/CompilationGuide <https://trac.ffmpeg.org/wiki/CompilationGuide>, but I did not manage to do it successfully. I would love to get there though and so any help is hugely appreciated. I’m very determined and will do my utmost to be able to contribute a complete answer to this issue.

>> or even better, build a binary for me to test with.
> Could you elaborate why you cannot compile yourself?
> FFmpeg is supposed to build out-of-the-box on every common
> operating system and an a few very uncommon OS's.
> This is the right mailing list for compilation help.

Thanks. I have managed to compile a usable ffmpeg using brew (I work exclusively on macOS), but I have not figured out how I would be able to edit the libavformat/movenc.h file before compiling using this method. It seems I would need to go down the route, so any help to get that far would be so welcome.

Thanks
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Carl Eugen Hoyos-2
2018-03-08 17:58 GMT+01:00, Mark Burton <[hidden email]>:
> Thanks. I have managed to compile a usable ffmpeg using brew (I work
> exclusively on macOS), but I have not figured out how I would be able to
> edit the libavformat/movenc.h file before compiling using this method. It
> seems I would need to go down the route, so any help to get that far would
> be so welcome.

You need a compiler, make and git. Iirc, all three are installed if you
type something like "gcc -v" on the command line (but I assume they
are now installed by brew).

$ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
$ cd ffmpeg
$ ./configure && make ffmpeg
This could for example fail if you don't have a new enough yasm or nasm
binary, in that case please try "./configure --disable-yasm", feel free to
add "--enable-gpl". If you know hat your cpu has - for example - four
cores, you can use "make -j4 ffmpeg" to speed up compilation.

This creates a current ffmpeg binary, please test (from the build
directory) if it allows to reproduce your issue.
Then edit libavformat/movenc.h and run "make ffmpeg" again to
get a binary that allows testing if you found the actual issue.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Carl Eugen Hoyos-2
2018-03-08 18:21 GMT+01:00, Carl Eugen Hoyos <[hidden email]>:

> 2018-03-08 17:58 GMT+01:00, Mark Burton <[hidden email]>:
>> Thanks. I have managed to compile a usable ffmpeg using brew (I work
>> exclusively on macOS), but I have not figured out how I would be able to
>> edit the libavformat/movenc.h file before compiling using this method. It
>> seems I would need to go down the route, so any help to get that far
>> would
>> be so welcome.
>
> You need a compiler, make and git. Iirc, all three are installed if you
> type something like "gcc -v" on the command line (but I assume they
> are now installed by brew).
>
> $ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

An faster equivalent that does not involve git is:
$ curl -O http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
$ tar xf ffmpeg-snapshot-git.tar.bz2

> $ cd ffmpeg
> $ ./configure && make ffmpeg
> This could for example fail if you don't have a new enough yasm or nasm
> binary, in that case please try "./configure --disable-yasm", feel free to
> add "--enable-gpl". If you know hat your cpu has - for example - four
> cores, you can use "make -j4 ffmpeg" to speed up compilation.
>
> This creates a current ffmpeg binary, please test (from the build
> directory) if it allows to reproduce your issue.
> Then edit libavformat/movenc.h and run "make ffmpeg" again to
> get a binary that allows testing if you found the actual issue.
>
> Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
In reply to this post by Carl Eugen Hoyos-2
On 8 Mar 2018, at 17:21, Carl Eugen Hoyos <[hidden email]> wrote:
> You need a compiler, make and git. Iirc, all three are installed if you
> type something like "gcc -v" on the command line (but I assume they
> are now installed by brew).

Thank you very much! That filled in a few blanks for me and I was able to get it all working. So I built from the current git and tested the ffmpeg build. The timescale issue was still the same, with inaccurate seeking.

Then in movenc.h I changed MOV_TIMESCALE from 1000 to 24000 and built ffmpeg again. This time the output .mov worked, with no seeking issues!

Finally in movenc.h I changed MOV_TIMESCALE to 600 and built ffmpeg again. Again, the output .mov worked, with no seeking issues!

I imagine some exhaustive testing is needed for other workflows, and I’m obviously not aware yet of why 1000 was chosen for ffmpeg (??), but based on the Quicktime specification documents and what the default timescale is set to there, it would seem that a switch from 1000 to 600 could be a very positive change.

Please could you advise what I would need to do from here to move things forward.

Many thanks again for your time and help getting ffmpeg built.

Regards
Mark
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Carl Eugen Hoyos-2
2018-03-08 22:20 GMT+01:00, Mark Burton <[hidden email]>:

> On 8 Mar 2018, at 17:21, Carl Eugen Hoyos <[hidden email]> wrote:
>> You need a compiler, make and git. Iirc, all three are installed if you
>> type something like "gcc -v" on the command line (but I assume they
>> are now installed by brew).
>
> Thank you very much! That filled in a few blanks for me and I was able to
> get it all working. So I built from the current git and tested the ffmpeg
> build. The timescale issue was still the same, with inaccurate seeking.
>
> Then in movenc.h I changed MOV_TIMESCALE from 1000 to 24000 and built ffmpeg
> again. This time the output .mov worked, with no seeking issues!
>
> Finally in movenc.h I changed MOV_TIMESCALE to 600 and built ffmpeg again.
> Again, the output .mov worked, with no seeking issues!
>
> I imagine some exhaustive testing is needed for other workflows, and I’m
> obviously not aware yet of why 1000 was chosen for ffmpeg (??), but based on
> the Quicktime specification documents and what the default timescale is set
> to there, it would seem that a switch from 1000 to 600 could be a very
> positive change.

> Please could you advise what I would need to do from here to move things
> forward.

One possibility is that you run "git diff libavformat/movenc.h" to verify you
have only changed this one value (this assumes you have originally done
"git clone" and not "curl..."), then run "git commit libavformat/movenc.h" to
start the commit line editor, type "i" (I believe this will be necessary to get
into insert mode) and "lavf/movenc: Change MOV_TIMESCALE
to 600" followed by two (!) carriage returns and an explanation why this is
a good idea (because seeking works better in some other software), then
exit the editor (it's "ESC" ":wq" here) and get back to the shell. There, run
"git format-patch HEAD^" to get a file 0001-lavf-movenc... that you send
as attachment to the ffmpeg-devel mailing list and "git reset HEAD^" to
clean your local checkout.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton
On 8 Mar 2018, at 22:29, Carl Eugen Hoyos <[hidden email]> wrote:

> One possibility is that you run "git diff libavformat/movenc.h" to verify you
> have only changed this one value (this assumes you have originally done
> "git clone" and not "curl..."), then run "git commit libavformat/movenc.h" to
> start the commit line editor, type "i" (I believe this will be necessary to get
> into insert mode) and "lavf/movenc: Change MOV_TIMESCALE
> to 600" followed by two (!) carriage returns and an explanation why this is
> a good idea (because seeking works better in some other software), then
> exit the editor (it's "ESC" ":wq" here) and get back to the shell. There, run
> "git format-patch HEAD^" to get a file 0001-lavf-movenc... that you send
> as attachment to the ffmpeg-devel mailing list and "git reset HEAD^" to
> clean your local checkout.

Fantastic. I’ve just submitted the patch to the developer list. Will do my best to answer the questions that come my way!

Thanks again Carl.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Quicktime - Specify a Movie Header timescale of 24000

Mark Burton


> On 8 Mar 2018, at 23:37, Mark Burton <[hidden email]> wrote:
>
> On 8 Mar 2018, at 22:29, Carl Eugen Hoyos <[hidden email] <mailto:[hidden email]>> wrote:
>> One possibility is that you run "git diff libavformat/movenc.h" to verify you
>> have only changed this one value (this assumes you have originally done
>> "git clone" and not "curl..."), then run "git commit libavformat/movenc.h" to
>> start the commit line editor, type "i" (I believe this will be necessary to get
>> into insert mode) and "lavf/movenc: Change MOV_TIMESCALE
>> to 600" followed by two (!) carriage returns and an explanation why this is
>> a good idea (because seeking works better in some other software), then
>> exit the editor (it's "ESC" ":wq" here) and get back to the shell. There, run
>> "git format-patch HEAD^" to get a file 0001-lavf-movenc... that you send
>> as attachment to the ffmpeg-devel mailing list and "git reset HEAD^" to
>> clean your local checkout.
>
> Fantastic. I’ve just submitted the patch to the developer list. Will do my best to answer the questions that come my way!

Was the resubmit correct?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".