Last active
September 3, 2017 02:52
-
-
Save BenjaminKim/411e03bd6de2dab33bf5f570dc33edac to your computer and use it in GitHub Desktop.
It merges xhiaopang's 1 minute videos to 1 day video. 샤오팡의 1분짜리 결과물들을 모아서 하루짜리 비디오로 합쳐줍니다.
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
require 'fileutils' | |
require 'filemagic' | |
fm = FileMagic.new | |
entries = Dir.glob('*').select {|f| File.directory? f} | |
entries.each do |dir| | |
puts "PWD: #{Dir.pwd}" | |
Dir.chdir(dir) | |
puts "PWD: #{Dir.pwd}" | |
dirs = Dir.glob('*').select {|x| x =~ /\d{8}/}.sort | |
dirs.each do |working_directory| | |
Dir.chdir(working_directory) | |
puts "PWD: #{Dir.pwd}" | |
files = Dir.glob('*.mp4').select {|x| x =~ /\d\d_\d\d/}.select do |file| | |
fm.file(file).include?('MP4') | |
end | |
params = files.sort.join(' + ') | |
output_name = Dir.pwd.split('/').last + '.mp4' | |
system("mkvmerge -o #{output_name} #{params}", out: $stdout, err: :out) | |
Dir.chdir('..') | |
end | |
Dir.chdir('..') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment