2

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.

5
  • Add -use_wallclock_as_timestamps 1 before -i
    – Gyan
    Feb 8, 2019 at 9:12
  • work as a charm, thank you ! Is there some parameter of -vsync to complete the gap we should take in to account ?
    – Paltoquet
    Feb 8, 2019 at 10:11
  • some parameter of -vsync to complete the gap? You mean, make a CFR video.
    – Gyan
    Feb 8, 2019 at 11:28
  • 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
    Feb 8, 2019 at 12:49
  • 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
    Feb 11, 2019 at 18:52

1 Answer 1

5

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.

1
  • 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
    Oct 9, 2019 at 7:52

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.