Make timelapses easily using FFmpeg
I make a lot of Timelapse and have tried a lot of ways to make Timelapses using python etc, today I found the easiest one using FFMpeg :)
ffmpeg -framerate 30 -pattern_type glob -i '*.JPG' -c:v libx264 -r 30 -pix_fmt yuv420p timelapse.mp4
79 comments
[ 3.4 ms ] story [ 158 ms ] threadBe aware that -pattern_type glob is not supported on Windows, though, iirc. A workaround is to name your jpegs with consecutive numbers (not necessarily starting at 0) and use a pattern with a counter placeholder in it instead.
Note of support: ffmpeg supported many of the transcoding needs of my former employer back in 2007, being a "friendly" tool to the team. Yes it had/s issue. Being open source gave us a lifeline, to be able to fix our own stuff, and build up our video and audio live streaming and video watching white label service.
> The sortedness of glob.glob's output is platform-dependent.
https://bugs.python.org/issue33275#msg315254
https://pubs.acs.org/doi/10.1021/acs.orglett.9b03216
see https://trac.ffmpeg.org/wiki/Concatenate or https://shotstack.io/learn/use-ffmpeg-to-concatenate-video/
Also, an assumption in your command is that all the images are the same aspect ratio. If they’re not, you can use this to dynamically pad it out with black bars on either size:
‘-vf "scale=1920:1080:force_original_aspect_ratio=decrease:eval=frame,pad=1920:1080:-1:-1:eval=frame"’
https://mpeyton.com/posts/rimworld_timelapse_ffmpeg/
[0] https://lrtimelapse.com/
Also as an FYI to everyone, FFmpeg does support nVidia GPU acceleration but it might not be enabled in your build. So check if you use it a lot.
http://fixounet.free.fr/avidemux/
Another is ShutterEncoder:
https://www.shutterencoder.com/en/
Worth a try!
Is that something ffmpeg could do?
Is there any good resource for recipes like these?
I'm also working on a new one that uses an ASI533 Pro and a 4mm lens from a mirrorless camera to get better quality images.
Unfortunately not all versions have "vidstab".
ffmpeg -i "$1" -vf vidstabdetect=shakiness=5:show=1 dummy.avi
ffmpeg -i "$1" -vf yadif, format=yuv420p, vidstabtransform=zoom=2:optzoom=0:crop=black -c:v libx264 -b:a 32k stabilized264.mp4
Yesterweek's shaky video shot from a kayak: https://youtu.be/4pM0VeH4NE0?si=H2qTJfcvis3QmFlj
brew install homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg --compact)
And all without python dependency, or even internet access.
Sometimes it tries to align unrelated objects, but that is just funny.
Try encoding the video to AV1 with OPUS audio. You'll get ridiculous gainz!
My command is:
Noise reduction, so you compress less useless noise: -vf hqdn3d
Turn up the Constant Rate Factor. This will make better visual tradeoffs than decreasing frame rate. 23 is a good starting point for h264, but keep increasing it until you don't like how the content looks: -crf 23
Throw more CPU at the problem: -preset veryslow
I usually open them up in a new project just to create a lossless input video to work with in After Effects, and use that (if I use image sequence directly, DaVinci Resolve acts in weird ways).
ffmpeg might ease that AE part.
Ffmpeg can encode into ProRes, but it’s technically an unofficial implementation.
What issues do you run into with image sequences?
In DaVinci Resolve, many tools go awry with image sequences: for example temporal noise reduction simply doesn't work with a compound clip with image sequences, I also remember having problems with caching performance. I have a few very strange/buggy problems with Resolve though I love color grading with it regardless, so I want to avoid the buggy sides of Resolve (as it's one of the buggiest software I've ever used) but use the upsides of it (grading and some OpenFX filters).
It would help me on this process.
https://www.movieprint.org/ & https://github.com/fakob/MoviePrint_v004/
I press shift-s to take a snapshot, not sure if that's a default hotkey or I set it to that a long time ago.
In the preferences you choose where it will save to and what format.
Bash script running on a cron job every hour with:
Then another bash script running once a week: (Edited/simplified, I do a few other things in the scripts like compile the timelapse with pre-made timelapses and share via nginx on the Pi itself)I have a bunch of old videos that use MTS as the file extension. I would like to convert these to an MP4 (or MKV) file but I would like to do it while keeping the metadata (date taken, date created, etc.). Is there a way to do this?
The scripts I've seen change the file extension by just changing the container but they never keep the metadata which is a huge issue for me.
cat *.jpg | ffmpeg -r 90 -f image2pipe -i - -codec:v libx264 -preset fast -crf 23 -vf format=yuv420p video.mp4
https://youtu.be/RAsJE5ddt_U
Maybe someone needs it :)