Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ gem 'terser'
gem 'shakapacker'

# Core Samvera
# gem 'active-fedora', '~> 15.0'
gem 'active-fedora', git: 'https://github.com/samvera/active_fedora.git', ref: '7f91e09e630f7e3c1eb3d355e5a016ae8af44778'
gem 'active-fedora', '~> 16.0'
gem 'active_fedora-datastreams', '~> 0.5'
gem 'hydra-head', '~> 13.0'
gem 'ldp', '~> 1.1.0'
Expand Down Expand Up @@ -73,8 +72,7 @@ gem 'omniauth-lti', git: "https://github.com/avalonmediasystem/omniauth-lti.git"
gem "omniauth-saml", "~> 2.0", ">= 2.2.3"

# Media Access & Transcoding
#gem 'active_encode', '~> 1.3.0'
gem 'active_encode', git: "https://github.com/samvera-labs/active_encode.git", branch: "mediaconvert_file"
gem 'active_encode', '~> 2.0'
gem 'audio_waveform-ruby', '~> 1.0.7', require: 'audio_waveform'
gem 'browse-everything', git: "https://github.com/avalonmediasystem/browse-everything.git", tag: 'v1.5-Avalon'
gem 'fastimage'
Expand Down
44 changes: 21 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,6 @@ GIT
addressable (~> 2.8)
rails

