Create video from bunch of JPEGs
I have a CCTV camera that uploads JPEG images (.jpg) to an FTP server when it detects movement. We seem to get quite a few images, so I would like to make them into a video to ease viewing.
I've done several Google searches, but nothing quite produces what I expect to see. The folder I am using has over 2000 images which are named AyyMMddhhmmssff.jpg. If I need to rename, I can do that since I already find I need to for FFMPEG to work.
I'd like an image per second, or maybe 2 per second so the images are easy to view when playing the video back. Yes, I know that will result in a 20/40min+ video!
I'm happy with a Windows, macOS or Ubuntu solution! My preference would be Windows (since that is where the FTP server is).
ImageMagick
convert *.jpg video.mpg
This sounded great, nice and simple. However, I have tried on my Mac (installed via brew) and Ubuntu and both grind performance of the relative system to a halt and after 20 minutes, still not finished. I had to reboot the Mac as I couldn't do anything!
FFMPEG
ffmpeg -y -r 6 -f image2 -s 1920x1080 -i <path>\%06d.jpg -vcodec libx264 -pix_fmt yuv420p <path>/video.mp4
I'm no expert when it comes to using FFMPEG, but I have used it for several tasks and found it to be a great utility to have around. The above command does produce a video, but the images display too quickly removing the point of the video. I tried tweaking the values and can get it better, but not exactly what I am after. One attempt (setting -r 1
IIRC) resulted in a single image for the entire video! Its clear I don't understand the various arguments in the FFMPEG command even though I have looked at the manual!
If you rename the images to be consecutively numbered, then you can use
ffmpeg -y -framerate 1 -i <path>\%06d.jpg -r 5 -c:v libx264 -pix_fmt yuv420p <path>/video.mp4
Consecutively numbered, as in 000001.jpg
,000002.jpg
,000003.jpg
... Note that there are exactly 6 characters in each name, which satisfies the %06d
passed on to ffmpeg.
If you don't want to rename, then create a text file of the form,
file first.jpg
file second.jpg
file third.jpg
...
file last.jpg
and then
ffmpeg -f concat -r 1 -i list.txt -r 5 -c:v libx264 -pix_fmt yuv420p <path>/video.mp4