Media streaming via RTP fully functional.
This commit is contained in:
parent
0b559a8f85
commit
55ae3ff048
@ -6,4 +6,4 @@ t=0 0
|
||||
a=tool:libavformat 58.29.100
|
||||
m=audio 1234 RTP/AVP 97
|
||||
b=AS:800
|
||||
a=rtpmap:97 PCMU/50000/2
|
||||
a=rtpmap:97 PCMU/32000/2
|
||||
|
||||
5
radio.py
5
radio.py
@ -11,6 +11,7 @@ import struct
|
||||
class Radio:
|
||||
FORMAT = 'CS16'
|
||||
SAMPLES = 8192
|
||||
PORT = 5001
|
||||
|
||||
def __init__(self, device_info):
|
||||
self.device_info = device_info
|
||||
@ -76,7 +77,7 @@ class Radio:
|
||||
|
||||
def _init_stream(self):
|
||||
self.playback = subprocess.Popen(
|
||||
['/usr/bin/sox', '-t', 'raw', '-r', '32000', '-b', '16', '-c', '2', '-L', '-e', 'signed-integer', '-', '-d'],
|
||||
['/usr/bin/ffmpeg', '-f', 's16le', '-ar', '32000', '-ac', '2', '-i', '-', '-f', 'rtp', f'rtp://localhost:{Radio.PORT}'],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL
|
||||
@ -120,7 +121,7 @@ if __name__ == '__main__':
|
||||
print('Stream started.')
|
||||
|
||||
# Let the stream play for a while
|
||||
time.sleep(5)
|
||||
time.sleep(15)
|
||||
|
||||
print('Ending stream...')
|
||||
sdr.end_stream()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user