GIT
remote: https://github.com/samvera/active_fedora.git
revision: 7f91e09e630f7e3c1eb3d355e5a016ae8af44778
ref: 7f91e09e630f7e3c1eb3d355e5a016ae8af44778
specs:
active-fedora (15.0.1)
active-triples (>= 0.11.0, < 2.0.0)
activemodel (>= 6.1)
activesupport (>= 6.1)
deprecation
faraday (>= 2.0)
faraday-encoding (>= 0.0.5)
faraday-follow_redirects
ldp (>= 0.7.0, < 2)
mutex_m
rsolr (>= 1.1.2, < 3)
ruby-progressbar (~> 1.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -123,6 +105,18 @@ GEM
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active-fedora (16.0.0)
active-triples (>= 0.11.0, < 2.0.0)
activemodel (>= 6.1)
activesupport (>= 6.1)
deprecation
faraday (>= 2.0)
faraday-encoding (>= 0.0.5)
faraday-follow_redirects
ldp (>= 0.7.0, < 2)
mutex_m
rsolr (>= 1.1.2, < 3)
ruby-progressbar (~> 1.0)
active-triples (1.2.0)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
Expand All @@ -132,6 +126,10 @@ GEM
json-ld
rails (>= 5.2)
rdf-vocab (>= 2.1.0)
active_encode (2.0.0)
addressable (~> 2.8)
rails
retriable
active_fedora-datastreams (0.5.0)
active-fedora (>= 11.0.0.pre)
activemodel (>= 5.2)
Expand Down Expand Up @@ -252,7 +250,7 @@ GEM
bcp47_spec (0.2.1)
bcrypt (3.1.20)
benchmark (0.4.1)
bigdecimal (3.2.2)
bigdecimal (3.2.3)
bindex (0.8.1)
bixby (5.0.2)
rubocop (= 1.28.2)
Expand Down Expand Up @@ -329,7 +327,7 @@ GEM
config (5.5.2)
deep_merge (~> 1.2, >= 1.2.1)
ostruct
connection_pool (2.5.3)
connection_pool (2.5.4)
crack (1.0.0)
bigdecimal
rexml
Expand Down Expand Up @@ -576,7 +574,7 @@ GEM
mysql2 (0.5.6)
net-http (0.6.0)
uri
net-imap (0.5.9)
net-imap (0.5.10)
date
net-protocol
net-ldap (0.19.0)
Expand Down Expand Up @@ -1000,9 +998,9 @@ PLATFORMS

DEPENDENCIES
about_page!
active-fedora!
active-fedora (~> 16.0)
active_annotations (~> 0.6)
active_encode!
active_encode (~> 2.0)
active_fedora-datastreams (~> 0.5)
activejob-traffic_control
activejob-uniqueness
Expand Down
7 changes: 6 additions & 1 deletion app/models/derivative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def set_streaming_locations!
if managed
path = Addressable::URI.parse(absolute_location).path
self.location_url = Avalon::StreamMapper.stream_path(path)
self.hls_url = Avalon::StreamMapper.map(path, 'http', format)
is_mp3 = format == "audio" && audio_codec == "mp3"
self.hls_url = Avalon::StreamMapper.map(path, 'http', (is_mp3 ? "audio_mp3" : format))
end
self
end
Expand Down Expand Up @@ -116,6 +117,10 @@ def self.from_output(output, managed = true)
derivative.video_codec = output[:video_codec]
derivative.resolution = "#{output[:width]}x#{output[:height]}" if output[:width] && output[:height]

if derivative.format == "audio" && derivative.audio_codec == "mp3"
derivative.mime_type ||= "audio/mpeg"
end

# FIXME: Transform to stream url here? How do we distribute to the streaming server?
derivative.location_url = output[:url]
# For Intercom push
Expand Down
15 changes: 14 additions & 1 deletion app/services/file_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,25 @@ def reader
when 's3'
S3File.new(uri).object.get.body
when 'file'
File.open(location,'r')
File.open(location, 'r')
else
open_uri
end
end

def magic_bytes
# Magic bytes for relevant file types should max out at 16, so only request
# that range when checking mimetype.
case uri.scheme
when 's3'
S3File.new(uri).object.get(range: 'bytes=0-15').body
when 'file'
File.read(location, 16)
else
open_uri.read(16)
end
end

# Ruby 3.0 removed URI#open from being called by Kernel#open.
# Prioritize using URI#open, attempt to fallback to Kernel#open
# if URI fails.
Expand Down
21 changes: 21 additions & 0 deletions config/media_convert_presets/avalon_audio_high.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Name": "avalon_audio_high",
"Category": "avalon",
"Settings": {
"AudioDescriptions": [
{
"CodecSettings": {
"AacSettings": {
"Bitrate": 320000,
"CodingMode": "CODING_MODE_2_0",
"SampleRate": 44100
},
"Codec": "AAC"
}
}
],
"ContainerSettings": {
"Container": "MP4"
}
}
}
21 changes: 21 additions & 0 deletions config/media_convert_presets/avalon_audio_medium.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Name": "avalon_audio_medium",
"Category": "avalon",
"Settings": {
"AudioDescriptions": [
{
"CodecSettings": {
"AacSettings": {
"Bitrate": 128000,
"CodingMode": "CODING_MODE_2_0",
"SampleRate": 44100
},
"Codec": "AAC"
}
}
],
"ContainerSettings": {
"Container": "MP4"
}
}
}
34 changes: 34 additions & 0 deletions config/media_convert_presets/avalon_video_high.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Name": "avalon_video_high",
"Category": "avalon",
"Settings": {
"VideoDescription": {
"Width": 1920,
"ScalingBehavior": "FIT_NO_UPSCALE",
"Height": 1080,
"CodecSettings": {
"Codec": "H_264",
"H264Settings": {
"Bitrate": 2048000,
"CodecProfile": "HIGH",
"CodecLevel": "AUTO"
}
}
},
"AudioDescriptions": [
{
"CodecSettings": {
"Codec": "AAC",
"AacSettings": {
"Bitrate": 192000,
"CodingMode": "CODING_MODE_2_0",
"SampleRate": 44100
}
}
}
],
"ContainerSettings": {
"Container": "MP4"
}
}
}
34 changes: 34 additions & 0 deletions config/media_convert_presets/avalon_video_low.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Name": "avalon_video_low",
"Category": "avalon",
"Settings": {
"VideoDescription": {
"Width": 720,
"ScalingBehavior": "FIT_NO_UPSCALE",
"Height": 480,
"CodecSettings": {
"Codec": "H_264",
"H264Settings": {
"Bitrate": 500000,
"CodecProfile": "HIGH",
"CodecLevel": "AUTO"
}
}
},
"AudioDescriptions": [
{
"CodecSettings": {
"Codec": "AAC",
"AacSettings": {
"Bitrate": 128000,
"CodingMode": "CODING_MODE_2_0",
"SampleRate": 44100
}
}
}
],
"ContainerSettings": {
"Container": "MP4"
}
}
}
34 changes: 34 additions & 0 deletions config/media_convert_presets/avalon_video_medium.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Name": "avalon_video_medium",
"Category": "avalon",
"Settings": {
"VideoDescription": {
"Width": 1280,
"ScalingBehavior": "FIT_NO_UPSCALE",
"Height": 720,
"CodecSettings": {
"Codec": "H_264",
"H264Settings": {
"Bitrate": 1024000,
"CodecProfile": "HIGH",
"CodecLevel": "AUTO"
}
}
},
"AudioDescriptions": [
{
"CodecSettings": {
"Codec": "AAC",
"AacSettings": {
"Bitrate": 128000,
"CodingMode": "CODING_MODE_2_0",
"SampleRate": 44100
}
}
}
],
"ContainerSettings": {
"Container": "MP4"
}
}
}
1 change: 1 addition & 0 deletions config/url_handlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ nginx:
http:
video: <%=http_base%>/<%=path%>/<%=filename%>.<%=extension%>/index.m3u8
audio: <%=http_base%>/<%=path%>/<%=filename%>.<%=extension%>/index.m3u8
audio_mp3: <%=http_base%>/<%=path%>/<%=filename%>.<%=extension%>

3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ services:
- ./solr/conf:/opt/solr/avalon_conf

hls:
image: avalonmediasystem/nginx:minio-jammy
image: avalonmediasystem/nginx:noble
environment:
- AVALON_DOMAIN=http://avalon:3000
- AVALON_STREAMING_BUCKET_URL=http://minio:9000/derivatives/
- VOD_MODE=remote
volumes:
- ./log/nginx:/var/log/nginx
ports:
Expand Down
2 changes: 1 addition & 1 deletion lib/avalon/ffprobe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def content_type media_file
# Remove S3 credentials or other params from extension output
extension = File.extname(media_file.location)&.gsub(/[\?#].*/, '')
# Fall back on file extension if magic bytes fail to identify file
Marcel::MimeType.for media_file.reader, extension: extension
@content_type ||= Marcel::MimeType.for media_file.magic_bytes, extension: extension
end

def valid_content_type? media_file
Expand Down
2 changes: 0 additions & 2 deletions lib/avalon/media_convert_encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# specific language governing permissions and limitations under the License.
# --- END LICENSE_HEADER BLOCK ---

require 'avalon/elastic_transcoder'

class MediaConvertEncode < WatchedEncode
self.engine_adapter = :media_convert
self.engine_adapter.role = Settings.encoding.media_convert_role
Expand Down
Loading