1

I am recording and piping my video with the following command :

raspivid -w 1920 -h 1080 -fps 25 -b 7000000 -o - -t 0 | ffmpeg -re -f h264 -framerate 25 -i - -vcodec copy -y -r 25 -strict experimental /media/video/testyolol.mp4

It does work for some time but the longer the recording is the lower is the speed and the fps drop slightly. I first started at 30 fps and after ~20min the fps was down to 26. And setting the fps to 25 also results in a drop after some time. Here is the output in the first few seconds :

frame=   15 fps=0.0 q=-1.0 size=     439kB time=00:00:00.56 bitrate=6421.2kbits
frame=   27 fps= 27 q=-1.0 size=     891kB time=00:00:01.04 bitrate=7021.2kbits
frame=   40 fps= 26 q=-1.0 size=    1352kB time=00:00:01.56 bitrate=7096.9kbits
frame=   52 fps= 26 q=-1.0 size=    1754kB time=00:00:02.04 bitrate=7044.8kbits
frame=   65 fps= 26 q=-1.0 size=    2302kB time=00:00:02.56 bitrate=7365.8kbits
frame=   78 fps= 26 q=-1.0 size=    2675kB time=00:00:03.08 bitrate=7115.6kbits
frame=   90 fps= 25 q=-1.0 size=    3065kB time=00:00:03.56 bitrate=7053.7kbits
frame=  103 fps= 25 q=-1.0 size=    3508kB time=00:00:04.08 bitrate=7042.8kbits
frame=  116 fps= 25 q=-1.0 size=    3953kB time=00:00:04.60 bitrate=7039.9kbits
frame=  128 fps= 25 q=-1.0 size=    4426kB time=00:00:05.08 bitrate=7137.2kbits
frame=  141 fps= 25 q=-1.0 size=    4828kB time=00:00:05.60 bitrate=7062.7kbits
frame=  153 fps= 25 q=-1.0 size=    5222kB time=00:00:06.08 bitrate=7036.0kbits
frame=  166 fps= 25 q=-1.0 size=    5672kB time=00:00:06.60 bitrate=7040.6kbits

And here after 20~ min

frame=37003 fps= 24 q=-1.0 size= 1264751kB time=00:24:40.08 bitrate=7000.2kbits
frame=37039 fps= 24 q=-1.0 size= 1265996kB time=00:24:41.52 bitrate=7000.3kbits
frame=37052 fps= 24 q=-1.0 size= 1266428kB time=00:24:42.04 bitrate=7000.2kbits
frame=37065 fps= 24 q=-1.0 size= 1266854kB time=00:24:42.56 bitrate=7000.1kbits/ 

As you can see the fps drop to 24 which resulst in the safed file not beeing 25min long if i have recorded for 25min meaning the recording is slightly sped up. Roughly 1min is missing after 20min of recording.

Is there a way to ensure the recorded file is as long as the actual recording and not sped up (important for my current project)?

  • 1
    why have you added -strict experimental? – Jaromanda X Mar 14 at 3:36
  • i was using different options to improve performance and one user suggested to test it out. But it doesn't matter if i use it or not tbh. – huialx Mar 14 at 12:17
1

The -framerate option before the -i basically tells ffmpeg to trust that the input framerate is what you tell it is, and not rely on frame timestamps. Obviusly, raspivid is not holding its part of the deal and doesn't provide steady 25 fps.

Try to let ffmpeg find out the framerate on its own by specifying only the output framerate (-r 25 after the -i). If that doesn't help, you'll have to find a way to make raspivid deliver what you ask for, perhaps settling for less fps or lower resolution.

  • i just tried it out with only the output stream set to 25 fps but it was even worse. In a 10min recording the resulting video was only 8min long. – huialx Mar 14 at 20:12
  • @huialx That sounds like a bug in raspivid which doesn't seem to provide reliable frame timestamps. – Dmitry Grigoryev Mar 15 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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