-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.py
More file actions
88 lines (66 loc) · 2.45 KB
/
Server.py
File metadata and controls
88 lines (66 loc) · 2.45 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import subprocess
import threading
from queue import Queue
NUMBER_OF_THREADS = 3
JOB_NUMBER = [1,2,3]
queue = Queue()
def create_jobs():
for x in JOB_NUMBER:
print(x)
queue.put(x)
queue.join()
def work():
while True:
print("Empezo")
x = queue.get()
print(x)
if x == 1:
while True:
print("Proceso 1")
#------------------------------------------------ Cambiar direccion de los videos y la IP
p = subprocess.Popen('ffmpeg -i F:/ARCHIVOS/Documentos/GitHub/APRENDIENDO/Python/UDP/data/zeus.mp4 -f mpegts udp://192.168.1.18:1337', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
print(p.returncode)
if x == 2:
while True:
print("Proceso 2")
p = subprocess.Popen('ffmpeg -i F:/ARCHIVOS/Documentos/GitHub/APRENDIENDO/Python/UDP/data/rambo.mp4 -f mpegts udp://192.168.1.18:1338', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
print(p.returncode)
if x == 3:
print("Proceso 3")
p = subprocess.Popen('ffmpeg -i F:/ARCHIVOS/Documentos/GitHub/APRENDIENDO/Python/UDP/data/noticias.mp4 -f mpegts udp://192.168.1.18:1339', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
print(p.returncode)
queue.task_done()
def create_workers():
for _ in range(NUMBER_OF_THREADS):
print("Creando workers")
t = threading.Thread(target=work)
t.daemon = True
t.start()
create_workers()
create_jobs()
''' import ffmpeg
import socket
# Here we define the UDP IP address as well as the port number that we have
# already defined in the client python script.
UDP_IP_ADDRESS = "127.0.0.1"
UDP_PORT_NO = 1337
packet_size = 65507
serverSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
serverSock.bind((UDP_IP_ADDRESS, UDP_PORT_NO))
process = (
ffmpeg
.input('F:/ARCHIVOS/Documentos/GitHub/APRENDIENDO/Python/UDP/video.mp4')
.output('-', format='mpegts')
.run_async(pipe_stdout=True)
)
while process.poll() is None:
packet = process.stdout.read(packet_size)
try:
serverSock.sendall(packet)
except socket.error:
process.stdout.close()
process.wait()
break '''