diff --git a/CHANGELOG b/CHANGELOG index c679907..6981c5c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +== 8.1.0-beta.2 2025-07-17 + +Fixes: +* Added support for base URLs in HLS playlists generated via the `FFMPEG::DASH` classes. + == 8.1.0-beta.1 2025-07-17 Fixes: diff --git a/lib/ffmpeg/dash/adaptation_set.rb b/lib/ffmpeg/dash/adaptation_set.rb index 1475781..5d8365a 100644 --- a/lib/ffmpeg/dash/adaptation_set.rb +++ b/lib/ffmpeg/dash/adaptation_set.rb @@ -104,6 +104,9 @@ def to_m3u8mt(group_id: content_type, default: true, autoselect: true) return unless %w[audio video].include?(content_type) return unless representations.any? + url = "stream#{representations.first.id}.m3u8" + url = URI.join(representations.first.base_url, url).to_s if representations.first.base_url + m3u8t( 'EXT-X-MEDIA', 'TYPE' => content_type.upcase, @@ -112,7 +115,7 @@ def to_m3u8mt(group_id: content_type, default: true, autoselect: true) 'LANGUAGE' => quote(lang || 'und'), 'DEFAULT' => default ? 'YES' : 'NO', 'AUTOSELECT' => autoselect ? 'YES' : 'NO', - 'URI' => quote("stream#{representations.first.id}.m3u8") + 'URI' => quote(url) ) end diff --git a/lib/ffmpeg/dash/representation.rb b/lib/ffmpeg/dash/representation.rb index fcd64da..88bde89 100644 --- a/lib/ffmpeg/dash/representation.rb +++ b/lib/ffmpeg/dash/representation.rb @@ -169,6 +169,9 @@ def to_m3u8 def to_m3u8si(audio_group_id: nil, video_group_id: nil) return unless %w[audio video].include?(@adaptation_set.content_type) + url = "stream#{id}.m3u8" + url = URI.join(base_url, url).to_s if base_url + "#{m3u8t( 'EXT-X-STREAM-INF', 'BANDWIDTH' => bandwidth, @@ -176,7 +179,7 @@ def to_m3u8si(audio_group_id: nil, video_group_id: nil) 'RESOLUTION' => resolution, 'AUDIO' => quote(audio_group_id), 'VIDEO' => quote(video_group_id) - )}\n#{"stream#{id}.m3u8"}" + )}\n#{url}" end private diff --git a/lib/ffmpeg/version.rb b/lib/ffmpeg/version.rb index 72f6399..43673a9 100644 --- a/lib/ffmpeg/version.rb +++ b/lib/ffmpeg/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module FFMPEG - VERSION = '8.1.0-beta.1' + VERSION = '8.1.0-beta.2' end diff --git a/spec/ffmpeg/dash/manifest_spec.rb b/spec/ffmpeg/dash/manifest_spec.rb index d41e418..985c323 100644 --- a/spec/ffmpeg/dash/manifest_spec.rb +++ b/spec/ffmpeg/dash/manifest_spec.rb @@ -176,5 +176,14 @@ M3U8 end end + + context 'with base URL set' do + it 'includes the base URL in the playlist URIs' do + manifest.base_url = 'http://example.com/' + is_expected.to include('http://example.com/stream0.m3u8') + is_expected.to include('http://example.com/stream1.m3u8') + is_expected.to include('http://example.com/stream2.m3u8') + end + end end end