-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a separate playbackSpeeder element
- Loading branch information
1 parent
32ae93d
commit f5960b6
Showing
6 changed files
with
54 additions
and
33 deletions.
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
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,47 @@ | ||
defmodule ExNVR.HLS.PlaybackSpeeder do | ||
@moduledoc """ | ||
Rewrites buffers pts according to the prodivded playback rate. | ||
""" | ||
|
||
use Membrane.Filter | ||
|
||
def_input_pad :input, | ||
demand_mode: :auto, | ||
demand_unit: :buffers, | ||
accepted_format: _any, | ||
availability: :always | ||
|
||
def_output_pad :output, | ||
demand_mode: :auto, | ||
accepted_format: _any | ||
|
||
def_options rate: [ | ||
spec: float(), | ||
default: 1, | ||
description: """ | ||
The playback speed rate to either speed up or slow down the stream. | ||
* A value lower than 1: speeds up the stream. | ||
* A value greater than 1: slows down the stream. | ||
* 1 is the default value which is the normal stream speed. | ||
""" | ||
] | ||
|
||
@impl true | ||
def handle_init(_ctx, options) do | ||
state = | ||
options | ||
|> Map.from_struct() | ||
|
||
{[], state} | ||
end | ||
|
||
@impl true | ||
def handle_process(:input, buffer, _ctx, state) do | ||
buffer = %{ | ||
buffer | ||
| pts: trunc(buffer.pts * state.rate) | ||
} | ||
|
||
{[buffer: {:output, buffer}], state} | ||
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