Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby mediainfo找到独特的属性_Ruby_Video_Metadata_Mediainfo - Fatal编程技术网

Ruby mediainfo找到独特的属性

Ruby mediainfo找到独特的属性,ruby,video,metadata,mediainfo,Ruby,Video,Metadata,Mediainfo,我正试图扫描一个大硬盘(想想17TBs),以找到特定文件夹中视频文件的存储估计值。此外,我还试图找到视频文件的特定独特属性。其目的是为数字资产管理系统提供一个案例,该系统可以支持2009年的视频文件。我用mediainfo检查每一个视频 我的文件大小/存储计数正常,但我在向循环中的数组添加视频属性哈希时遇到问题。我的目标是让media info查看每个视频的特定属性,将它们放入散列,然后将散列添加到数组中。然后,一旦我收集了视频属性的所有散列,我就会调用uniq!在阵列上,以便向我显示独特的视频

我正试图扫描一个大硬盘(想想17TBs),以找到特定文件夹中视频文件的存储估计值。此外,我还试图找到视频文件的特定独特属性。其目的是为数字资产管理系统提供一个案例,该系统可以支持2009年的视频文件。我用mediainfo检查每一个视频

我的文件大小/存储计数正常,但我在向循环中的数组添加视频属性哈希时遇到问题。我的目标是让media info查看每个视频的特定属性,将它们放入散列,然后将散列添加到数组中。然后,一旦我收集了视频属性的所有散列,我就会调用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"
需要“yaml”
#!/usr/bin/ruby
库路径=ARGV[0]
files_list=Dir.glob(“#{library_path}/***”)
总捕获量和导出量=0
video_audit=Hash.new()
视频信息=[]
codecs=Hash.new()
文件_list.each do |文件路径|
filename=File.basename(filepath.to_s)
filepath.chomp!
放置文件名
文件夹\u-to\u-scan=[“/capture-scratch/”、“/capturestrack/”、“/capture-scratch/”、“/capture-scratch/”、“/capture-scratch/”、“导出”、“导出”]
file\u size=file.size(文件路径)
file_扩展名=file.extname(文件路径)
如果
要扫描的文件夹。有吗?{| folder | filepath.downcase.include?folder}
如果
File.File?(文件路径)&文件名[0]!=“&&U文件扩展名!=“.TIFF”&文件扩展名!=“.TIF”和文件扩展名(&U)!=“.tif”和文件扩展名(&U)!=“.tiff”&文件扩展名!=“.jpg”&文件扩展名!=“.jpeg”&文件扩展名!=“.JPG”&文件扩展名!=“.JPEG”
持续时间=%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!
正在写入_-library=%x[mediainfo--Inform=“General;”%Encoded_-library%”“#{filepath}”。chomp!
视频审计[:文件路径]=文件路径
视频审核[:文件名]=文件名
视频审计[:持续时间]=持续时间
视频检查[:文件大小]=文件大小
视频审计[:格式]=格式
视频审计[:商业名称]=商业名称
视频\u审核[:格式\u配置文件]=格式\u配置文件
视频审计[:写入库]=写入库
视频\u审核[:文件\u扩展名]=文件\u扩展名
编解码器[:文件名]=文件名
编解码器[:格式]=格式
编解码器[:商业名称]=商业名称
编解码器[:格式配置文件]=格式配置文件
编解码器[:写入库]=写入库
编解码器[:文件扩展名]=文件扩展名
结束
结束
将视频_audit.to_yaml
放置编解码器

视频信息我知道了。我在循环之外创建新的哈希。每次迭代都需要创建一个新的散列,这样就可以将它添加到video_info数组中。然后,当我在脚本末尾调用uniq on video_info时,我需要删除bang操作符。这是我的最终代码:

require 'json'

#developed by Maile Thiesen
#!/usr/bin/ruby

library_path = ARGV[0]

files_list = Dir.glob("#{library_path}/**/*")
total_capture_scatch_and_exports_size = 0
counter = 0

video_info = []

files_list.each do |filepath|
filename = File.basename(filepath.to_s)
  codecs = {}
  filepath.chomp!
  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!

              codecs[:format] = format
              codecs[:commercial_name] = commercial_name
              codecs[:format_profile] = format_profile
              codecs[:writing_library] = writing_library
            codecs[:file_extension] = file_extension    
            total_capture_scatch_and_exports_size += file_size

            counter += 1
            video_info << codecs
      end    

  end

end
puts "THE UNIQUE CODECS ARE: #{JSON.pretty_generate(video_info.uniq)}"
puts "THE TOTAL FILESIZE IS : #{total_capture_scatch_and_exports_size/(1000**3).to_f} GB"
require'json'
#由Maile Thiesen开发
#!/usr/bin/ruby
库路径=ARGV[0]
files_list=Dir.glob(“#{library_path}/***”)
总捕获量和导出量=0
计数器=0
视频信息=[]
文件_list.each do |文件路径|
filename=File.basename(filepath.to_s)
编解码器={}
filepath.chomp!
文件夹\u-to\u-scan=[“/capture-scratch/”、“/capturestrack/”、“/capture-scratch/”、“/capture-scratch/”、“/capture-scratch/”、“导出”、“导出”]
file\u size=file.size(文件路径)
file_扩展名=file.extname(文件路径)
如果
要扫描的文件夹。有吗?{| folder | filepath.downcase.include?folder}
如果
File.File?(文件路径)&文件名[0]!=“&&U文件扩展名!=“.TIFF”&文件扩展名!=“.TIF”和文件扩展名(&U)!=“.tif”和文件扩展名(&U)!=“.tiff”&文件扩展名!=“.jpg”&文件扩展名!=“.jpeg”&文件扩展名!=“.JPG”&文件扩展名!=“.JPEG”
持续时间=%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!
正在写入_-library=%x[mediainfo--Inform=“General;”%Encoded_-library%”“#{filepath}”。chomp!
编解码器[:格式]=格式
编解码器[:商业名称]=商业名称
编解码器[:格式配置文件]=格式配置文件
编解码器[:写入库]=写入库
编解码器[:文件扩展名]=文件扩展名
总捕获和导出大小+=文件大小
计数器+=1

视频信息我知道了。我在循环之外创建新的哈希。每次迭代都需要创建一个新的散列,这样就可以将它添加到video_info数组中。然后,当我在脚本末尾调用uniq on video_info时,我需要删除bang操作符。这是我的最终代码:

require 'json'

#developed by Maile Thiesen
#!/usr/bin/ruby

library_path = ARGV[0]

files_list = Dir.glob("#{library_path}/**/*")
total_capture_scatch_and_exports_size = 0
counter = 0

video_info = []

files_list.each do |filepath|
filename = File.basename(filepath.to_s)
  codecs = {}
  filepath.chomp!
  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!

              codecs[:format] = format
              codecs[:commercial_name] = commercial_name
              codecs[:format_profile] = format_profile
              codecs[:writing_library] = writing_library
            codecs[:file_extension] = file_extension    
            total_capture_scatch_and_exports_size += file_size

            counter += 1
            video_info << codecs
      end    

  end

end
puts "THE UNIQUE CODECS ARE: #{JSON.pretty_generate(video_info.uniq)}"
puts "THE TOTAL FILESIZE IS : #{total_capture_scatch_and_exports_size/(1000**3).to_f} GB"
require'json'
#由Maile Thiesen开发
#!/usr/bin/ruby
库路径=ARGV[0]
files_list=Dir.glob(“#{library_path}/***”)
总捕获量和导出量=0
计数器=0
视频信息=[]
文件_list.each do |文件路径|
filename=File.basename(filepath.to_s)
编解码器={}
filepath.chomp!
文件夹\u-to\u-scan=[“/capture-scratch/”、“/capturestrack/”、“/capture-scratch/”、“/capture-scratch/”、“/capture-scratch/”、“导出”、“导出”]