Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#9710 closed defect (fixed)

60/120 fps timecode are mis-read from QuickTime MOV

Reported by: jdachik01 Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords: timecode 59.94 mov
Cc: Marton Balint Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by jdachik01)

Summary of the bug:

Timecode of 59.94 fps content from a Panasonic GH5 is not being read correctly by newer versions of ffmpeg. Confirmed in versions of ffmpeg from 2020 and 2022. Works fine in a version from 2018. 2018 ffmpeg version timecode matches the timecode in the Panasonic XML metadata. Not sure if x64/x86 might play a role as well.

(Since first writing this ticket, I've discovered that timecode for 119.88 fps content from Panasonic S1H cameras cannot be read at all by ffmpeg's 2022 version, while the 2018 version of ffmpeg reads it fine. If the issue with GH5 59.94 footage is fixed, and the fix does not also address the issue with the S1H 119.88 fps footage, I can open up a new ticket, or amend this one. Just didn't want to add too much to this one right off the bat.)

Download link for GH5 file (35 MB): https://drive.google.com/file/d/1QsJokEmOhTr52ckC4QAk4VvnwZrsF9gV/view?usp=sharing

XML: : <StartTimecode>01:51:38:04</StartTimecode>

ffmpeg 2018: timecode : 01:51:38;04
ffmpeg 2022: timecode : 00:55:49;04

ffmpeg2022 -i P22C5054.MOV
ffmpeg version 5.0-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers

built with gcc 11.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100

Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'P22C5054.MOV':

Metadata:

major_brand : qt
minor_version : 537986816
compatible_brands: qt pana
creation_time : 2022-03-28T16:40:34.000000Z
com.panasonic.Semi-Pro.metadata.xml: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>

: <ClipMain xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:schemas-Professional-Plug-in:Semi-Pro:ClipMetadata:v1.0">
: <ClipContent>
: <GlobalClipID>060A2B340101010501010D2113000000EFD4DF4950BF56344063106100D20024</GlobalClipID>
: <Duration>60</Duration>
: <EditUnit>1001/60000</EditUnit>
: <EssenceList>
: <Video>
: <Codec BitRate="200">H264_422_Intra</Codec>
: <ActiveLine>1080</ActiveLine>
: <ActivePixel>1920</ActivePixel>
: <BitDepth>10</BitDepth>
: <FrameRate>59.94p</FrameRate>
: <TimecodeType>Drop</TimecodeType>
: <StartTimecode>01:51:38:04</StartTimecode>
: </Video>
: <Audio>
: <Channel>2</Channel>
: <SamplingRate>48000</SamplingRate>
: <BitsPerSample>16</BitsPerSample>
: </Audio>
: </EssenceList>
: <ClipMetadata>
: <Rating>0</Rating>
: <Access>
: <CreationDate>2022-03-28T16:40:34-06:00</CreationDate>
: <LastUpdateDate>2022-03-28T16:40:34-06:00</LastUpdateDate>
: </Access>
: <Device>
: <Manufacturer>Panasonic</Manufacturer>
: <ModelName>DC-GH5S</ModelName>
: </Device>
: <Shoot>
: <StartDate>2022-03-28T16:40:34-06:00</StartDate>
: </Shoot>
: </ClipMetadata>
: </ClipContent>
: <UserArea>
: <AcquisitionMetadata xmlns="urn:schemas-Professional-Plug-in:P2:CameraMetadata:v1.2">
: <CameraUnitMetadata>
: <Gamma>
: <CaptureGamma>V-LogL</CaptureGamma>
: </Gamma>
: <Gamut>
: <CaptureGamut>V-Gamut</CaptureGamut>
: </Gamut>
: </CameraUnitMetadata>
: </AcquisitionMetadata>
: </UserArea>
: </ClipMain>
:

Duration: 00:00:01.00, start: 0.000000, bitrate: 287839 kb/s
Stream #0:0[0x1](und): Video: h264 (High 4:2:2 Intra) (avc1 / 0x31637661), yuv422p10le(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 200403 kb/s, 59.94 fps, 59.94 tbr, 180k tbn (default)

Metadata:

creation_time : 2022-03-28T16:40:34.000000Z
vendor_id : [0][0][0][0]
timecode : 00:55:49;04

Stream #0:1[0x2](und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s16, 1536 kb/s (default)

Metadata:

creation_time : 2022-03-28T16:40:34.000000Z
vendor_id : pana
timecode : 00:55:49;04

Stream #0:2[0x3](und): Data: none (tmcd / 0x64636D74), 1 kb/s (default)

Metadata:

creation_time : 2022-03-28T16:40:34.000000Z
timecode : 00:55:49;04

At least one output file must be specified

ffmpeg2018 -i P22C5054.MOV
ffmpeg version N-91492-g9cb3d8fcb7 Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 7.3.1 (GCC) 20180710
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 21.105 / 58. 21.105
libavformat 58. 17.101 / 58. 17.101
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 26.100 / 7. 26.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100

Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'P22C5054.MOV':

Metadata:

major_brand : qt
minor_version : 537986816
compatible_brands: qt pana
creation_time : 2022-03-28T16:40:34.000000Z
com.panasonic.Semi-Pro.metadata.xml: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>

: <ClipMain xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:schemas-Professional-Plug-in:Semi-Pro:ClipMetadata:v1.0">
: <ClipContent>
: <GlobalClipID>060A2B340101010501010D2113000000EFD4DF4950BF56344063106100D20024</GlobalClipID>
: <Duration>60</Duration>
: <EditUnit>1001/60000</EditUnit>
: <EssenceList>
: <Video>
: <Codec BitRate="200">H264_422_Intra</Codec>
: <ActiveLine>1080</ActiveLine>
: <ActivePixel>1920</ActivePixel>
: <BitDepth>10</BitDepth>
: <FrameRate>59.94p</FrameRate>
: <TimecodeType>Drop</TimecodeType>
: <StartTimecode>01:51:38:04</StartTimecode>
: </Video>
: <Audio>
: <Channel>2</Channel>
: <SamplingRate>48000</SamplingRate>
: <BitsPerSample>16</BitsPerSample>
: </Audio>
: </EssenceList>
: <ClipMetadata>
: <Rating>0</Rating>
: <Access>
: <CreationDate>2022-03-28T16:40:34-06:00</CreationDate>
: <LastUpdateDate>2022-03-28T16:40:34-06:00</LastUpdateDate>
: </Access>
: <Device>
: <Manufacturer>Panasonic</Manufacturer>
: <ModelName>DC-GH5S</ModelName>
: </Device>
: <Shoot>
: <StartDate>2022-03-28T16:40:34-06:00</StartDate>
: </Shoot>
: </ClipMetadata>
: </ClipContent>
: <UserArea>
: <AcquisitionMetadata xmlns="urn:schemas-Professional-Plug-in:P2:CameraMetadata:v1.2">
: <CameraUnitMetadata>
: <Gamma>
: <CaptureGamma>V-LogL</CaptureGamma>
: </Gamma>
: <Gamut>
: <CaptureGamut>V-Gamut</CaptureGamut>
: </Gamut>
: </CameraUnitMetadata>
: </AcquisitionMetadata>
: </UserArea>
: </ClipMain>
:

Duration: 00:00:01.00, start: 0.000000, bitrate: 287839 kb/s

Stream #0:0(und): Video: h264 (High 4:2:2 Intra) (avc1 / 0x31637661), yuv422p10le(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 200403 kb/s, 59.94 fps, 59.94 tbr, 180k tbn, 119.88 tbc (default)
Metadata:

creation_time : 2022-03-28T16:40:34.000000Z
timecode : 01:51:38;04

Stream #0:1(und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s16, 1536 kb/s (default)
Metadata:

creation_time : 2022-03-28T16:40:34.000000Z
timecode : 01:51:38;04

Stream #0:2(und): Data: none (tmcd / 0x64636D74), 1 kb/s (default)
Metadata:

creation_time : 2022-03-28T16:40:34.000000Z
timecode : 01:51:38;04

At least one output file must be specified

Change History (17)

comment:1 by jdachik01, 2 years ago

Description: modified (diff)

comment:2 by jdachik01, 2 years ago

Description: modified (diff)

comment:3 by Balling, 2 years ago

Please provide the "S1H 119.88" file. You do understand it is just 120/1.001, right?

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

in reply to:  3 comment:4 by jdachik01, 2 years ago

Replying to Balling:

Please provide the "S1H 119.88" file. You do understand it is just 120/1.001, right?

Yes, I'm aware of the fractional values (29.97 = 30000/1001, etc.). And clearly there is some relation to the frame rate in comparison to 29.97 that is at play. It turns out I was wrong, in part, about the S1H file. I have a version of ffmpeg from 2020 that cannot read its timecode at all, but the one I just grabbed in the last few days can read it (though incorrectly). ffmpeg (from 2022) seems to be running some calculation against the starting timecodes for 59.94 and 119.88 fps content from these cameras. 59.94 timecodes are being chopped in half (01:00:00;00 might become 00:30:00;00), and 119.88 fps timecodes are being chopped to one quarter (01:00:00;00 might become 00:15:00;00).

Here's the S1H file. Thanks for the help!

Panasonic XML metadata: <StartTimecode>16:25:24:25</StartTimecode>
ffmpeg2018: timecode : 16:25:24;25
ffmpeg2022: timecode : 04:06:21;27

https://drive.google.com/file/d/1cg5iM3HWQZdGP5KR_gxxxWoqSU2mpKDy/view?usp=sharing

comment:5 by Balling, 2 years ago

; means it is drop-frame timecode. So looks like this

2d90d51c561c2e4c36a00d1ba666adee5028663c

01:00:00;00 might become 00:30:00;00

These are both drop frames. That means there are more frames than timecodes. So math is not that simple.

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

comment:6 by jdachik01, 2 years ago

Yes, I realize I was oversimplifying - I was just going for the gist of what was occurring by providing a simple example.

So, yes, every minute (except every tenth minute) I'd expect 29.97 fps content to drop two frames, 59.94 to drop four frames, and 119.88 to drop eight.

Last edited 2 years ago by jdachik01 (previous) (diff)

comment:7 by Marton Balint, 2 years ago

Cc: Marton Balint added
Keywords: mov added
Summary: 59.94 fps timecode mis-read60/120 fps timecode are mis-read from QuickTime MOV

Probably the same issue as in #9492.

comment:8 by jdachik01, 2 years ago

It does appear to be the same issue. The other ticket, though, made no mention that the problem did not affect ffmpeg versions from approx 2018 and earlier. That piece of information could prove useful in addressing the problem.

comment:9 by Marton Balint, 2 years ago

I guess time timecode should be in the frame rate of the stream, not in 30 fps, no? So the correct 120 fps timecode would be 16:25:24;100, and not 16:25:24;25.

comment:10 by Balling, 2 years ago

Yes, obviously, it will be 119 and then 0. Really, when is this thing going to be gone? After all it is also incorrect, every 9 hours 15 minutes drop frame still accumulates one frame (because for it there is no difference between 30/1.001 and 29.97, while the difference is there).

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

comment:12 by jdachik01, 2 years ago

It's up to you, but I would think most users would want ffmpeg to report the same timecode as listed in the Panasonic XML data, which reports only 2 frame digits (like Mediainfo). That is, unless I'm making an incorrect assumption - perhaps I just haven't yet come across an example that was greater than 100.

Last edited 2 years ago by jdachik01 (previous) (diff)

comment:13 by Balling, 2 years ago

Status: newopen

listed in the Panasonic XML data,

Well, then we need 120 fps sample that has timecode above 99. :) I mean, yes, it is a problem, sure. Please note we do not use xml BS. We look into tmcd. Last file here is affected too: https://samples.ffmpeg.org/mov/canon_6d/ (mvi_9114.mov has 00:00:08:46 timecode, not 00:00:08:23 as mediainfo reads and not 00:00:04:23 either). That file has 50.000 inetger framerate, that is why 46 is there. Pathetic!!!

That patch above fixes tmcd parsing, it is a little more complex as old style only support 30/1.001 frmae rate (though timecode only has 29.970 precision, which is quite funny).

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

comment:14 by Balling, 2 years ago

Your 120/1.001 fps video P1002234.MOV does have a timecode in XML metadata, and it is "Drop":

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\ZAQU\Downloads\P1002234.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 537986816
    compatible_brands: qt  pana
    creation_time   : 2021-10-20T12:28:50.000000Z
    com.panasonic.Semi-Pro.metadata.xml: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
                    : <ClipMain xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:schemas-Professional-Plug-in:Semi-Pro:ClipMetadata:v1.0">
                    :   <ClipContent>
                    :     <GlobalClipID>060A2B340101010501010D21130000004FE40E247A8692046041146104090070</GlobalClipID>
                    :     <Duration>840</Duration>
                    :     <EditUnit>1001/120000</EditUnit>
                    :     <EssenceList>
                    :       <Video>
                    :         <Codec BitRate="150">H265_420_LongGOP</Codec>
                    :         <ActiveLine>1080</ActiveLine>
                    :         <ActivePixel>1920</ActivePixel>
                    :         <BitDepth>10</BitDepth>
                    :         <FrameRate>119.88p</FrameRate>
                    :         <TimecodeType>Drop</TimecodeType>
                    :         <StartTimecode>16:25:24:25</StartTimecode>
                    :       </Video>
                    :       <Audio>
                    :         <Channel>2</Channel>
                    :         <SamplingRate>48000</SamplingRate>
                    :         <BitsPerSample>16</BitsPerSample>
                    :       </Audio>
                    :     </EssenceList>
                    :     <ClipMetadata>
                    :       <Rating>0</Rating>
                    :       <Access>
                    :         <CreationDate>2021-10-20T12:28:50-06:00</CreationDate>
                    :         <LastUpdateDate>2021-10-20T12:28:50-06:00</LastUpdateDate>
                    :       </Access>
                    :       <Device>
                    :         <Manufacturer>Panasonic</Manufacturer>
                    :         <ModelName>DC-S1H</ModelName>
                    :       </Device>
                    :       <Shoot>
                    :         <StartDate>2021-10-20T12:28:50-06:00</StartDate>
                    :       </Shoot>
                    :     </ClipMetadata>
                    :   </ClipContent>
                    :   <UserArea>
                    :     <AcquisitionMetadata xmlns="urn:schemas-Professional-Plug-in:P2:CameraMetadata:v1.2">
                    :       <CameraUnitMetadata>
                    :         <ISOSensitivity>640</ISOSensitivity>
                    :         <Gamma>
                    :           <CaptureGamma>V-Log</CaptureGamma>
                    :         </Gamma>
                    :         <Gamut>
                    :           <CaptureGamut>V-Gamut</CaptureGamut>
                    :         </Gamut>
                    :       </CameraUnitMetadata>
                    :     </AcquisitionMetadata>
                    :   </UserArea>
                    : </ClipMain>
                    :
  Duration: 00:00:07.01, start: 0.000000, bitrate: 144615 kb/s

But tcmd does have a drop frame timecode also!!

      creation_time   : 2021-10-20T12:28:50.000000Z
      vendor_id       : pana
      timecode        : 04:06:21;27
  Stream #0:2[0x3](und): Data: none (tmcd / 0x64636D74), 3 kb/s (default)
    Metadata:
      creation_time   : 2021-10-20T12:28:50.000000Z
      timecode        : 04:06:21;27

while if you using DaVinci resolve it is 16:25:24;100 (note the ";"). Wow, so XML metadata is buggy!!! Here is screenshot from Davinci!! https://imgur.com/a/W3SivTD

comment:15 by Marton Balint, 2 years ago

Resolution: fixed
Status: openclosed

comment:16 by Marton Balint, 2 years ago

Component: undeterminedavformat

comment:17 by Balling, 2 years ago

I will point out that XML metadata shows the ~4 times less for last field: frames.

Note: See TracTickets for help on using tickets.