Opened 3 years ago

Closed 3 years ago

#9390 closed defect (fixed)

Wrong FPS used for timecode computation mangles timecodes

Reported by: Marcelo Magnasco Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: timecode
Cc: Marcelo Magnasco Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Marcelo Magnasco)

Summary of the bug:
ffprobe reports the wrong timecode for footage generated by my GoPro 9 Black cameras. The error is due to ffprobe/ffmpeg mangling the frame rate from 29.97 or 59.94 to 29/1 or 59/1.

For example, footage with start timecode 10:59:47:14, 29.97fps, is reported by ffprobe as having start timecode 11:22:32:16, which is equal to (10:59:47:14)*30/29.

How to reproduce:

% ffprobe GP001.MP4
where GP001.MP4 is a 29.97fps clip from a GoPro, includes in its output a black-backgrounded line
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffb6b80ac00] Using non-standard frame rate 29/1

The incorrect framerate 29 is used to convert the timecode from frames-since-midnight to HH:MM:SS:FF format. 

PLEASE SEE THE ATTACHED FILE AND NOTE 

ffmpeg version 4.2.1-tessus 
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (1)

C5GL010008.mp4 (1.3 MB ) - added by Marcelo Magnasco 3 years ago.
one of the files in the test set

Download all attachments as: .zip

Change History (13)

comment:1 by Balling, 3 years ago

Please add a sample. Also a consensus is that timecode drop and non-drop only applies to 29.97 (yeah, drop timecode does not know that it is 30/1.001 actually and is wrong after a couple of days, see wiki https://en.wikipedia.org/wiki/SMPTE_timecode#cite_ref-3).

It is a very common problem of Youtube that it uses absolutely wrong 29970/1000 instead of the correct 30000/1001 framerate too.

P.S. Of course drop timecode code does not apply here since 29/1 is integer framerate and thus drop and non-drop are the same.

Last edited 3 years ago by Balling (previous) (diff)

by Marcelo Magnasco, 3 years ago

Attachment: C5GL010008.mp4 added

one of the files in the test set

comment:2 by Marcelo Magnasco, 3 years ago

Description: modified (diff)

NOTE: the 2MB file size limit prevented me from attaching most of the files in the set. I was only able to attach file C5GL010008.mp4 . I have put up the files in our server: http://sur.rockefeller.edu/Plone/ffmpeg-timecode-issues

I made three clips (plus two LRV previews) with a GoPro Hero9 Black camera, pointing at a timeslate running on my desktop. The camera's clock is synced to my phone not to the slate so it's about one sec off from the 25fps timecode (which should be correct time of day).

GoPro cameras list all their FPSs as 60/120/240 but they are in fact NTSC 59.94... etc.

C5GX010007.MP4 1080p/240fps
C5GH010008.MP4 1080p/120fps
C5GL010008.mp4 480p/60fps preview of 008
C5GH010009.MP4 1080p/60fps
C5GL010009.mp4 480p/60fps preview of 009

Timecode of first frame in movie and timecode displayed on slate on first frame nondrop/30, vs. timecode reported by ffprobe

@@@@@@@@@ |. 1st frame. | on slate. |. ffprobe
C5GX010007.MP4 | 08:54:16:144 | 08:54:17:13 | 08:56:30:113
C5GH010008.MP4 | 08:55:05:017 | 08:55:05:27 | 08:59:34:81
C5GL010008.mp4 | 08:55:04:53 | 08:55:05:27 | 09:04:09:02
C5GH010009.MP4 | 08:55:50:00 | 08:55:51:04 | 09:04:54:54
C5GL010009.mp4 |08:55:50:00 | 08:55:51:04 | 09:04:54:54

Please note these are not small errors, ffprobe is off by many minutes, the more the slower the sampling rate.

You can compute easily that in the case of the file attached, the timecode reported by ffprobe, 09:04:09:02, equals (60/59)*08:55:04:53

Last edited 3 years ago by Marcelo Magnasco (previous) (diff)

comment:3 by Balling, 3 years ago

Yes please paste on dropbox:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffb6b80ac00] Using non-standard frame rate 29/1

file. "480p/60fps preview of 008" file you attached is useless.

comment:4 by Balling, 3 years ago

deleted

Last edited 3 years ago by Balling (previous) (diff)

in reply to:  3 comment:5 by Marcelo Magnasco, 3 years ago

Replying to Balling:

Yes please paste on dropbox:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ffb6b80ac00] Using non-standard frame rate 29/1

file. "480p/60fps preview of 008" file you attached is useless.

No, Balling, it is NOT useless. The clip is 59.94fps and read as such by every other software, but ffprobe sees both 59/1 and 59.94:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f911e00c400] Using non-standard frame rate 59/1 [...]
    Stream #0:0(eng): Video: h264 [...]  59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)

