I have a camera which when motion is detected uploads JPG files at roughly one a second — so I want to take them and convert them back to video.

For the uploaded files

  • It sometimes skips a few uploads (up to about 3 second gaps)
  • They continue for around 20 seconds after motion has ceased
  • The files are 640×480 color 24-bit Depth and each is around 40K
  • The pictures vary in lighting between stills
  • There are no files once the motion detection has stopped — so a gap in files can be used to determine the end of video

So I want to use a script to make these into a video - I'd like to

  • Extend each JPG to the correct length of time
  • “watermark” the timestamp onto the video
  • Compress the video

For compression, I feel that the common background and large sections of unchanging video should be highly compressible

I'll be able to write the scripts which would include - the selection of the right set of files to include in each video - production of an intermediate parameter file - calculation of time span of each still image - determination of end of movie — including still currently recording

I'm running on a Window's laptop — but would consider a Raspberry Pi or Ubuntu system.

I've looked at FFmpeg but got a little lost of where to start — I did find possible-to-stream-append-images-into-an-existing-mp4. Which is close and I can start with this. However, one answer seemed to be saying that this may cause loss of fidelity with a comment saying no it won't. Also, I am unsure about how to make the JPGs extend to different lengths and how to watermark a time stamp onto each image

So my questions are What tool and encoding format is a good match with what I want ?

Should I make the script wait until the files are fully produced or is it possible to append one JPG file to the movie stream at a time with parameters without excessive loss of fidelity?

Is timestamping best done with a watermark on the video - or with some metadata tagging and require the renderer to display timestamps?

I have included one image from the camera

One Still Image

1 Answer 1


I would use shell scripting thus:

  • find the creation date of the first jpeg and the creation date of the subsequent jpeg.
  • if the time difference is <= 1 second then we have the start of a sequence. If the files are named sequentially then maybe move them to a subfolder. If not then move (or copy) the files to create a sequence.
  • while the time difference is <= 1 second keep updating the last frame of the sequence
  • once we have a non-sequential file create a video using ffmpeg
  • set the new first frame to the non-sequential file
  • repeat for all the jpegs.
  • concatenate all the videos

ffmpeg can create a video from an image sequence where the files are named frame_000.jpg, frame_001.jpeg, frame_002.jpg… thus:

ffmpeg -i frame_%03d.jpg -r 1 output.mp4

the -r 1 option sets the frame rate to 1 per second. If the sequence doesn't start with 000 then you can use -start_number 123 to specify the first frame. more details here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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