3

I am constructing a video from a content that doesn't change at a constant rate (phone screen virtual display), in fact I receive frame only when there is such a change. Is it legal according to the standards to have inconsistent frame rate in a video? For example have frames with PTS of 0s, 0.066s, 0.1333s, 0.2s and then the next frame at 20s, etc?

It seems some players (Chrome) are struggling playing it back correctly, when encountering such a time gap, it sometimes start showing frames from the beginning of the video instead. Should I replicate the last frame myself to maintain a constant frame rate? Is there a way to instruct a codec (ffmpeg) to inject "skip frames" at a constant rate when such gaps are detected.

Thanks

Dmitry Fink
  • 1,032
  • 1
  • 13
  • 31
  • Are you executing a ffmpeg command or is it via API? – Gyan Jan 29 '16 at 19:20
  • 3
    And yes, it is legal for MP4s to have variable frame rate. – Gyan Jan 29 '16 at 20:00
  • 1
    @Mulvya besides it being legal, are there known compatibility issues with players? As I mentioned I see issues with Chrome built in player. As for command line or API, if its indeed a prolem in the real world, and needs to be fixed then both options are on the table: 1. use ffmpeg API while recording to generate constant fps 2. record with VFR, then have backend server transcode (with ffmpeg?) to inject missing frames. – Dmitry Fink Jan 29 '16 at 21:58

2 Answers2

1

Yes, as it's already mentioned by Mulvya mp4 supports variable frame rate.

You can look here to check if some containers including mp4 support variable frame rate.

As for duplicating or dropping frames you can do some experiments with -vsync option.

For example -vsync 1 allows to duplicate/drop frames to achieve exactly the requested constant frame rate.

Edgar Rokjān
  • 17,245
  • 4
  • 40
  • 67
0

It is legal for MP4s to have variable frame rate, but as you experienced, very irregular PTS patterns may cause playback problems.

To transcode to CRF MP4, which is default muxing mode for ffmeg, use via CLI:

ffmpeg -i input.mp4 -crf 18 -c:a copy -fflags +genpts output.mp4
Gyan
  • 85,394
  • 9
  • 169
  • 201