大容量のハード ドライブ (17 TB と考えてください) をスキャンして、特定のフォルダー内のビデオ ファイルのストレージの見積もりを見つけようとしています。さらに、ビデオ ファイルの特定の固有のプロパティを見つけようとしています。この目的は、2009 年にさかのぼるビデオ ファイルをサポートできるデジタル アセット管理システムの事例を作成することです。私は mediainfo を使用して各ビデオを検査しています。
ファイル サイズ/ストレージ カウントは機能していますが、ビデオ プロパティのハッシュをループ内の配列に追加するのに問題があります。私の目標は、メディア情報が各ビデオの特定のプロパティを調べ、それらをハッシュに入れ、そのハッシュを配列に追加することです。次に、ビデオ プロパティのすべてのハッシュを収集したら、uniq! を呼び出します。配列で、一意のビデオ プロパティが表示されるようにします。
私のコードの出力は現在、最後のビデオのビデオ プロパティを何度も返します。何が間違っているのかわかりません。何かアドバイス?
require 'yaml'
#!/usr/bin/ruby
library_path = ARGV[0]
files_list = Dir.glob("#{library_path}/**/*")
total_capture_scatch_and_exports_size = 0
video_audit = Hash.new()
video_info = []
codecs = Hash.new()
files_list.each do |filepath|
filename = File.basename(filepath.to_s)
filepath.chomp!
puts filename
folders_to_scan = ["/capture scratch/", "/capturescratch/", "/capture-scratch/", "/capture_scratch/", "exports", "export"]
file_size = File.size(filepath)
file_extension = File.extname(filepath)
if
folders_to_scan.any? { |folder| filepath.downcase.include? folder }
if
File.file?(filepath) && filename[0] != "." && file_extension != ".TIFF" && file_extension != ".TIF" && file_extension != ".tif" && file_extension != ".tiff" && file_extension != ".jpg" && file_extension != ".jpeg" && file_extension != ".JPG" && file_extension != ".JPEG"
duration = %x[mediainfo --Inform="General;%Duration/String3%" '#{filepath}'].chomp!
format = %x[mediainfo --Inform="General;%Format%" '#{filepath}'].chomp!
commercial_name = %x[mediainfo --Inform="General;%Format_Commercial_IfAny%" '#{filepath}'].chomp!
format_profile = %x[mediainfo --Inform="General;%Format_Profile%" '#{filepath}'].chomp!
writing_library = %x[mediainfo --Inform="General;%Encoded_Library%" '#{filepath}'].chomp!
video_audit[:filepath] = filepath
video_audit[:filename] = filename
video_audit[:duration] = duration
video_audit[:file_size] = file_size
video_audit[:format] = format
video_audit[:commercial_name] = commercial_name
video_audit[:format_profile] = format_profile
video_audit[:writing_library] = writing_library
video_audit[:file_extension] = file_extension
codecs[:filename] = filename
codecs[:format] = format
codecs[:commercial_name] = commercial_name
codecs[:format_profile] = format_profile
codecs[:writing_library] = writing_library
codecs[:file_extension] = file_extension
end
end
puts video_audit.to_yaml
puts codecs
video_info << codecs
total_capture_scatch_and_exports_size += file_size
end
puts "THE VIDEO INFO IS=======>>>> #{video_info}"
puts "THE UNIQUE CODECS ARE: #{video_info.uniq!}"
#1000**3 is for gigabytes (this is how finder on OSX calculates storage on the Drobo Harddrives)use 1024**3 ofr gibibytes
puts "The total filesize is : #{total_capture_scatch_and_exports_size/(1000**3).to_f} GB"