Class: Pageflow::VideoFile

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

Overview

rubocop:todo Style/Documentation

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, #extension, #failed?, #file_name, #publish!, #ready?, #retryable?, #url

Methods included from ReusableFile

#attachments_for_export, #basename, #cache_key, #can_upload?, #extension, #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



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

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

#dash_4kObject



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

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

#dash_fullhdObject



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

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

#dash_highObject



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

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

#dash_lowObject



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

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

#dash_mediumObject



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

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

#dash_playlistObject



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

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

#dash_playlist_high_and_upObject



113
114
115
# File 'app/models/pageflow/video_file.rb', line 113

def dash_playlist_high_and_up
  ZencoderAttachment.new(self, 'dash/manifest-high-and-up.mpd')
end

#encode_highdef?Boolean

Returns:

  • (Boolean)


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

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

#externally_generated_outputsObject



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

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

#hls_4kObject



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

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

#hls_fullhdObject



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

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

#hls_highObject



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

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

#hls_lowObject



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

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

#hls_mediumObject



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

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

#hls_playlistObject



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'app/models/pageflow/video_file.rb', line 117

def hls_playlist
  if Pageflow.config.zencoder_options[:hls_smil_suffix].present?
    ZencoderAttachment.new(self,
                           Pageflow.config.zencoder_options.fetch(
                             :hls_smil_file_name,
                             '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

#hls_playlist_high_and_upObject



131
132
133
# File 'app/models/pageflow/video_file.rb', line 131

def hls_playlist_high_and_up
  ZencoderAttachment.new(self, 'hls-playlist-high-and-up.m3u8', host: :hls)
end

#meta_data_attributes=(attributes) ⇒ Object



159
160
161
162
163
164
165
# File 'app/models/pageflow/video_file.rb', line 159

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

#mp4_4kObject



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

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

#mp4_fullhdObject



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

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

#mp4_highObject



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

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

#mp4_lowObject



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

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

#mp4_mediumObject



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

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

#output_definitionObject



147
148
149
# File 'app/models/pageflow/video_file.rb', line 147

def output_definition
  ZencoderVideoOutputDefinition.new(self)
end

#post_process_encoded_filesObject



167
168
169
170
171
172
# File 'app/models/pageflow/video_file.rb', line 167

def post_process_encoded_files
  self.thumbnail = URI.parse(zencoder_thumbnail.url(default_protocol: 'https'))
  self.poster = URI.parse(zencoder_poster.url(default_protocol: 'https'))
rescue OpenURI::HTTPError
  throw(:halt, :pending)
end

#smilObject



135
136
137
# File 'app/models/pageflow/video_file.rb', line 135

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

#thumbnail_urlObject



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

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

#zencoder_posterObject



143
144
145
# File 'app/models/pageflow/video_file.rb', line 143

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

#zencoder_thumbnailObject



139
140
141
# File 'app/models/pageflow/video_file.rb', line 139

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