Created
April 4, 2021 00:01
-
-
Save DoodlingDev/d698fab019c2a2b931bff8893f6dcdfa to your computer and use it in GitHub Desktop.
Revisions
-
DoodlingDev created this gist
Apr 4, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ normalize_file = "./audio_normalize_results.txt" system "touch #{normalize_file}" files_list = Dir["./**/*"] files_list = files_list.select do |n| n.match(/\.mkv$/) || n.match(/\.mp4$/) || n.match(/\.avi$/) end files_list_total = files_list.length puts "#{files_list_total} files to convert" files_list = files_list.map do |n| full_filename = n.gsub(" ", '\ ') full_filename = full_filename.gsub("(", '\(') full_filename = full_filename.gsub(")", '\)') full_filename end files_list.each_with_index do |full_filename, index| puts "converting file number #{index} of #{files_list_total}" match_group = full_filename.match(/(^.+)\/([^\/]+)$/) dirname = match_group[1] filename = match_group[2] temp_filename = "#{dirname}/_#{filename}" puts "mv #{full_filename} #{temp_filename}" system "mv #{full_filename} #{temp_filename}" result = system "ffmpeg -i #{temp_filename} -af dynaudnorm -vcodec copy #{full_filename} -max_muxing_queue_size 9999" if result system "echo 'SUCCESS -> #{full_filename}' >> #{normalize_file}" system "rm #{temp_filename}" else system "echo 'FAILURE -> #{full_filename}' >> #{normalize_file}" end end system "cat #{normalize_file}"