-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
39 lines (29 loc) · 1 KB
/
server.py
File metadata and controls
39 lines (29 loc) · 1 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
import os
import random
import string
import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer
def random_string(length):
return ''.join(random.choice(string.lowercase) \
for i in range(length))
def python_logo(segment, width, height, br):
file_in = random_string(10) + "_in_" + ".ts"
file_out = random_string(10) + "_out_" + ".ts"
with open(file_in, "wb") as handle:
handle.write(segment.data)
print 'width:', width
print 'height:', height
print 'bitrate:', br
cmd = "ffmpeg -y -i " + file_in + " -s " \
+ width + "x" + height + " " + file_out
print cmd
os.system(cmd)
with open(file_out, "rb") as handle:
trans_segment = xmlrpclib.Binary(handle.read())
cmd = "rm -f " + file_in + " " + file_out
os.system(cmd)
return trans_segment
server = SimpleXMLRPCServer(("localhost", 10002))
print "Listening on port 8000..."
server.register_function(python_logo, 'python_logo')
server.serve_forever()