Last active
August 29, 2015 13:57
-
-
Save tvararu/9597402 to your computer and use it in GitHub Desktop.
Compresses everything in a folder with ffmpeg using some arbitrary parameters. Outputs to a different folder. 85% savings in my experience, with no major loss in quality.
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
# How to run: | |
# | |
# $ cd ~/folder/that/contains/videos/in/original | |
# $ cd .. | |
# $ ls original/ | |
# video1.mp4 video2.mp4 | |
# | |
# $ ruby ffmpeg_compress.rb | |
# $ ls compressed/ | |
# video1.mp4 video2.mp4 | |
# | |
ORIGINAL_FOLDER = 'original' | |
COMPRESSED_FOLDER = 'compressed' | |
files = Dir["#{ORIGINAL_FOLDER}/*"] | |
files.each do |path| | |
newPath = path.sub(ORIGINAL_FOLDER, COMPRESSED_FOLDER) | |
cmd = "export INPUT=\"#{path}\" OUTPUT=\"#{newPath}\" && ffmpeg -y -i $INPUT -r 30000/1001 -b:v 400k -bt 500k -vcodec libx264 -acodec libfaac -ac 2 -ar 44100 -ab 128k $OUTPUT" | |
system(cmd) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very useful! :)