[FFmpeg-user] Recording from a stream
Jean-Marie Baran
jean-marie.baran at ama.bzh
Tue Dec 22 11:15:25 CET 2015
On 22/12/2015 10:11, Carl Eugen Hoyos wrote:
> Jean-Marie Baran <jean-marie.baran <at> ama.bzh> writes:
>
>> What I try to achieve here is to have Ffmpeg somehow
>> record the variation in the framerate. Ideally I
>> would tell it, «well, record the timestamp of the
>> frame as they arrive»,
> Which timestamp are you talking about?
> stdint cannot provide timestamps and is
> read as fast as possible.
>
> Where does the mjpeg stream originate?
> Whatever it is, you should try to use it
> as input for FFmpeg, maybe it provides
> timestamps...
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
The stream comes from a third-party application which sends at an
approximate rate of 15fps. It sends raw MJPEG frames alternated with
metadata which contains only the size of the next frame :
| size of next frame | MJPEG frame | size of next frame | MJPEG frame |
size of next frame | MJPEG frame | ...
My program reads this, remove the sizes, and send the frames on ffmpeg's
stdin. So indeed ffmpeg reads as fast as the frames arrive, which is
approximatively 15fps, but record a fixed frame rate of 15fps in the
mp4. For example, if "|" is the moment at which a frame arrives, and "-"
is a unit of time, the frames could arrive on stdin like this:
|---|--|-|--|----|-----|----|---|---| (1)
And ffmpeg will record it like this:
|---|---|---|---|---|---|---|---|---| (2)
So when playing back the video, at some moment it seems it is played too
quickly, at others too slowly. If that is possible, I would like ffmpeg
to record this irregularities into the mp4, so that players do not play
the video as it were a fixed frame rate.
On a side note, I imagined ffmpeg would be able to detect the fps (hence
my first question about removing "-r 15"), but I was wrong.
--
*Jean-Marie Baran*
More information about the ffmpeg-user
mailing list