Class: Pageflow::VideoFile

Inherits:
ApplicationRecord show all
Includes:
MediaEncodingStateMachine, OutputSource, UploadableFile
Defined in:
app/models/pageflow/video_file.rb

Constant Summary

Constants included from OutputSource

OutputSource::STATE_MAPPING

Instance Method Summary collapse

Methods included from OutputSource

#output_presences, #output_presences=, #output_present?, #present_outputs

Methods included from MediaEncodingStateMachine

#failed?, #ready?, #retry!, #retryable?

Methods included from UploadableFile

#attachment, #attachment=, #attachment_default_url, #attachment_styles, #attachments_for_export, #basename, #can_upload?, #direct_upload_config, #failed?, #publish!, #ready?, #retryable?, #url

Methods included from ReusableFile

#attachments_for_export, #basename, #cache_key, #can_upload?, #failed?, #file_name, #file_type, #nested_files, #original_url, #parent_allows_type_for_nesting, #parent_belongs_to_same_entry, #publish!, #ready?, #retry!, #retryable?, #url

Instance Method Details

#attachment_s3_urlObject



42
43
44
# File 'app/models/pageflow/video_file.rb', line 42

def attachment_s3_url
  "s3://#{File.join(attachment.bucket_name, attachment.path)}"
end

#dash_4kObject



70
71
72
# File 'app/models/pageflow/video_file.rb', line 70

def dash_4k
  ZencoderAttachment.new(self, 'dash/4k/rendition.mpd')
end

#dash_fullhdObject



74
75
76
# File 'app/models/pageflow/video_file.rb', line 74

def dash_fullhd
  ZencoderAttachment.new(self, 'dash/fullhd/rendition.mpd')
end

#dash_highObject



78
79
80
# File 'app/models/pageflow/video_file.rb', line 78

def dash_high
  ZencoderAttachment.new(self, 'dash/high/rendition.mpd')
end

#dash_lowObject



86
87
88
# File 'app/models/pageflow/video_file.rb', line 86

def dash_low
  ZencoderAttachment.new(self, 'dash/low/rendition.mpd')
end

#dash_mediumObject



82
83
84
# File 'app/models/pageflow/video_file.rb', line 82

def dash_medium
  ZencoderAttachment.new(self, 'dash/medium/rendition.mpd')
end

#dash_playlistObject



110
111
112
# File 'app/models/pageflow/video_file.rb', line 110

def dash_playlist
  ZencoderAttachment.new(self, 'dash/manifest.mpd')
end

#encode_highdef?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/pageflow/video_file.rb', line 46

def encode_highdef?
  entry.feature_state('highdef_video_encoding')
end

#externally_generated_outputsObject



141
142
143
144
145
146
147
# File 'app/models/pageflow/video_file.rb', line 141

def externally_generated_outputs
  if Pageflow.config.zencoder_options[:hls_smil_suffix].present?
    %w(hls-playlist)
  else
    []
  end
end

#hls_4kObject



106
107
108
# File 'app/models/pageflow/video_file.rb', line 106

def hls_4k
  ZencoderAttachment.new(self, 'hls-4k.m3u8')
end

#hls_fullhdObject



102
103
104
# File 'app/models/pageflow/video_file.rb', line 102

def hls_fullhd
  ZencoderAttachment.new(self, 'hls-fullhd.m3u8')
end

#hls_highObject



98
99
100
# File 'app/models/pageflow/video_file.rb', line 98

def hls_high
  ZencoderAttachment.new(self, 'hls-high.m3u8')
end

#hls_lowObject



90
91
92
# File 'app/models/pageflow/video_file.rb', line 90

def hls_low
  ZencoderAttachment.new(self, 'hls-low.m3u8')
end

#hls_mediumObject



94
95
96
# File 'app/models/pageflow/video_file.rb', line 94

def hls_medium
  ZencoderAttachment.new(self, 'hls-medium.m3u8')
end

#hls_playlistObject



114
115
116
117
118
119
120
121
122
123
# File 'app/models/pageflow/video_file.rb', line 114

def hls_playlist
  if Pageflow.config.zencoder_options[:hls_smil_suffix].present?
    ZencoderAttachment.new(self,
                           'hls-playlist.smil',
                           host: :hls,
                           url_suffix: Pageflow.config.zencoder_options[:hls_smil_suffix])
  else
    ZencoderAttachment.new(self, 'hls-playlist.m3u8', host: :hls)
  end
end

#meta_data_attributes=(attributes) ⇒ Object



149
150
151
152
153
154
155
# File 'app/models/pageflow/video_file.rb', line 149

def (attributes)
  self.attributes = attributes.symbolize_keys.slice(:format,
                                                    :duration_in_ms,
                                                    :width,
                                                    :height,
                                                    :output_presences)
end

#mp4_4kObject



50
51
52
# File 'app/models/pageflow/video_file.rb', line 50

def mp4_4k
  ZencoderAttachment.new(self, '4k.mp4')
end

#mp4_fullhdObject



54
55
56
# File 'app/models/pageflow/video_file.rb', line 54

def mp4_fullhd
  ZencoderAttachment.new(self, 'fullhd.mp4')
end

#mp4_highObject



58
59
60
# File 'app/models/pageflow/video_file.rb', line 58

def mp4_high
  ZencoderAttachment.new(self, 'high.mp4')
end

#mp4_lowObject



66
67
68
# File 'app/models/pageflow/video_file.rb', line 66

def mp4_low
  ZencoderAttachment.new(self, 'low.mp4')
end

#mp4_mediumObject



62
63
64
# File 'app/models/pageflow/video_file.rb', line 62

def mp4_medium
  ZencoderAttachment.new(self, 'medium.mp4')
end

#output_definitionObject



137
138
139
# File 'app/models/pageflow/video_file.rb', line 137

def output_definition
  ZencoderVideoOutputDefinition.new(self)
end

#smilObject



125
126
127
# File 'app/models/pageflow/video_file.rb', line 125

def smil
  ZencoderAttachment.new(self, 'hls-playlist.smil')
end

#thumbnail_url(*args) ⇒ Object



38
39
40
# File 'app/models/pageflow/video_file.rb', line 38

def thumbnail_url(*args)
  poster.url(*args)
end

#zencoder_posterObject



133
134
135
# File 'app/models/pageflow/video_file.rb', line 133

def zencoder_poster
  ZencoderAttachment.new(self, 'poster-{{number}}', format: 'jpg')
end

#zencoder_thumbnailObject



129
130
131
# File 'app/models/pageflow/video_file.rb', line 129

def zencoder_thumbnail
  ZencoderAttachment.new(self, 'thumbnail-{{number}}', format: 'jpg')
end