fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.94k stars 880 forks source link

Generate video from jpeg stream without a constant FPS input #856

Closed fatbitx closed 5 years ago

fatbitx commented 6 years ago

Hi all,

I'm recording a video from an application that sends a stream of jpeg images. The problem is that the app only sends new frames when there are changes (like vnc for example). I've got kind of working video, but it plays very fast when no new frames arrived to the fluent-ffmpeg end. This app can send up to 30 fps, but it also can send one frame each 30 seconds if nothing changes in the image. So, if the original stream had a duration of 30 seconds I'd like to obtain a 30 seconds video.

Do you know if fluent-ffmepg can "fill" the gaps. I don't mind about file size, because I understand that by repeating frames you'll get a bigger output video file.

Version information

This is what I've tried so far:

Code to reproduce


FFmpeg(imagesStream)
    .inputOption('-re')
    .inputOption('-r 12')
    .videoCodec('libx264')
    .outputOption('-movflags frag_keyframe+faststart')
    .outputOption('-vsync 2')
    .outputOption('-r 24')
    .outputFPS(24)
    .outputOption('-pix_fmt yuv420p')
    .noAudio()
    .saveToFile(fileName)
    .run()

(note: if the problem only happens with some inputs, include a link to such an input file)

Expected results

If the original stream lasted for 30 seconds, I'd like to have a 30 seconds output video.

Observed results

If the original stream was 30 seconds with little changes in the actual images, the output video can be only of 5 seconds (this is just an example).

Checklist

Sorry to ask here, I don't know how to properly ask to ffmpeg directly, and maybe some of you know hot to achieve this.

Thanks for your help and your awesome project.

fatbitx commented 5 years ago

I still have a fast video playback when there's a low framerate input, but I close the issue because it was more a question than an issue. Keep rocking!