Skip to content

Instantly share code, notes, and snippets.

@KrzaQ

KrzaQ/resizer.rb Secret

Last active August 29, 2015 14:18
Show Gist options
  • Save KrzaQ/7f1a59d3ad246e900c5b to your computer and use it in GitHub Desktop.
Save KrzaQ/7f1a59d3ad246e900c5b to your computer and use it in GitHub Desktop.
OutDir = 'out'
Scale = '640:-1'
AllowedExtenstions = ['avi', 'mp4']
def convert(filename, ext)
command = "ffmpeg -i #{filename}.#{ext} -vf scale=#{Scale} -strict -2 #{OutDir}/#{filename}_small.#{ext}"
p command
`#{command}`
end
Dir["./*.{#{AllowedExtenstions.join(",")}}"].map{ |f|
ext = AllowedExtenstions.find {|ext| f.end_with? ext }
base = File.basename(f, ".#{ext}")
[base, ext]
}.each{ |basename, ext|
convert(basename, ext)
# p [basename, ext]
}
# ffmpeg -i VID_20150407_220615_TU3.mp4 -vf scale=640:-1 -strict -2 VID_20150407_220615_TU3_small.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment