0

I want to record video from a camera, save it to file, and at the same time have access to the last frame recorded.

One idea would be to use ffmpeg's Multiple Outputs functionality where I split the stream into two, one gets saved to file, one spits out the last recorded frame (ideally, the frames won't need to be written to disk, but piped onwards for processing).

What I don't know is how to get ffmpeg to spit "the last frame" from a stream.

Any ideas?

12.yakir
  • 313
  • 2
  • 9
  • Why not just extract the last frame from the saved file? – llogan Feb 15 '21 at 20:22
  • I might misunderstand you, but the idea here is to have it live: so the camera records to the file, and while it is doing so, I want to "continuously" extract frames from that stream. So 1 or 5 frames per second. – 12.yakir Feb 16 '21 at 09:40

1 Answers1

1

Output a video and continuously update an image every second

ffmpeg -i input.foo outputvideo.mp4 -r 1 -update 1 image.jpg

Output a video and output a new image every second

ffmpeg -i input.foo outputvideo.mp4 -r 1 images_%04d.jpg
  • Output will be named images_0001.jpg, images_0002.jpg, etc.

Also see

llogan
  • 121,796
  • 28
  • 232
  • 243
  • Great info, thank you. Is there a good way to pipe the last frame from some input? Something like this? `ffmpeg -i input_video.mp4 -r 1 -update 1 -f image2pipe -` – 12.yakir Feb 18 '21 at 19:37
  • 1
    @12.yakir No need for `-update 1` if you are not outputting to a single image file. Use `ffmpeg -i input_video.mp4 -r 1 -f image2pipe -` – llogan Feb 18 '21 at 19:55