Class: Yamdi
- Inherits:
-
Object
- Object
- Yamdi
- Defined in:
- lib/yamdi.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
- #audio_codec_id ⇒ Object
- #audio_data_rate ⇒ Object
- #audio_delay ⇒ Object
- #audio_sample_rate ⇒ Object
- #audio_sample_size ⇒ Object
- #audio_size ⇒ Object
- #can_seek_to_end? ⇒ Boolean
- #data_size ⇒ Object
- #duration ⇒ Object
- #file_size ⇒ Object
- #frame_rate ⇒ Object
- #has_audio? ⇒ Boolean
- #has_cue_points? ⇒ Boolean
- #has_keyframes? ⇒ Boolean
- #has_metadata? ⇒ Boolean
- #has_video? ⇒ Boolean
- #height ⇒ Object
-
#initialize(flv_path) ⇒ Yamdi
constructor
A new instance of Yamdi.
- #key_frames ⇒ Object
- #last_key_frame_location ⇒ Object
- #last_key_frame_timestamp ⇒ Object
- #last_timestamp ⇒ Object
- #last_video_frame_timestamp ⇒ Object
- #parse(flv_path) ⇒ Object
- #stereo? ⇒ Boolean
- #video_codec_id ⇒ Object
- #video_data_rate ⇒ Object
- #video_size ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(flv_path) ⇒ Yamdi
Returns a new instance of Yamdi.
11 12 13 |
# File 'lib/yamdi.rb', line 11 def initialize(flv_path) @metadata = Nokogiri.parse( parse(flv_path) ) end |
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/yamdi.rb', line 9 def @metadata end |
Instance Method Details
#audio_codec_id ⇒ Object
51 52 53 |
# File 'lib/yamdi.rb', line 51 def audio_codec_id @metadata.xpath("//audiocodecid").inner_text.to_i end |
#audio_data_rate ⇒ Object
59 60 61 |
# File 'lib/yamdi.rb', line 59 def audio_data_rate @metadata.xpath("//audiodatarate").inner_text.to_i end |
#audio_delay ⇒ Object
67 68 69 |
# File 'lib/yamdi.rb', line 67 def audio_delay @metadata.xpath("//audiodelay").inner_text.to_f end |
#audio_sample_rate ⇒ Object
55 56 57 |
# File 'lib/yamdi.rb', line 55 def audio_sample_rate @metadata.xpath("//audiosamplerate").inner_text.to_i end |
#audio_sample_size ⇒ Object
63 64 65 |
# File 'lib/yamdi.rb', line 63 def audio_sample_size @metadata.xpath("//audiosamplesize").inner_text.to_i end |
#audio_size ⇒ Object
99 100 101 |
# File 'lib/yamdi.rb', line 99 def audio_size @metadata.xpath("//audiosize").inner_text.to_i end |
#can_seek_to_end? ⇒ Boolean
47 48 49 |
# File 'lib/yamdi.rb', line 47 def can_seek_to_end? boolean @metadata.xpath("//canSeekToEnd").inner_text end |
#data_size ⇒ Object
95 96 97 |
# File 'lib/yamdi.rb', line 95 def data_size @metadata.xpath("//datasize").inner_text.to_i end |
#duration ⇒ Object
23 24 25 |
# File 'lib/yamdi.rb', line 23 def duration @metadata.xpath("//duration").inner_text.to_f end |
#file_size ⇒ Object
107 108 109 |
# File 'lib/yamdi.rb', line 107 def file_size @metadata.xpath("//filesize").inner_text.to_i end |
#frame_rate ⇒ Object
79 80 81 |
# File 'lib/yamdi.rb', line 79 def frame_rate @metadata.xpath("//framerate").inner_text.to_f end |
#has_audio? ⇒ Boolean
35 36 37 |
# File 'lib/yamdi.rb', line 35 def has_audio? boolean @metadata.xpath("//hasAudio").inner_text end |
#has_cue_points? ⇒ Boolean
43 44 45 |
# File 'lib/yamdi.rb', line 43 def has_cue_points? boolean @metadata.xpath("//hasCuePoints").inner_text end |
#has_keyframes? ⇒ Boolean
27 28 29 |
# File 'lib/yamdi.rb', line 27 def has_keyframes? boolean @metadata.xpath("//hasKeyframes").inner_text end |
#has_metadata? ⇒ Boolean
39 40 41 |
# File 'lib/yamdi.rb', line 39 def boolean @metadata.xpath("//hasMetadata").inner_text end |
#has_video? ⇒ Boolean
31 32 33 |
# File 'lib/yamdi.rb', line 31 def has_video? boolean @metadata.xpath("//hasVideo").inner_text end |
#height ⇒ Object
87 88 89 |
# File 'lib/yamdi.rb', line 87 def height @metadata.xpath("//height").inner_text.to_i end |
#key_frames ⇒ Object
127 128 129 |
# File 'lib/yamdi.rb', line 127 def key_frames KeyFrame.all_from_xml(@metadata.xpath("//keyframes")) end |
#last_key_frame_location ⇒ Object
123 124 125 |
# File 'lib/yamdi.rb', line 123 def last_key_frame_location @metadata.xpath("//lastkeyframelocation").inner_text.to_i end |
#last_key_frame_timestamp ⇒ Object
119 120 121 |
# File 'lib/yamdi.rb', line 119 def @metadata.xpath("//lastkeyframetimestamp").inner_text.to_f end |
#last_timestamp ⇒ Object
111 112 113 |
# File 'lib/yamdi.rb', line 111 def @metadata.xpath("//lasttimestamp").inner_text.to_f end |
#last_video_frame_timestamp ⇒ Object
115 116 117 |
# File 'lib/yamdi.rb', line 115 def @metadata.xpath("//lastvideoframetimestamp").inner_text.to_f end |
#parse(flv_path) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/yamdi.rb', line 15 def parse(flv_path) temp_file = Tempfile.new('yamdi_tmp') `yamdi -i #{flv_path} -x #{temp_file.path}` contents = temp_file.read temp_file.close contents end |
#stereo? ⇒ Boolean
71 72 73 |
# File 'lib/yamdi.rb', line 71 def stereo? boolean @metadata.xpath("//stereo").inner_text end |
#video_codec_id ⇒ Object
75 76 77 |
# File 'lib/yamdi.rb', line 75 def video_codec_id @metadata.xpath("//videocodecid").inner_text.to_i end |
#video_data_rate ⇒ Object
83 84 85 |
# File 'lib/yamdi.rb', line 83 def video_data_rate @metadata.xpath("//videodatarate").inner_text.to_i end |
#video_size ⇒ Object
103 104 105 |
# File 'lib/yamdi.rb', line 103 def video_size @metadata.xpath("//videosize").inner_text.to_i end |
#width ⇒ Object
91 92 93 |
# File 'lib/yamdi.rb', line 91 def width @metadata.xpath("//width").inner_text.to_i end |