I am trying to use ffmpeg
to create a video out of an image file that is overwritten constantly. I'm checking the documentation and I can see this is achievable in reverse:
ffmpeg -y -f v4l2 -video_size 1280x720 -i /dev/video0 \
-r 0.2 -qscale:v 2 -update 1 /tmp/webcam.jpg
Is there a way I can recreate this video file from this /tmp/webcam.jpg
file that is being overwritten constantly with the new frame? Ie: Specify a time to loop over the same image?
In this case, an application is sending a new image every split second via a socket and being saved to /tmp/image.jpg
. I need to convert it to a one minute video for example whilst that image is being rewritten.
CodePudding user response:
Named pipe "proof of concept":
Create named pipe in Linux terminal:
mkfifo webcam_pipe
Execute FFmpeg command that reads from named pipe and writes video to
webcam.mkv
file:ffmpeg -y -r 1 -f image2pipe -vcodec mjpeg -i webcam_pipe -vcodec copy webcam.mkv
Open another console, and Execute FFmpeg command that writes JPEG images to the named pipe at 1Hz (60 seconds long):
ffmpeg -y -re -f lavfi -i testsrc=size=1280x720:rate=1 -t 60 -vcodec mjpeg -f image2pipe webcam_pipe
It's also working when the pipe name is /tmp/webcam.jpg
In your case "application is sending a new image via a socket", and I have no idea if it's going to work...