-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsend_livewire_stream.py
53 lines (36 loc) · 1.34 KB
/
send_livewire_stream.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
import sys
import os
import socket
import struct
def ipToDecimal(originalIp):
""" Takes a standard dotted-quad IP Address and returns it as an integer """
ipStruct = socket.inet_pton(socket.AF_INET, originalIp)
(ipDecimal, ) = struct.unpack(">L", ipStruct)
return ipDecimal
def decimalToIp(originalDecimal):
""" Takes a integer-based IP Address and returns it as the standard dotted-quad format """
ipStruct = struct.pack(">L", originalDecimal)
return socket.inet_ntoa(ipStruct)
LOCAL_IP = '10.2.160.1'
AXIA_IP = '239.192.0.0'
# AXIA_IP = '10.2.160.1'
BASE_IP = socket.inet_aton(AXIA_IP)
AXIA_PORT = 111
AXIA_PORT = 16701
RTPDUMP_BIN = 'rtpdump'
PLAY_BIN = 'play'
INPUT_DEVICE = ['-re', "-f", "dshow", '-i',
'audio="Livewire In 06 (AXIA IP-Driver (WDM))"']
INPUT_DEVICE = ['-re', '-i', 'https://stream.iwi.radio/Awa_FM.aac']
SEND_IP = decimalToIp(int(AXIA_PORT) + ipToDecimal(AXIA_IP))
print(f"Send to port {AXIA_PORT} => {SEND_IP}")
command = (
['ffmpeg'] +
INPUT_DEVICE +
['-c:a', 'pcm_s24be', '-ar', '48000', '-ac',
'2', '-f', 'rtp', f'rtp://{SEND_IP}:5004?localaddr={LOCAL_IP}']
)
print(" ".join(command))
# os.system(RTPDUMP_BIN + " -F payload " + hex(multicastAddr) + "/5004 | " +
# PLAY_BIN + " -c 2 -r 48000 -b 24 -e signed-integer -B -t raw -")