[FFmpeg-devel] (sponsored) feature request

Oliver Fromme oliver at fromme.com
Thu Jul 3 19:17:57 CEST 2014

 > From: "Oliver Fromme" <oliver at fromme.com>
 > > Just an idea ...  Would it help to provide a "wait" option?
 > > 
 > > In other words, you specify a timestamp on the command line
 > > that is in the near future (a minute or just a few seconds
 > > ahead), and that "wait" option would instruct ffmpeg to wait
 > > until the local system clock actually reaches that timestamp,
 > > right before starting the recording.
 > Great! I think that would do the trick just fine!
 > Interested in implementing it? (And if so, please send me a 64 bits binary 
 > for Windows, as I can't compile for Win...)

I'm not that familiar with the overall structure of the ffmpeg
source code, only with some small parts of it that I have worked
on so far.  And I don't have Windows at all, so I can't compile
a binary for Windows.

But it really should be easy to implement.  First chose a proper
name for the "wait" option, then you have to locate the place
where the waiting should take place if the option is used.  The
rest is trivial:  Use the gettimeofday() function to retrieve
the current system clock and subtract it from the desired
timestamp that was given on the command line.  The result is
the amount of time to wait, which can be performed with the
nanosleep() function.  You just have to keep in mind that
gettimeofday() returns microseconds, while nanosleep() expects
nanoseconds, so you have to convert.

All of that should be just a handful of lines of source code.
Probably less than the paragraph explaining it above.

In fact, the most difficult part of it (at least for me) would
be to find the appropriate location in the ffmpeg sources where
to add the code for waiting.  My guess would be right in front
of the "while" loop in the transcode() function in ffmpeg.c,
but I could be wrong.  You'll certainly find a developer who is
more familiar with the ffmpeg source code than me.

Best regards

``We are all but compressed light'' (Albert Einstein)

More information about the ffmpeg-devel mailing list