我是这条蟒蛇的新手。我将 webm 视频文件分成块,但我无法使用 python 程序使它们单独播放。但是在我将块加入单个文件后它会播放。我知道它是因为没有头文件。请帮助我将头文件附加到零件上以使它们可以单独播放。请回复。提前非常感谢。
这是代码:
客户端:
import socket, os
import time
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 5005))
size = 1024
while True:
fname = "/home/xincoz/test/conn2.webm"
fn = client_socket.recv(1024)
print fn
fp = open(fname,'wb')
while True:
strng = client_socket.recv(int(fn))
print strng
if not strng:
break
fp.write(strng)
fp.close()
print "Data Received successfully"
exit()
服务器端:
import os,kaa.metadata
import sys,time
import socket
import Image
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(("localhost", 5005))
server_socket.listen(5)
client_socket, address = server_socket.accept()
print "Conencted to - ",address,"\n"
file = '/home/xincoz/Downloads/connect.webm'
a = kaa.metadata.parse(file)
print '\n Maybe, pending work'
file_name = open(file,'rb')
size=str(os.path.getsize(file))
print size
client_socket.send(str(os.path.getsize(file)))
print file_name
strng = file_name.read(os.path.getsize(file))
client_socket.send(strng[0:2000000])
file_name.close()
print str(a)+"Meta Data"
print "Data sent successfully"