Live data from Hacker News

Make timelapses easily using FFmpeg

news.ycombinator.com

51–60 of 80 posts

Re: Make timelapses easily using FFmpeg

#51
post #21

I looked into using ffmpeg to “compress” video podcasts by lowering the framerate a lot, but it didn’t seem to do as much as I thought (about 50% size reduction). The theory was that a video podcast is mostly talking heads with an occasional chart on the screen, so you really only need a frame every second, or five seconds.

Reducing framerate doesn't help much when there isn't a lot changing between frames. Here are some better optimizations:

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

Re: Make timelapses easily using FFmpeg

#52
post #9

Nice, thanks! I tried using ffmpeg for a minor video editing task I had a few months ago - just a cut, crop, rescale, and volume adjust. I've tried a few of the mainstream GUI video editing tools, and IMO, they all have incomprehensible UIs, are way too bloated, and usually far too expensive for what I'm trying to do. FFmpeg may not be dead simple, but I find it much easier to skim the command line flag list to figur…

I found https://github.com/mifi/editly to be an intuitive frontend for this type of task - I used it to create a montage of several clips and was able to easily adjust parameters around timestamps and such to get the montage perfect

Re: Make timelapses easily using FFmpeg

#54
You can also glob with c printf style format.

    ffmpeg -framerate 30 -i image-%05d.jpg -c:v libx265 -crf 35 -pix_fmt yuv420p timelapse.mp4
Will get images of the form image-00000.jpg, image-00001.jpg, ... image-99999.jpg.

Re: Make timelapses easily using FFmpeg

#55
Seems like there are a lot of experts here with FFmpeg, so perhaps one of you can help me.

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.

Re: Make timelapses easily using FFmpeg

#56
post #2

ffmpeg is such a great tool! Be 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.

I use -pattern_type glob on Windows without issue. Not sure how long I've been using it, at least a year, possibly two. This is what I use:

    ffmpeg -framerate 30 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p out.mp4

Re: Make timelapses easily using FFmpeg

#57

Is there a variant that encodes ProRes lossless? 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.

FWIW, ProRes isn’t a lossless codec (tho it should be perceptually lossless in most cases). Ffmpeg can encode into ProRes, but it’s technically an unofficial implementation. What issues do you run into with image sequences?

Right, calling it technically lossless is wrong but 422 HQ gives impressive results so I we can probably safely say that it is "practically" lossless.

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.

Re: Make timelapses easily using FFmpeg

#58

Where FFMPEG really shines is stabilising video. 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

I took some side photos of my pregnant wife, hoping to make a time-lapse, but I never got around to it. The photos aren’t perfectly aligned since her position changes a bit in each one. Can ffmpeg fix that?

Re: Make timelapses easily using FFmpeg

#59
post #47

Where FFMPEG really shines is stabilising video. 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

How about $ ffmpeg-english "capture video from the camera every 1 second and write it to jpg files" $ ffmpeg-english "take all of the images ending with .jpg in this directory and make a 30fps timelapse of it" Sound awesome? Here's the code for ffmpeg-english: #!/usr/bin/env python3 import openai import sys import os import time # Ensure you have set your OpenAI API key as an environment variable openai.api_key = os.…

I love when my commands are not reproducible even in the same shell session.
Post reply on HN