I have nevertheless uploaded all clips to our server:

http://sur.rockefeller.edu/Plone/ffmpeg-timecode-issues

Let me again reiterate: the only place in the ff suite where the FPS is incorrectly truncated to an integer is upon reading the timecode, whereby the truncated FPS is used to convert frames-since-midnight to hh:mm:ss:ff. Even if I transcode the clip using, say, ffmpeg concat, the new clip is created as 59.94 and the hh:mm:ss:ff is translated to frames-since-midnight using the correct frame rate.

comment:6 by Balling, 3 years ago

Interesting. Ffprobe does not print on your first file that here! Ha. Okay, will test further. Please note that it does not support 2 streams in it. That is known AFAIK, #8338.

in reply to:  6 comment:7 by Marcelo Magnasco, 3 years ago

Ohhh, it does not do that in your system? What timecode do you get?

I'm on a Mac, freshly installed ff* binaries. Maybe it's a Mac-specfic bug? I will test from our linux boxes on Monday.

% uname -a
Darwin xxxx 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64
% ffprobe C5GL010008.mp4
ffprobe version 4.2.1-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7ff3ed808600] Using non-standard frame rate 59/1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C5GL010008.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2021-08-27T08:55:37.000000Z
    firmware        : HD9.01.01.60.70
  Duration: 00:00:03.84, start: 0.000000, bitrate: 2842 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 848x480 [SAR 1:1 DAR 53:30], 2523 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro AVC  
      encoder         : GoPro AVC encoder
      timecode        : 09:04:09:02
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 187 kb/s (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro AAC  
      timecode        : 09:04:09:02
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro TCD  
      timecode        : 09:04:09:02
    Stream #0:3(eng): Data: bin_data (gpmd / 0x646D7067), 62 kb/s (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro MET  
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 100359 for input stream 3

Indeed as you state, stream 2 is not supported, this is known, but the telemetry stream (gpmd, 3) while unsupported is copied verbatim without issue. Those are not my problems.

Replying to Balling:

Interesting. Ffprobe does not print on your first file that here! Ha. Okay, will test further. Please note that it does not support 2 streams in it. That is known AFAIK, #8338.

comment:8 by Balling, 3 years ago

Status: newopen

Yes, that is MacOS bug (or maybe 4.2.1 is too old), here windows binaries from https://github.com/BtbN/FFmpeg-Builds/releases/tag/autobuild-2021-08-28-12-20 (BTW, you do not use Windows 10 on Macbook? I only use windows 10 on my Macbook)

PS C:\Users\XXXX> L:\5777\ffmpeg\bin\ffprobe.exe C:\Users\XXXX\Downloads\C5GL010008.mp4
ffprobe version N-103420-g1da524121c-20210828 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10-win32 (GCC) 20210408
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20210828
  libavutil      57.  4.101 / 57.  4.101
  libavcodec     59.  6.100 / 59.  6.100
  libavformat    59.  4.102 / 59.  4.102
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8.  4.100 /  8.  4.100
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\XXXX\Downloads\C5GL010008.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2021-08-27T08:55:37.000000Z
    firmware        : HD9.01.01.60.70
  Duration: 00:00:03.84, start: 0.000000, bitrate: 2842 kb/s
  Stream #0:0[0x1](eng): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709), 848x480 [SAR 1:1 DAR 53:30], 2523 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro AVC
      vendor_id       : [0][0][0][0]
      encoder         : GoPro AVC encoder
      timecode        : 08:55:04:53
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 187 kb/s (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro AAC
      vendor_id       : [0][0][0][0]
      timecode        : 08:55:04:53
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro TCD
      timecode        : 08:55:04:53
  Stream #0:3[0x4](eng): Data: bin_data (gpmd / 0x646D7067), 62 kb/s (default)
    Metadata:
      creation_time   : 2021-08-27T08:55:37.000000Z
      handler_name    : GoPro MET
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 98314 for input stream 3
PS C:\Users\XXXX>

Also, this

Unsupported codec with id 100359 for input stream 3

was changed since August 2020 to

Unsupported codec with id 98314 for input stream 3
Last edited 3 years ago by Balling (previous) (diff)

comment:9 by Balling, 3 years ago

You know there were some fixes (not related to the issue at hand, since that is drop-frame): 2d90d51c561c2e4c36a00d1ba666adee5028663c

comment:10 by Marcelo Magnasco, 3 years ago

Ok indeed 4.2.1 was too old, version N-103404-ga6f00d4e82-tessus seems to have solved this. I'll double check Monday and close the ticket if so.

comment:11 by Balling, 3 years ago

Did you check?

comment:12 by Marcelo Magnasco, 3 years ago

Resolution: fixed
Status: openclosed

Version N-103404-ga6f00d4e82-tessus fixed the problem.

Note: See TracTickets for help on using tickets.