Body: <p>I have a H264 video source that was recorded with variable framerate (VFR) and a text file with frame ID, timestamp pairs that looks like this:</p>
  
  <pre><code>frameId,timestamp
  1890413473,13792093
  1890413474,13792106
  1890413475,13792123
  1890413476,13792139
  ...
  </code></pre>
  
  <p>If I try to playback as is, it defaults to the 25 constant framerate (CFR) 
  <code>ffmpeg -i stream.h264 -c copy stream.mkv</code></p>
  
  <p>How do I combine the timestamp data to make a .mkv playing at the appropriate rate? The docs have <code>-vsync vfr</code> which looks related, but not sure about the input format for the times to sync with.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-26T15:57:40.067Z
Comments.Text: See https://stackoverflow.com/a/37893746
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-28T16:54:19.697Z
Comments.Text: I wrapped the h264 in an mp4 container and changed the text file to the timecode v2 format. Then the [mp4fpsmod](https://github.com/nu774/mp4fpsmod) was able to make the correct VFR video.
  I was able to do a similar thing with [mkvmerge](https://gitlab.com/mbunkus/mkvtoolnix) to work with mkv containers.
Comments.UserDisplayName: Phoenix
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-28T21:13:18.320Z
Comments.Text: However, is there a way for `ffmpeg` to do this or be more attuned to it? For instance if I try to convert the corrected vfr video to another format `ffmpeg -i stream_vfr.mp4 -c copy stream.mkv` I get mismatch values between `pkt_duration`, `pkt_dts` from the original from `ffprobe -show_frames`
Comments.UserDisplayName: Phoenix
Tags: <ffmpeg><framerate><h.264>
Title: ffmpeg convert H264 CFR + timestamps to VFR
UserDisplayName: Phoenix
ThreadText: # ffmpeg convert H264 CFR + timestamps to VFR
  
  (Asked by: username_0 on 2019-03-26)
  
  I have a H264 video source that was recorded with variable framerate (VFR) and a text file with frame ID, timestamp pairs that looks like this:
  
  ```
  frameId,timestamp
  1890413473,13792093
  1890413474,13792106
  1890413475,13792123
  1890413476,13792139
  ...
  
  ```
  
  If I try to playback as is, it defaults to the 25 constant framerate (CFR)
  `ffmpeg -i stream.h264 -c copy stream.mkv`
  
  How do I combine the timestamp data to make a .mkv playing at the appropriate rate? The docs have `-vsync vfr` which looks related, but not sure about the input format for the times to sync with.
  
  **Tags:** ffmpeg, framerate, h.264
  
  > **Comments:**
  > **username_1**: See https://stackoverflow.com/a/37893746  
  > **username_0**: I wrapped the h264 in an mp4 container and changed the text file to the timecode v2 format. Then the [mp4fpsmod](https://github.com/nu774/mp4fpsmod) was able to make the correct VFR video. I was able to do a similar thing with [mkvmerge](https://gitlab.com/mbunkus/mkvtoolnix) to work with mkv containers.  
  > **username_0**: However, is there a way for `ffmpeg` to do this or be more attuned to it? For instance if I try to convert the corrected vfr video to another format `ffmpeg -i stream_vfr.mp4 -c copy stream.mkv` I get mismatch values between `pkt_duration`, `pkt_dts` from the original from `ffprobe -show_frames`  
  
  ---
  
  ## 0 answers
  
  