Skip to content

Commit e8fe759

Browse files
committed
WIP
1 parent 08fc45f commit e8fe759

File tree

6 files changed

+123
-10
lines changed

6 files changed

+123
-10
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ gem 'omniauth-lti', git: "https://github.com/avalonmediasystem/omniauth-lti.git"
7373
gem "omniauth-saml", "~> 2.0", ">= 2.2.3"
7474

7575
# Media Access & Transcoding
76-
gem 'active_encode', '~> 1.3.0'
76+
gem 'active_encode', '~> 2.0'
7777
gem 'audio_waveform-ruby', '~> 1.0.7', require: 'audio_waveform'
7878
gem 'browse-everything', git: "https://github.com/avalonmediasystem/browse-everything.git", tag: 'v1.5-Avalon'
7979
gem 'fastimage'

Gemfile.lock

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ GIT
5050
ims-lti
5151
omniauth
5252

53+
GIT
54+
remote: https://github.com/samvera-labs/active_encode.git
55+
revision: 5b21eedebe18357551f85567845f65a3128bea1e
56+
branch: s3_pass_through
57+
specs:
58+
active_encode (1.3.0)
59+
addressable (~> 2.8)
60+
rails
61+
5362
GIT
5463
remote: https://github.com/samvera/active_fedora.git
5564
revision: 7f91e09e630f7e3c1eb3d355e5a016ae8af44778
@@ -123,9 +132,6 @@ GEM
123132
json-ld
124133
rails (>= 5.2)
125134
rdf-vocab (>= 2.1.0)
126-
active_encode (1.3.0)
127-
addressable (~> 2.8)
128-
rails
129135
active_fedora-datastreams (0.5.0)
130136
active-fedora (>= 11.0.0.pre)
131137
activemodel (>= 5.2)
@@ -237,7 +243,7 @@ GEM
237243
bcp47_spec (0.2.1)
238244
bcrypt (3.1.20)
239245
benchmark (0.4.1)
240-
bigdecimal (3.2.2)
246+
bigdecimal (3.2.3)
241247
bindex (0.8.1)
242248
bixby (5.0.2)
243249
rubocop (= 1.28.2)
@@ -314,7 +320,7 @@ GEM
314320
config (5.5.2)
315321
deep_merge (~> 1.2, >= 1.2.1)
316322
ostruct
317-
connection_pool (2.5.3)
323+
connection_pool (2.5.4)
318324
crack (1.0.0)
319325
bigdecimal
320326
rexml
@@ -561,7 +567,7 @@ GEM
561567
mysql2 (0.5.6)
562568
net-http (0.6.0)
563569
uri
564-
net-imap (0.5.9)
570+
net-imap (0.5.10)
565571
date
566572
net-protocol
567573
net-ldap (0.19.0)
@@ -985,7 +991,7 @@ DEPENDENCIES
985991
about_page!
986992
active-fedora!
987993
active_annotations (~> 0.6)
988-
active_encode (~> 1.3.0)
994+
active_encode!
989995
active_fedora-datastreams (~> 0.5)
990996
activejob-traffic_control
991997
activejob-uniqueness

app/models/derivative.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def set_streaming_locations!
7878
if managed
7979
path = Addressable::URI.parse(absolute_location).path
8080
self.location_url = Avalon::StreamMapper.stream_path(path)
81-
self.hls_url = Avalon::StreamMapper.map(path, 'http', format)
81+
is_mp3 = format == "audio" && audio_codec == "mp3"
82+
self.hls_url = Avalon::StreamMapper.map(path, 'http', (is_mp3 ? "audio_mp3" : format))
8283
end
8384
self
8485
end
@@ -116,6 +117,10 @@ def self.from_output(output, managed = true)
116117
derivative.video_codec = output[:video_codec]
117118
derivative.resolution = "#{output[:width]}x#{output[:height]}" if output[:width] && output[:height]
118119

120+
if derivative.format == "audio" && derivative.audio_codec == "mp3"
121+
derivative.mime_type ||= "audio/mpeg"
122+
end
123+
119124
# FIXME: Transform to stream url here? How do we distribute to the streaming server?
120125
derivative.location_url = output[:url]
121126
# For Intercom push

