add `headers
` option to create_ffmpeg_player()
headers can't be passed through 'options' because in '-headers' flag shoul be placed before '-i' At least for ffmpeg 2.8.4
This commit is contained in:
parent
8b1854e759
commit
f075548d78
@ -334,7 +334,7 @@ class VoiceClient:
|
|||||||
struct.pack_into('>I', buff, 8, self.ssrc)
|
struct.pack_into('>I', buff, 8, self.ssrc)
|
||||||
return buff
|
return buff
|
||||||
|
|
||||||
def create_ffmpeg_player(self, filename, *, use_avconv=False, pipe=False, options=None, after=None):
|
def create_ffmpeg_player(self, filename, *, use_avconv=False, pipe=False, options=None, headers=None, after=None):
|
||||||
"""Creates a stream player for ffmpeg that launches in a separate thread to play
|
"""Creates a stream player for ffmpeg that launches in a separate thread to play
|
||||||
audio.
|
audio.
|
||||||
|
|
||||||
@ -369,6 +369,8 @@ class VoiceClient:
|
|||||||
to the stdin of ffmpeg.
|
to the stdin of ffmpeg.
|
||||||
options: str
|
options: str
|
||||||
Extra command line flags to pass to ``ffmpeg``.
|
Extra command line flags to pass to ``ffmpeg``.
|
||||||
|
headers: dict
|
||||||
|
HTTP headers dictionary to pass to ``-headers`` command line option
|
||||||
after : callable
|
after : callable
|
||||||
The finalizer that is called after the stream is done being
|
The finalizer that is called after the stream is done being
|
||||||
played. All exceptions the finalizer throws are silently discarded.
|
played. All exceptions the finalizer throws are silently discarded.
|
||||||
@ -386,8 +388,13 @@ class VoiceClient:
|
|||||||
"""
|
"""
|
||||||
command = 'ffmpeg' if not use_avconv else 'avconv'
|
command = 'ffmpeg' if not use_avconv else 'avconv'
|
||||||
input_name = '-' if pipe else shlex.quote(filename)
|
input_name = '-' if pipe else shlex.quote(filename)
|
||||||
cmd = command + ' -i {} -f s16le -ar {} -ac {} -loglevel warning'
|
headers_arg = ""
|
||||||
cmd = cmd.format(input_name, self.encoder.sampling_rate, self.encoder.channels)
|
if isinstance(headers, dict):
|
||||||
|
for key, value in headers.items():
|
||||||
|
headers_arg += "{}: {}\r\n".format(key, value)
|
||||||
|
headers_arg = ' -headers ' + shlex.quote(headers_arg)
|
||||||
|
cmd = command + '{} -i {} -f s16le -ar {} -ac {} -loglevel warning'
|
||||||
|
cmd = cmd.format(headers_arg, input_name, self.encoder.sampling_rate, self.encoder.channels)
|
||||||
|
|
||||||
if isinstance(options, str):
|
if isinstance(options, str):
|
||||||
cmd = cmd + ' ' + options
|
cmd = cmd + ' ' + options
|
||||||
|
Loading…
x
Reference in New Issue
Block a user