-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HLS output #18
Merged
Merged
HLS output #18
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d46b657
Add hls
Noarkhh 3c213fb
Add hls test
Noarkhh c7d6d56
Fix hls
Noarkhh 7eeeb24
Handle hls eos correctly
Noarkhh e2a24d8
Don't compare files with media
Noarkhh a413ae7
Add simple hls source for testing
Noarkhh 1912397
Fix tests
Noarkhh 7e537d7
Improve test
Noarkhh 6c9bdce
Minor refactoring
Noarkhh 1454780
Fix typespecs
Noarkhh 653cee9
WIP
Noarkhh aa0d42d
Bump hls version
Noarkhh 0844099
Fix function clauses ordering
Noarkhh c041b9d
Remove IO.inspects
Noarkhh b0e4b5b
Adjust for muxed_av
Noarkhh a6071ae
Don't test m3u8 files
Noarkhh 8e67dbc
Change fixture
Noarkhh a3a6663
Add a test and an example
Noarkhh 81ffecb
Change port number in rtmp hls test
Noarkhh 5036de8
Refactor the source
Noarkhh 0560ab7
Fix test
Noarkhh f01fc49
Fix module attribute
Noarkhh 562710e
Refactor compare
Noarkhh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitkeep | ||
!.gitignore |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<body> | ||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> | ||
<h1>Membrane Boombox HLS Example</h1> | ||
<video id="player" autoplay muted controls></video> | ||
<script> | ||
var video = document.getElementById('player'); | ||
var hls = new Hls(); | ||
hls.loadSource("hls_output/index.m3u8"); | ||
hls.attachMedia(video); | ||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
defmodule Boombox.HLS do | ||
@moduledoc false | ||
|
||
import Membrane.ChildrenSpec | ||
|
||
require Membrane.Pad, as: Pad | ||
alias Boombox.Pipeline.Ready | ||
alias Membrane.Time | ||
|
||
@spec link_output( | ||
Path.t(), | ||
Boombox.Pipeline.track_builders(), | ||
Membrane.ChildrenSpec.t() | ||
) :: Ready.t() | ||
def link_output(location, track_builders, spec_builder) do | ||
{directory, manifest_name} = | ||
if Path.extname(location) == ".m3u8" do | ||
{Path.dirname(location), Path.basename(location, ".m3u8")} | ||
else | ||
{location, "index"} | ||
end | ||
|
||
spec = | ||
[ | ||
spec_builder, | ||
child( | ||
:hls_sink_bin, | ||
%Membrane.HTTPAdaptiveStream.SinkBin{ | ||
manifest_name: manifest_name, | ||
manifest_module: Membrane.HTTPAdaptiveStream.HLS, | ||
storage: %Membrane.HTTPAdaptiveStream.Storages.FileStorage{ | ||
directory: directory | ||
}, | ||
hls_mode: :muxed_av | ||
} | ||
), | ||
Enum.map(track_builders, fn | ||
{:audio, builder} -> | ||
builder | ||
|> child(:hls_out_aac_encoder, Membrane.AAC.FDK.Encoder) | ||
|> via_in(Pad.ref(:input, :audio), | ||
options: [encoding: :AAC, segment_duration: Time.milliseconds(2000)] | ||
) | ||
|> get_child(:hls_sink_bin) | ||
|
||
{:video, builder} -> | ||
builder | ||
|> via_in(Pad.ref(:input, :video), | ||
options: [encoding: :H264, segment_duration: Time.milliseconds(2000)] | ||
) | ||
|> get_child(:hls_sink_bin) | ||
end) | ||
] | ||
|
||
%Ready{actions: [spec: spec]} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#EXTM3U | ||
#EXT-X-VERSION:7 | ||
#EXT-X-TARGETDURATION:5 | ||
#EXT-X-MEDIA-SEQUENCE:0 | ||
#EXT-X-DISCONTINUITY-SEQUENCE:0 | ||
#EXT-X-MAP:URI="muxed_header_g3cFdmlkZW8_part_0.mp4" | ||
#EXTINF:4.80365593, | ||
muxed_segment_0_g3cFdmlkZW8.m4s | ||
#EXTINF:4.288194112, | ||
muxed_segment_1_g3cFdmlkZW8.m4s | ||
#EXTINF:0.924473961, | ||
muxed_segment_2_g3cFdmlkZW8.m4s | ||
#EXT-X-ENDLIST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#EXTM3U | ||
#EXT-X-VERSION:7 | ||
#EXT-X-INDEPENDENT-SEGMENTS | ||
#EXT-X-STREAM-INF:BANDWIDTH=1176608,AVERAGE-BANDWIDTH=969642,RESOLUTION=480x270,CODECS="avc1.42e015,mp4a.40.2" | ||
g3cFdmlkZW8.m3u8 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use
hls_mode: :muxed_av
, it generally works better and that's what fishjam uses