FFmpeg MJPEG FPS Input to MP4 FPS Output Query

Hopefully someone can advise…

FFmpeg version 6.1.2

I have an application that compresses raw data to JPG files, these JPG files are then sent to a named Pipe within Linux. The named pipe is used as an input to FFmpeg, this input is used to generate an output MP4 that will be streamed via Apache to a Web Browser.

The FPS of the Input is set to 1 at the moment for testing (it will run at 40 eventually). The FPS of the output is using the default of 25.

My understanding from the FFmpeg documentation is that the input FPS of 1 will be duplicated 24 times to generate the output FPS of 25 – is this correct? The command I am running is as follows:

ffmpeg -y -i /tmp/streamfifo -movflags faststart+frag_keyframe+empty_moov -f mp4 live.mp4

What I actually get is 25 seconds of input frames output to 1 second of output frames, i.e. everything speeded up 25x.

I have played around with various -r settings, for example:

 ffmpeg -y -i /tmp/streamfifo -movflags faststart+frag_keyframe+empty_moov -r 25 -f mp4 live.mp4

But, I get the same result.

Clearly I am doing something wrong, any pointers?

Thankyou.

UPDATE:

Ok, so I have found that because FFmpeg is reading from a named pipe there is no way of FFmpeg knowing the input framerate by default. If you pass the "-use_wallclock_as_timestamp 1" flag and specify the output frame rate required via "-filter:v fps=25" then this will give me the desired output. However… if I use this in combination with the "-movflags faststart+frag_keyframe+empty_moov" flag then I get an output FPS of 0.3…

So, to summarise:

ffmpeg -y -use_wallclock_as_timestamp 1 -i /tmp/streamfifo -filter:v fps=25 -f mp4 live.mp4

Gives me 25 FPS on the Output with a 1 FPS input.

But,

ffmpeg -y -use_wallclock_as_timestamp 1 -i /tmp/streamfifo -movflags faststart+frag_keyframe+empty_moov -filter:v fps=25 -f mp4 live.mp4

gives me 0.3 FPS on the output with a 1 FPS input.

I need the -movflags faststart+frag_keyframe+empty_moov flag as I want to stream to a browser.

UPDATE NUMBER TWO:

Ok, apologies for the constant updates, I’m updating this as I go. So… it turns out that there is something “iffy” with the named pipe setup I think. If I restart my application to effectively reset the named pipe, and then run:

ffmpeg -y -use_wallclock_as_timestamp 1 -i /tmp/streamfifo -movflags faststart+frag_keyframe+empty_moov -filter:v fps=25 -f mp4 live.mp4

then I get the desired output, which is an MP4 file with an FPS of 25 that I can stream via Apache into a Web Browser and is seekable.

I think this might be the answer but I will know tomorrow after some more testing…