Skip to content

Commit fc34c19

Browse files
committed
feat(mpeg-dash): add support for base URLs in generated HLS playlists
1 parent 5b92852 commit fc34c19

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
== 8.1.0-beta.2 2025-07-17
2+
3+
Fixes:
4+
* Added support for base URLs in HLS playlists generated via the `FFMPEG::DASH` classes.
5+
16
== 8.1.0-beta.1 2025-07-17
27

38
Fixes:

lib/ffmpeg/dash/adaptation_set.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ def to_m3u8mt(group_id: content_type, default: true, autoselect: true)
104104
return unless %w[audio video].include?(content_type)
105105
return unless representations.any?
106106

107+
url = "stream#{representations.first.id}.m3u8"
108+
url = URI.join(representations.first.base_url, url).to_s if representations.first.base_url
109+
107110
m3u8t(
108111
'EXT-X-MEDIA',
109112
'TYPE' => content_type.upcase,
@@ -112,7 +115,7 @@ def to_m3u8mt(group_id: content_type, default: true, autoselect: true)
112115
'LANGUAGE' => quote(lang || 'und'),
113116
'DEFAULT' => default ? 'YES' : 'NO',
114117
'AUTOSELECT' => autoselect ? 'YES' : 'NO',
115-
'URI' => quote("stream#{representations.first.id}.m3u8")
118+
'URI' => quote(url)
116119
)
117120
end
118121

lib/ffmpeg/dash/representation.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,17 @@ def to_m3u8
169169
def to_m3u8si(audio_group_id: nil, video_group_id: nil)
170170
return unless %w[audio video].include?(@adaptation_set.content_type)
171171

172+
url = "stream#{id}.m3u8"
173+
url = URI.join(base_url, url).to_s if base_url
174+
172175
"#{m3u8t(
173176
'EXT-X-STREAM-INF',
174177
'BANDWIDTH' => bandwidth,
175178
'CODECS' => quote(codecs),
176179
'RESOLUTION' => resolution,
177180
'AUDIO' => quote(audio_group_id),
178181
'VIDEO' => quote(video_group_id)
179-
)}\n#{"stream#{id}.m3u8"}"
182+
)}\n#{url}"
180183
end
181184

182185
private

lib/ffmpeg/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module FFMPEG
4-
VERSION = '8.1.0-beta.1'
4+
VERSION = '8.1.0-beta.2'
55
end

spec/ffmpeg/dash/manifest_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,14 @@
176176
M3U8
177177
end
178178
end
179+
180+
context 'with base URL set' do
181+
it 'includes the base URL in the playlist URIs' do
182+
manifest.base_url = 'http://example.com/'
183+
is_expected.to include('http://example.com/stream0.m3u8')
184+
is_expected.to include('http://example.com/stream1.m3u8')
185+
is_expected.to include('http://example.com/stream2.m3u8')
186+
end
187+
end
179188
end
180189
end

0 commit comments

Comments
 (0)