[FFmpeg-user] Recording from a stream
jean-marie.baran at ama.bzh
Mon Dec 21 18:41:10 CET 2015
I am trying to use ffmpeg in order to record a video and an audio
stream. The incoming video stream is MJPEG at an average of 15 fps; the
audio stream is PCM16 (s16le).
I use the ffmpeg tool to convert these streams respectively to H.264
(with libx264) and AAC, in an MP4 container.
The problem is that when playing back the record, the video is (a lot)
too fast, but audio is fine (any player, VLC, ffplay, ...). However if I
specify the input fps ("-r 15"), the video is near the required speed.
But as rate at which I receive the video frame is not constant, the
video speeds up/down very often.
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», but so far each time I remove
"-r 15" the video plays too fast.
Here are my options:
-thread_queue_size 1024 # Because ffmpeg told me to do it
-i tcp://localhost:35647?listen=1 # Audio comes from a socket
-thread_queue_siwe 1024 # It told me to do it for video too
-i - # Video comes from stdin
-preset fast -crf 28 # libx264 options
-vsync vfr # Tried everything: passthrough, cfr, vfr and auto
-r:v 15 #
-strict -2 -acodec aac # Encode in AAC
Moreover I would like not to hardcode the framerate here, because this
command is invoked from a program, that I do not want to change if the
input stream switch to 30fps for example.
I read about pts and dts to adjust the time at which frames are actually
displayed. In a worst case, it is at least possible to specify the fps
but tell ffmpeg to use these so that the video stays are a correct speed ?
More information about the ffmpeg-user