I have a .h264 video file with a separate text file containing timestamps for each frame in timestamp v2 format. Where the starting frame doesn't necessarily start with a timestamp value 0.

I want to containerize both files into a VFR .mp4 container where the PTS frame values are populated from the timestamp text files.

I found this repo https://github.com/nu774/mp4fpsmod that supposedly solves this, but in my case, the timestamps are sometimes duplicated and two consecutive frames have the same PTS value. In this case mp4fpsmod hangs.

Is there another way to construct the .mp4 with duplicated timestamps? Or if I could somehow be able to drop the duplicated timestamps and corresponding frames in the h264 file.

I did manage to convert to a VPF .mkv file with mkvmerge, but I would need to show the video in a browser, which is not possible with an mkv.

  • $\begingroup$ Did you figured out a solution for your problem? I have kinda similar issue where I have VFR h264 bitstream and a way to corelate frames with timestamps outside of it and looking for similar solution (my thread) $\endgroup$
    – Adam Szmyd
    Mar 11, 2022 at 9:34
  • $\begingroup$ @AdamSzmyd unfortunately no. The VFR isn't that important for the project I'm working on, so this segment is currently on hold. But did you try with the mp4fpsmod repo I referenced? There you can pass change the timestamps of a mp4 file by passing a text file with timestamps. It wasn't helpful to me, only because I had duplicate consecutive timestamps (non monotonic). $\endgroup$
    – Jaka
    Mar 12, 2022 at 11:03


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.