Class: Yamdi

Inherits:
Object
  • Object
show all
Defined in:
lib/yamdi.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#metadataObject

Returns the value of attribute metadata.



9
10
11
# File 'lib/yamdi.rb', line 9

def 
  @metadata
end

Instance Method Details

#audio_codec_idObject



51
52
53
# File 'lib/yamdi.rb', line 51

def audio_codec_id
  @metadata.xpath("//audiocodecid").inner_text.to_i
end

#audio_data_rateObject



59
60
61
# File 'lib/yamdi.rb', line 59

def audio_data_rate
  @metadata.xpath("//audiodatarate").inner_text.to_i
end

#audio_delayObject



67
68
69
# File 'lib/yamdi.rb', line 67

def audio_delay
  @metadata.xpath("//audiodelay").inner_text.to_f
end

#audio_sample_rateObject



55
56
57
# File 'lib/yamdi.rb', line 55

def audio_sample_rate
  @metadata.xpath("//audiosamplerate").inner_text.to_i
end

#audio_sample_sizeObject



63
64
65
# File 'lib/yamdi.rb', line 63

def audio_sample_size
  @metadata.xpath("//audiosamplesize").inner_text.to_i
end

#audio_sizeObject



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

Returns:

  • (Boolean)


47
48
49
# File 'lib/yamdi.rb', line 47

def can_seek_to_end?
  boolean @metadata.xpath("//canSeekToEnd").inner_text
end

#data_sizeObject



95
96
97
# File 'lib/yamdi.rb', line 95

def data_size
  @metadata.xpath("//datasize").inner_text.to_i
end

#durationObject



23
24
25
# File 'lib/yamdi.rb', line 23

def duration
  @metadata.xpath("//duration").inner_text.to_f
end

#file_sizeObject



107
108
109
# File 'lib/yamdi.rb', line 107

def file_size
  @metadata.xpath("//filesize").inner_text.to_i
end

#frame_rateObject



79
80
81
# File 'lib/yamdi.rb', line 79

def frame_rate
  @metadata.xpath("//framerate").inner_text.to_f
end

#has_audio?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/yamdi.rb', line 35

def has_audio?
  boolean @metadata.xpath("//hasAudio").inner_text
end

#has_cue_points?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/yamdi.rb', line 43

def has_cue_points?
  boolean @metadata.xpath("//hasCuePoints").inner_text
end

#has_keyframes?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/yamdi.rb', line 27

def has_keyframes?
  boolean @metadata.xpath("//hasKeyframes").inner_text
end

#has_metadata?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/yamdi.rb', line 39

def has_metadata?
  boolean @metadata.xpath("//hasMetadata").inner_text
end

#has_video?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/yamdi.rb', line 31

def has_video?
  boolean @metadata.xpath("//hasVideo").inner_text
end

#heightObject



87
88
89
# File 'lib/yamdi.rb', line 87

def height
  @metadata.xpath("//height").inner_text.to_i
end

#key_framesObject



127
128
129
# File 'lib/yamdi.rb', line 127

def key_frames
  KeyFrame.all_from_xml(@metadata.xpath("//keyframes"))
end

#last_key_frame_locationObject



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_timestampObject



119
120
121
# File 'lib/yamdi.rb', line 119

def last_key_frame_timestamp
  @metadata.xpath("//lastkeyframetimestamp").inner_text.to_f
end

#last_timestampObject



111
112
113
# File 'lib/yamdi.rb', line 111

def last_timestamp
  @metadata.xpath("//lasttimestamp").inner_text.to_f
end

#last_video_frame_timestampObject



115
116
117
# File 'lib/yamdi.rb', line 115

def last_video_frame_timestamp
  @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

Returns:

  • (Boolean)


71
72
73
# File 'lib/yamdi.rb', line 71

def stereo?
  boolean @metadata.xpath("//stereo").inner_text
end

#video_codec_idObject



75
76
77
# File 'lib/yamdi.rb', line 75

def video_codec_id
  @metadata.xpath("//videocodecid").inner_text.to_i
end

#video_data_rateObject



83
84
85
# File 'lib/yamdi.rb', line 83

def video_data_rate
  @metadata.xpath("//videodatarate").inner_text.to_i
end

#video_sizeObject



103
104
105
# File 'lib/yamdi.rb', line 103

def video_size
  @metadata.xpath("//videosize").inner_text.to_i
end

#widthObject



91
92
93
# File 'lib/yamdi.rb', line 91

def width
  @metadata.xpath("//width").inner_text.to_i
end