nico.fyi
    Published on

    Reduce video size with ffmpeg

    You don't need to download any app, just use FFMPEG

    Authors

    Recently there's some people on Twitter sharing a free Mac app that can compress video significantly while maintaining quality. After giving away my e-mail address, I downloaded the app and ran it. First thing I saw was a window asking me to enter the path for ffmpeg. Guess it's using ffmpeg under the hood.

    So I asked ChatGPT for an ffmpeg command to reduce video size while maintaining the quality. It gave me this:

    ffmpeg -i input.mp4 -vcodec libx264 -crf 37 output.mp4
    

    I can set the crf value between 1 - 51 to adjust the quality of the video where higher number means worse quality. And turned out it's correct. I could reduce a 17 MB MP4 video down to 1.9 MB or less depends on the crf value.

    Afterwards, I could add that command to Forklift so that I don't need to open terminal to compress video files.

    #!/bin/sh
    
    /opt/homebrew/bin/ffmpeg -i $SOURCE_SELECTION_PATHS  -vcodec libx264 -crf 27 "$SOURCE_SELECTION_PATHS"-compressed.mp4
    

    Image

    Here's a demo video how easy it is to compress videos in Forklift with that command:


    Btw, I'm making a book about Pull Request Best Practices. Check it out!