beanieboi / ffprober

a small ruby wrapper for ffprobe
MIT License
41 stars 21 forks source link

Reel #55

Closed pietrop closed 8 years ago

pietrop commented 8 years ago

What would be the best way to get direct access to the reel metadata? I can see it in the Ffprober object reel_name=>"NO NAME" but not quiet sure how to access it..

require "ffprober"
ffprobe = Ffprober::Parser.from_file("Clip15.mov")
#<Ffprober::Wrapper:0x007fbf72ae3c40   
 @json={:streams=>     
 [
    {   :index=>0, :codec_name=>"prores", :codec_long_name=>"ProRes",
        :codec_type=>"video", :codec_time_base=>"1/2500", :codec_tag_string=>"apcs",
        :codec_tag=>"0x73637061", :width=>1920, :height=>1080, :coded_width=>1920,
        :coded_height=>1080, :has_b_frames=>0, :sample_aspect_ratio=>"1:1",
        :display_aspect_ratio=>"16:9", :pix_fmt=>"yuv422p10le", :level=>-99,
        :color_space=>"bt709", :color_transfer=>"bt709", :color_primaries=>"bt709",
        :refs=>1, :r_frame_rate=>"25/1", :avg_frame_rate=>"25/1",
        :time_base=>"1/2500", :start_pts=>0, :start_time=>"0.000000",
        :duration_ts=>42900, :duration=>"17.160000", :bit_rate=>"79867502",
        :bits_per_raw_sample=>"10", :nb_frames=>"429",  

        :disposition=>{:default=>1, :dub=>0, :original=>0, :comment=>0, :lyrics=>0, :karaoke=>0, :forced=>0,
        :hearing_impaired=>0, :visual_impaired=>0, :clean_effects=>0,
        :attached_pic=>0}, 

        :tags=>{:creation_time=>"2015-10-29 14:21:44",:language=>"eng", :handler_name=>"Apple Alias Data Handler", :encoder=>"Apple
        ProRes 422 LT", :timecode=>"00:00:00:00"}
    },

    {   :index=>1,:codec_name=>"pcm_s16le", :codec_long_name=>"PCM signed 16-bit little-endian",
        :codec_type=>"audio", :codec_time_base=>"1/48000", :codec_tag_string=>"sowt",
        :codec_tag=>"0x74776f73", :sample_fmt=>"s16", :sample_rate=>"48000",
        :channels=>2, :channel_layout=>"stereo", :bits_per_sample=>16,
        :r_frame_rate=>"0/0", :avg_frame_rate=>"0/0", :time_base=>"1/48000",
        :start_pts=>0, :start_time=>"0.000000", :duration_ts=>824832,
        :duration=>"17.184000", :bit_rate=>"1536000", :nb_frames=>"824832",
        :disposition=>{:default=>1, :dub=>0, :original=>0, :comment=>0, :lyrics=>0,
        :karaoke=>0, :forced=>0, :hearing_impaired=>0, :visual_impaired=>0,
        :clean_effects=>0, :attached_pic=>0}, 

        :tags=>{:creation_time=>"2015-10-29 14:21:44", :language=>"eng", :handler_name=>"Apple Alias Data Handler"}
    },

    {   :index=>2, :codec_type=>"data", :codec_time_base=>"1/25",
        :codec_tag_string=>"tmcd", :codec_tag=>"0x64636d74", :r_frame_rate=>"0/0",
        :avg_frame_rate=>"0/0", :time_base=>"1/2500", :start_pts=>0,
        :start_time=>"0.000000", :duration_ts=>42900, :duration=>"17.160000",
        :bit_rate=>"1", :nb_frames=>"1", 

        :disposition=>{:default=>0, :dub=>0,:original=>0, :comment=>0, :lyrics=>0, :karaoke=>0, :forced=>0,
        :hearing_impaired=>0, :visual_impaired=>0, :clean_effects=>0,
        :attached_pic=>0}, 

        :tags=>{:creation_time=>"2015-10-29 14:21:44",
        :language=>"eng", :handler_name=>"Apple Alias Data Handler", :reel_name=>"NO
        NAME", :timecode=>"00:00:00:00"}
    }
], 

    :chapters=>[],

    :format=>{
        :filename=>"Clip15.mov", :nb_streams=>3, :nb_programs=>0, :format_name=>"mov,mp4,m4a,3gp,3g2,mj2", :format_long_name=>"QuickTime / MOV",
        :start_time=>"0.000000", :duration=>"17.160000", :size=>"174741490",:bit_rate=>"81464564", :probe_score=>100, :tags=>{:major_brand=>"qt  ",
        :minor_version=>"537199360", :compatible_brands=>"qt  ",:creation_time=>"2015-10-29 14:21:44"
        }
    }
},

@video_streams=[#<Ffprober::VideoStream:0x007fbf750a1e00 @index=0,

@codec_name="prores", @codec_long_name="ProRes", @codec_type="video",
@codec_time_base="1/2500", @codec_tag_string="apcs", @codec_tag="0x73637061",
@width=1920, @height=1080, @coded_width=1920, @coded_height=1080,
@has_b_frames=0, @sample_aspect_ratio="1:1", @display_aspect_ratio="16:9",
@pix_fmt="yuv422p10le", @level=-99, @color_space="bt709",
@color_transfer="bt709", @color_primaries="bt709", @refs=1,
@r_frame_rate="25/1", @avg_frame_rate="25/1", @time_base="1/2500",
@start_pts=0, @start_time="0.000000", @duration_ts=42900,
@duration="17.160000", @bit_rate="79867502", @bits_per_raw_sample="10",
@nb_frames="429", 

@disposition={
    :default=>1, :dub=>0, :original=>0,:comment=>0, :lyrics=>0, :karaoke=>0, :forced=>0, :hearing_impaired=>0,
    :visual_impaired=>0, :clean_effects=>0, :attached_pic=>0
    },

@tags={
    :creation_time=>"2015-10-29 14:21:44", :language=>"eng",:handler_name=>"Apple Alias Data Handler", :encoder=>"Apple ProRes 422 LT",
:timecode=>"00:00:00:00"}>

], 

@format=#<Ffprober::Format:0x007fbf75111688

@filename="Clip15.mov", @nb_streams=3, @nb_programs=0,@format_name="mov,mp4,m4a,3gp,3g2,mj2", 
@format_long_name="QuickTime / MOV",@start_time="0.000000", 
@duration="17.160000", @size="174741490",@bit_rate="81464564", @probe_score=100, 

@tags={
    :major_brand=>"qt  ",:minor_version=>"537199360", :compatible_brands=>"qt  ",:creation_time=>"2015-10-29 14:21:44"
    }
    >
    >

any suggestions much appreciated

beanieboi commented 8 years ago

hey

thanks for the report, is it possible for you to share Clip15.mov? this would make it easier for me to look into this.

ben

pietrop commented 8 years ago

Hi Ben, Here it is http://we.tl/H44cKksSUF

Thanks

Pietro

beanieboi commented 8 years ago

thanks, will look into this today!

On 02 Nov 2015, at 16:02, Pietro notifications@github.com wrote:

Hi Ben, Here it is https://www.wetransfer.com/downloads/f72f327de947c6c19c4385360a2911c820151102204022/400428076a26f5e525b244739a57b0bd20151102204022/660f3f https://www.wetransfer.com/downloads/f72f327de947c6c19c4385360a2911c820151102204022/400428076a26f5e525b244739a57b0bd20151102204022/660f3f Thanks

Pietro

— Reply to this email directly or view it on GitHub https://github.com/beanieboi/ffprober/issues/55#issuecomment-153155550.

pietrop commented 8 years ago

Thanks Ben, Meanwhile I figured out I can get to reel_name with a system call to ffprobe, but I'd rather use ffprober to keep it simple if there's a way..

require 'json'

clip_name="Clip15.mov"

# REEL_NAME
# use system call to save output of ffprobe as json  | from https://gist.github.com/nrk/2286511
ffprobe_json = `ffprobe -v quiet -print_format json -show_format -show_streams '#{clip_name}'`

#transform json into ruby hash from https://hackhands.com/ruby-read-json-file-hash/
data_hash = JSON.parse(ffprobe_json)
# access reel_name value in ruby hash / ffprobe json
reel_name = data_hash['streams'][2]["tags"]["reel_name"]

puts "reel_name: "+reel_name
beanieboi commented 8 years ago

hey,

could you check out the data-streams branch? i added support for data streams there. i need to add some tests before i will merge it, but it works locally for me.

access the reel name ffprobe.data_streams.first.tags[:reel_name]

56

please let me know what you think

pietrop commented 8 years ago

thanks, I'll try it out, any ideas on an ETA for when is this branch going to be merged with the main one?

beanieboi commented 8 years ago

just pushed some tests, will release later today

beanieboi commented 8 years ago

the release is out, thanks for the report. will close this now

pietrop commented 8 years ago

that's great! thank you!

beanieboi commented 8 years ago

you're welcome!