Hacker News new | past | comments | ask | show | jobs | submit login

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




If you really wish to install all the available options, you can run:

brew install homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg --compact)


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?


Yes. That is how you make lively picture show.

Sometimes it tries to align unrelated objects, but that is just funny.


Avi? What is this 2002?


Dummy.avi is useless map of perceived jerkiness.


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) < 2:
            print("Usage: ffmpeg-english <task_description>", 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()


I love when my commands are not reproducible even in the same shell session.


Honestly, ffmpeg is awesome enough being able to do what it can with a one-liner..

And all without python dependency, or even internet access.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: