Menu

#463 Wrong fps information in MP4

Incorrect_result
open-accepted
6
2015-01-12
2010-03-05
roozhou
No

It seems MediaInfo uses dts to calculate duration of each frame for a video track. This is completely wrong. When a video is vfr or dts compression is used, MediaInfo reports weird min fps and max fps.
One should calculate duration in this way:
1) Calculate pts of each frame using dts + cts_offset
2) Sort all pts
3) duration of frame i should be dts[i] - dts[i-1]

Discussion

  • Jerome Martinez

    Jerome Martinez - 2010-03-05
    • status: open --> pending-invalid
     
  • Jerome Martinez

    Jerome Martinez - 2010-03-05

    I am not sure to understand the issue:
    - frame duration is given by the stts (Time To Sample) atom, with a sample count, and a sample duration.
    - Whatever is the frame order, theses frames have the duration from the stts atom.

    I don't need any PTS or DTS for MP4, because frame duration is given by stts atom, so I use it. The minimum frame rate is given by the maximum frame duration, and the maximum frame rate is given by the minimum frame duration.

    Why is this method wrong?

    Do you have a sample of weird min/max, and what would be "right" values?
    (I can provide a FTP server access if needed)

     
  • roozhou

    roozhou - 2010-03-05
    • status: pending-invalid --> open-invalid
     
  • roozhou

    roozhou - 2010-03-05

    STTS[i] only represents dts[i]-dts[i-1]. When you calculate PTS or frame duration you should also take CTTS into account.

    I will provide samples. Actually a less-than-1M sample will show the problem.
    Or you can download my x264 build from www.sourceforge.net/projects/direct264.

    Encode any cfr file with cmdline "x264.exe -o output.mp4 --force-cfr input.xxx". The output is cfr but mediainfo shows weird fps.

    e,g. The source is 30fps, I encode with b-pyramid. MediaInfo shows minfps=30, maxfps=120.

     
  • Jerome Martinez

    Jerome Martinez - 2010-03-06

    OK, STTS-base framerate computing works well when DTS difference is not less than PTS difference (a DTS is in synch with a PTS of another frame), but in the case on of direct264, there is intermediate DTS, so CTTS is neeeded to compute the real PTS difference.

     
  • Jerome Martinez

    Jerome Martinez - 2010-03-06
    • priority: 5 --> 6
     
  • roozhou

    roozhou - 2010-03-06

    Since MPC-HC's MP4 splitter does not handle initial delay correctly (causing A/V desync), I use DTS compression to eliminate initial delay. And ffmpeg also produce such files.

    I will be glad to see this problem being fixed.

     
  • Jerome Martinez

    Jerome Martinez - 2010-03-06

    I forgot to set the "Resolution" field to "Accepted", sorry. Done now.

     
  • Jerome Martinez

    Jerome Martinez - 2010-03-06

    Accepted.

    Warning: non-paid bugs are set to low priority, I don't know when I have time to handle it.
    If you desire to accelerate the development, don't hesitate to contact me for a quotation.

     
  • Jerome Martinez

    Jerome Martinez - 2010-03-06
    • status: open-invalid --> open-accepted
     

Log in to post a comment.