Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framerate autodetection wildly inaccurate with certain content #90

Closed
joeyparrish opened this issue Aug 25, 2021 · 3 comments · Fixed by #93
Closed

Framerate autodetection wildly inaccurate with certain content #90

joeyparrish opened this issue Aug 25, 2021 · 3 comments · Fixed by #93
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@joeyparrish
Copy link
Member

I received a video from a colleague (drone.mp4) that breaks our framerate detection. We decide that it's 600 fps instead of 51.98, which leads to a bad keyframe interval for ffmpeg, which leads to failed segmentation.

Output from ffprobe:

$ ffprobe drone.mp4 
ffprobe version 4.3.2-0+deb11u2 Copyright (c) 2007-2021 the FFmpeg developers
...

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'drone.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2019-07-23T18:34:13.000000Z
  Duration: 00:00:27.24, start: 0.000000, bitrate: 17878 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709), 1920x1080, 17796 kb/s, 51.98 fps, 600 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2019-07-23T18:34:13.000000Z
      handler_name    : Core Media Video
      encoder         : H.264
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 61 kb/s (default)
    Metadata:
      creation_time   : 2019-07-23T18:34:13.000000Z
      handler_name    : Core Media Audio
@joeyparrish joeyparrish added the type: bug Something isn't working correctly label Aug 25, 2021
@joeyparrish joeyparrish added this to the v1.0 milestone Aug 25, 2021
@joeyparrish
Copy link
Member Author

As a workaround, the frame_rate field can be used on the video section of the input config for such content.

@mariocynicys
Copy link
Contributor

mariocynicys commented Sep 8, 2021

$ ffprobe zdrone.mp4 -select_streams v:0 -show_entries stream=avg_frame_rate -of compact=p=0:nk=1 2> /dev/null
169920/3269

This was using avg_frame_rate instead of r_frame_rate for the probing. This sof discusses the difference which i didn't quiet understand.

>>> 169920/3269
51.979198531661055

Update: I understand the difference now. The r_frame_rate will be different to fit some kind timestamp calculation when the video has mixed frame rates. See https://ffmpeg.org/faq.html#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e
I think we should use avg_frame_rate then.

@joeyparrish
Copy link
Member Author

Thank you for figuring this out! I'd be happy to review a PR.

joeyparrish pushed a commit that referenced this issue Sep 8, 2021
It seems that r_frame_rate may involve some calculation when the video has more than one frame rate (mixed frame rates).  FFmpeg will try to find the least common multiple of all the different frame rates in the video, which is not the value we want.

To avoid this, we can use avg_frame_rate instead.

See https://ffmpeg.org/faq.html#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e

Fixes #90
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Nov 7, 2021
@shaka-project shaka-project locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants