<p>When receiving frames from a raw input i.e. one without embedded timestamps, ffmpeg will assign timestamps in serial order, thus losing the temporal relation between the incoming frames.</p>

<p>When the difference in times is important, you can add <code>-use_wallclock_as_timestamps 1</code> before the input <code>-i</code>. This will assign the system time at time of receipt as the timestamp. Not perfect, as there may be jitter during the transport of the input, but better than the default behaviour.</p>

<p><code>vsync</code> is somewhat of a misnomer. It takes effect after filtering and is generally used to select between generating a constant (<code>cfr</code>) or variable frame rate (<code>vfr</code>) stream.</p>

CC BY-SA 4.0
2019-10-09T07:52:16.593Z
On some systems, I think i have some delay between the moment I send my data and ffmpeg receive it. Is there a way to use a txt file where I note the acquisition time from each of my frame and then reorder a video based on thoose new timeStamps ?
Paltoquet
CC BY-SA 4.0
2019-02-11T19:31:37.930Z
2019-02-11T19:31:37.930Z
Gyan
<p>I have a Qt application running, i hijack the openGL frameBuffer when a new frame has been rendered. A new frame is drawned when only some changes appear in the scene, so no constant frameRate.</p>

<p>Now i want to send those raw rgba pixels value to ffmpeg, I use this wonderfull link <a href="http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/" rel="nofollow noreferrer">http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/</a> to encode my input stream, but in the end i have a video where each frame has been concatenate with a constant time between each. </p>

<p>To clarify, if i am not updating my application for 1 sec, this halt won't appear in the final video.</p>

<p>I use this command line to encode:</p>

<pre><code>ffmpeg.exe -f rawvideo -vsync 1 -pix_fmt rgba -s 1172x768 -i - -threads 0 -y -pix_fmt yuv420p -b:v 8000K -vf vflip output.mp4
</code></pre>

<p>and i write in to my stream with:</p>

<pre><code>uchar* buffer = (uchar*)malloc(count);
fwrite(buffer, sizeof(char), count, m_ffmpeg);
fflush(m_ffmpeg);
</code></pre>

<p>I saw the vsync option, i use it with different values as output and input options, but it seems to have no effect.</p>

<p>I might be able to store the delta time in a .txt file if it can help.</p>

CC BY-SA 4.0
2019-02-08T09:12:25.400Z
Add `-use_wallclock_as_timestamps 1` before `-i`
Gyan
CC BY-SA 4.0
2019-02-08T10:11:43.067Z
work as a charm, thank you ! Is there some parameter of  ```-vsync``` to complete the gap we should take in to account ?
Paltoquet
CC BY-SA 4.0
2019-02-08T11:28:58.510Z
*some parameter of -vsync to complete the gap*? You mean, make a CFR video.
Gyan
CC BY-SA 4.0
2019-02-08T12:49:03.517Z
By default i think frame are dupplicated to fill the gap between 2 of my acquisitions. I don't know what would be the effect of setting ```-vsync 0``` and if it's relevant or not.
Paltoquet
CC BY-SA 4.0
2019-02-11T18:52:19.823Z
Hi @Gyan - I know this one is a really simple one, but if you post as an answer we can properly upvote your post and the OP can accept. That would really help. Thanks.
Dr Mayhem
<ffmpeg><framerate>
FFmpeg encode variable input framerate
Paltoquet
# FFmpeg encode variable input framerate

(Asked by: username_0 on 2019-02-08)

I have a Qt application running, i hijack the openGL frameBuffer when a new frame has been rendered. A new frame is drawned when only some changes appear in the scene, so no constant frameRate.
Now i want to send those raw rgba pixels value to ffmpeg, I use this wonderfull link http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/ to encode my input stream, but in the end i have a video where each frame has been concatenate with a constant time between each. 
To clarify, if i am not updating my application for 1 sec, this halt won't appear in the final video.
I use this command line to encode:
ffmpeg.exe -f rawvideo -vsync 1 -pix_fmt rgba -s 1172x768 -i - -threads 0 -y -pix_fmt yuv420p -b:v 8000K -vf vflip output.mp4

and i write in to my stream with:
uchar* buffer = (uchar*)malloc(count);
fwrite(buffer, sizeof(char), count, m_ffmpeg);
fflush(m_ffmpeg);

I saw the vsync option, i use it with different values as output and input options, but it seems to have no effect.
I might be able to store the delta time in a .txt file if it can help.

**Tags:** ffmpeg, framerate

> **Comments:**
> **username_1**: Add `-use_wallclock_as_timestamps 1` before `-i`  
> **username_0**: work as a charm, thank you ! Is there some parameter of  ```-vsync``` to complete the gap we should take in to account ?  
> **username_1**: *some parameter of -vsync to complete the gap*? You mean, make a CFR video.  
> **username_0**: By default i think frame are dupplicated to fill the gap between 2 of my acquisitions. I don't know what would be the effect of setting ```-vsync 0``` and if it's relevant or not.  
> **username_2**: Hi @username_1 - I know this one is a really simple one, but if you post as an answer we can properly upvote your post and the OP can accept. That would really help. Thanks.  

---

## 1 answers

### Answer by username_1 on 2019-02-11. Score: 5 | Accepted answer

When receiving frames from a raw input i.e. one without embedded timestamps, ffmpeg will assign timestamps in serial order, thus losing the temporal relation between the incoming frames.

When the difference in times is important, you can add `-use_wallclock_as_timestamps 1` before the input `-i`. This will assign the system time at time of receipt as the timestamp. Not perfect, as there may be jitter during the transport of the input, but better than the default behaviour.

`vsync` is somewhat of a misnomer. It takes effect after filtering and is generally used to select between generating a constant (`cfr`) or variable frame rate (`vfr`) stream.

> **Comments:**
> **username_0**: On some systems, I think i have some delay between the moment I send my data and ffmpeg receive it. Is there a way to use a txt file where I note the acquisition time from each of my frame and then reorder a video based on thoose new timeStamps ?  

---

