Live data from Hacker News

Make timelapses easily using FFmpeg

news.ycombinator.com

41–50 of 80 posts

Re: Make timelapses easily using FFmpeg

#41
post #19

Been making timelapses with ffmpeg since forever, such a great tool. I try to always have a cam pointed at the sky and upload a snapshot every minute. A telegram command triggers the creation of a timelapse with a similar cli command like the OP. https://www.youtube.com/watch?v=5GvaFBzOu2c

Nice! What equipment do you use to capture? And does it push to some server... running RTSP?

I use an old Android phone with a long deprecated app called MobileWebCam (still available on certain sites) I removed the battery and connected the charger directly. It uploads a picture every minute, a Node.js backend creates the timelapse with ffmpeg. Currently experimenting with a TP-Link C520 cam and a Raspberry Pi. You can point the camera to different positions using ONVIF, use ffmpeg to grab the stream and take a snapshot, then process this again on the server. Downside is the wide angle / fish eye lens and occasionally a corrupted stream snapshot.

Re: Make timelapses easily using FFmpeg

#42

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?

Re: Make timelapses easily using FFmpeg

#43
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…

Blender has a very well done video editor, it's probably my favorite foss video editor so far. It also uses ffmpeg under the hood

Worth a try!

Re: Make timelapses easily using FFmpeg

#44
post #41

Earlier quoted context omitted.

Nice! What equipment do you use to capture? And does it push to some server... running RTSP?

I use an old Android phone with a long deprecated app called MobileWebCam (still available on certain sites) I removed the battery and connected the charger directly. It uploads a picture every minute, a Node.js backend creates the timelapse with ffmpeg. Currently experimenting with a TP-Link C520 cam and a Raspberry Pi. You can point the camera to different positions using ONVIF, use ffmpeg to grab the stream and ta…

Thank you, was looking for a cheap webcam security set up using the great near-wasted cameras on older android phones.

Re: Make timelapses easily using FFmpeg

#45
post #19

Been making timelapses with ffmpeg since forever, such a great tool. I try to always have a cam pointed at the sky and upload a snapshot every minute. A telegram command triggers the creation of a timelapse with a similar cli command like the OP. https://www.youtube.com/watch?v=5GvaFBzOu2c

Nice! What equipment do you use to capture? And does it push to some server... running RTSP?

If you want an all sky solution, zwoastro.com ships an all sky lens with many of their small sensor planetary cameras. There's also a selection of software to handle the photos, making time-lapse, uploading etc. It came in really useful for seeing the Aurora outburst. Here's a short write up I did for my local club recently: https://m.facebook.com/story.php?id=101640086556073&story_fb...

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.

Re: Make timelapses easily using FFmpeg

#46
post #39

Somewhat unrelated, but a beautiful tool for extracting screenshots from video: MoviePrint https://www.movieprint.org/ & https://github.com/fakob/MoviePrint_v004/

I use VLC for that.

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.

Re: Make timelapses easily using FFmpeg

#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.getenv("OPENAI_API_KEY")
    client = openai.OpenAI()

    def get_ffmpeg_command(task_description):
        # Call the OpenAI API with the task description
        response = client.chat.completions.create(
            model="gpt-4",
            messages=[
                {"role":"system", "content":"You are an expert in FFmpeg commands. Given the following English description of a task, you respond with the correct FFmpeg command. Do not include any other information in your response except for the command only."},
                {"role":"user", "content":task_description},
            ],
            max_tokens=150,
            temperature=0.5
        )
        command = response.choices[0].message.content.strip()
        return command

    def main():
        if len(sys.argv) ", file=sys.stderr)
            sys.exit(1)

        task_description = " ".join(sys.argv[1:])
        ffmpeg_command = get_ffmpeg_command(task_description)

        # some basic guardrails
        assert(ffmpeg_command.startswith("ffmpeg"))
        assert(";" not in ffmpeg_command)
        assert("|" not in ffmpeg_command)

        print(f"Executing command: {ffmpeg_command} in 2 seconds (^C to cancel)")
        time.sleep(2)
        os.system(ffmpeg_command)

    if __name__ == "__main__":
        main()

Re: Make timelapses easily using FFmpeg

#48
post #11

I'd recommend Da Vinci Resolve for making timelapses. It performs really well and let's you scrub through before rendering anything which lets you clip just the part that you need. Plus you get the benefit of high export quality which can be fiddly with ffmpeg.

Resolve is insanely heavyweight for such a simple task. Those video editor UIs are incredibly hard to understand for people not using them every day.

I would argue that ffmpeg has the hardest to understand interface in the video editing space (unless you can find a command someone else came up with that does exactly what you want)

Re: Make timelapses easily using FFmpeg

#49
I use a Raspberry Pi Zero with a Pi Camera and ffmpeg to make timelapses of plants growing from seedlings each season when we plant tomatoes/potatoes/etc. It's a great way to show the kids how different plants grow from seed, and such a cheap/easy project.

Bash script running on a cron job every hour with:

    DATE=$(date +"%Y%m%d%H%M")
    raspistill -o /home/pi/timelapse/$DATE.jpg -awb off -awbg 1.8,1.6
Then another bash script running once a week:

    DATE=$(date +"%Y%m%d%H%M")
    ffmpeg -framerate 12 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p -vf 'scale=1920:-2,crop=1920:1080:0:(in_h-1000)' 'timelapse-$DATE.mp4'
    scp timelapse-$DATE.mp4 username@my.server:/home/user/
(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)

Re: Make timelapses easily using FFmpeg

#50
FFMpeg really helped me out not too long ago. I tried KDenLive and ShotCut to edit some videos, which I rarely do, only to be overwhelmed and then discover that ffmpeg command can do everything from timelapses to trimming and brightness/contrast adjustments. And you can "preview" the result too, using ffplay.
Post reply on HN