config/url_handlers.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ nginx:
1515
http:
1616
video: <%=http_base%>/<%=path%>/<%=filename%>.<%=extension%>/index.m3u8
1717
audio: <%=http_base%>/<%=path%>/<%=filename%>.<%=extension%>/index.m3u8
18+
audio_mp3: <%=http_base%>/<%=path%>/<%=filename%>.<%=extension%>
1819

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ services:
6565
- ./solr/conf:/opt/solr/avalon_conf
6666

6767
hls:
68-
image: avalonmediasystem/nginx:minio-jammy
68+
image: avalonmediasystem/nginx:mp3
6969
environment:
7070
- AVALON_DOMAIN=http://avalon:3000
7171
- AVALON_STREAMING_BUCKET_URL=http://minio:9000/derivatives/
7272
volumes:
7373
- ./log/nginx:/var/log/nginx
74+
- ./nginx.conf.template:/etc/nginx/nginx.conf.template
7475
ports:
7576
- '8880:80'
7677
networks:

nginx.conf.template

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
user nginx;
2+
worker_processes 4;
3+
daemon off;
4+
5+
events {
6+
worker_connections 1024;
7+
}
8+
9+
http {
10+
server {
11+
listen $AVALON_STREAMING_PORT;
12+
13+
vod_mode $VOD_MODE;
14+
vod_upstream_location /s3;
15+
vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT';
16+
vod_last_modified_types *;
17+
vod_metadata_cache metadata_cache 512m;
18+
vod_response_cache response_cache 128m;
19+
vod_hls_absolute_index_urls off;
20+
vod_hls_absolute_master_urls off;
21+
22+
open_file_cache max=1000 inactive=5m;
23+
open_file_cache_valid 2m;
24+
open_file_cache_min_uses 1;
25+
open_file_cache_errors on;
26+
27+
location /status {
28+
vod_status;
29+
}
30+
31+
location /s3/avalon/ {
32+
internal;
33+
proxy_pass $AVALON_STREAMING_BUCKET_URL;
34+
}
35+
36+
location ~ ^/avalon/(?<stream>.+/(?<resource>.+\.(?:m3u8|ts))) {
37+
vod hls;
38+
39+
gzip on;
40+
gzip_types application/x-mpegURL;
41+
42+
set $token "$arg_token";
43+
add_header X-Stream-Auth-Token "$token";
44+
45+
sub_filter_types application/vnd.apple.mpegurl;
46+
sub_filter_once off;
47+
sub_filter '.ts' ".ts?token=$token";
48+
49+
auth_request /auth;
50+
add_header Access-Control-Allow-Headers '*';
51+
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
52+
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
53+
add_header Access-Control-Allow-Origin '*';
54+
expires 100d;
55+
}
56+
57+
location ~ ^/avalon/(.+/.+\.(?:mp3)) {
58+
set $stream $1;
59+
60+
set $token "$arg_token";
61+
add_header X-Stream-Auth-Token "$token";
62+
63+
gzip on;
64+
gzip_types audio/mp3;
65+
66+
sub_filter_types audio/mp3;
67+
sub_filter_once off;
68+
sub_filter '.mp3' ".mp3?token=$token";
69+
70+
auth_request /auth;
71+
72+
add_header Access-Control-Allow-Headers '*';
73+
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
74+
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
75+
add_header Access-Control-Allow-Origin "*";
76+
expires 100d;
77+
proxy_pass $AVALON_STREAMING_BUCKET_URL/$stream;
78+
}
79+
80+
location = /auth {
81+
resolver 127.0.0.1;
82+
proxy_pass $AVALON_DOMAIN/authorize.txt?token=$token&name=$stream;
83+
proxy_pass_request_body off;
84+
proxy_set_header Content-Length "";
85+
proxy_set_header X-Original-URI $request_uri;
86+
}
87+
88+
location /crossdomain.xml {
89+
default_type text/xml;
90+
return 200 '<?xml version="1.0"?>
91+
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
92+
<cross-domain-policy>
93+
<site-control permitted-cross-domain-policies="all"/>
94+
<allow-access-from domain="*" secure="false"/>
95+
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
96+
</cross-domain-policy>';
97+
expires 24h;
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)