Hello,

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:

ffmpeg -y
       -thread_queue_size 1024 # Because ffmpeg told me to do it
       -f s16le
       -i tcp://localhost:35647?listen=1 # Audio comes from a socket
       -r 15
       -f mjpeg
       -thread_queue_siwe 1024 # It told me to do it for video too
       -i - # Video comes from stdin
       -c:v libx264
       -preset fast -crf 28 # libx264 options
-vsync vfr # Tried everything: passthrough, cfr, vfr and auto without success
       -async 1
       -r:v 15 #
       -strict -2 -acodec aac # Encode in AAC
       -ar 44100

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 ?

Regards,
--
*Jean-Marie Baran*

_______________________________________________
ffmpeg-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

Reply via email to