So you have those old videos taken in your handy-cam that you'd want to convert to mp4 for better compatibility across devices and less storage footprint? And you want to batch convert all these videos? |
This ruby-script should come handy for you.
STEP 1: Save a copy of the script in the directory where you've those old videos in .avi format, that you'd want to convert to mp4.
STEP 2: Run script as ruby convert_avi_to_mp4.rb
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
#!/usr/bin/env ruby | |
puts "Starting.." | |
#Dir['path/to/dir/*'].select { |e| File.file?(e) } | |
Dir.glob("./*.avi").each do |filename| | |
puts "Converting File name: #{filename}" | |
puts `mkdir "#{File.join( File.dirname(filename), "mp4")}"` | |
newfilename = File.join( | |
File.dirname(filename), | |
"mp4", | |
"#{File.basename(filename, '.avi')}.mp4") | |
`ffmpeg -i "#{filename}" "#{newfilename}"` | |
end | |
puts "The End.." |
Note: You should have ruby and ffmpeg installed in your system before you run this script.