Last active
May 11, 2023 13:36
-
-
Save adipasquale/af5684a3d70f10a4b59b2d75a002fafa to your computer and use it in GitHub Desktop.
Compress and convert videos with ffmpeg and automator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open Automator | |
# create a new quick action | |
# select Movie files in Finder | |
# add action "Run Shell Script" | |
# select ruby as the shell and pass inputs as arguments | |
# enter this | |
require 'time' | |
ARGV.each do |input_path| | |
basename = File.basename(input_path, File.extname(input_path)) | |
output_path = "#{File.dirname(input_path)}/#{basename}.compressed.#{Time.now.utc.iso8601}.mp4" | |
command = "/opt/homebrew/bin/ffmpeg -i #{input_path} -vcodec libx264 -crf 20 #{output_path}" | |
system command, exception: true | |
system %{say "compression finished for movie #{basename}"}, exception: true | |
end | |
# save with the name you’d like |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# same as above with | |
require 'time' | |
ARGV.each do |input_path| | |
basename = File.basename(input_path, File.extname(input_path)) | |
output_path = "#{File.dirname(input_path)}/#{basename}.#{Time.now.utc.iso8601}.webm" | |
command = "/opt/homebrew/bin/ffmpeg -i #{input_path} -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus #{output_path}" | |
system command, exception: true | |
system %{say "compression finished for movie #{basename}"}, exception: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i video.mp4 -vcodec libx265 -crf 30 video.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i video.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus video.webm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment