2013-08-03 146 views
8

我通过使用python -m SimpleHTTPServer调用服务器来将文件夹中的文件共享到其他设备。音频/视频流使用SimpleHTTPServer失败

我只是想流视频/音频(标准MP4 & MP3,无论是在20MB)到另一台计算机使用此&它WORKS(但在终端抛出的错误(下上市))。

不知何故,视频/音频失败(除了非常小的MP3文件)与iPhone/iPad的Safari玩。它绝对与媒体文件无关,因为我在iPhone中使用Apache成功传输它们。

任何想法为什么会发生?

Exception happened during processing of request from ('192.168.1.2', 51775) 
Traceback (most recent call last): 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock 
    self.process_request(request, client_address) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request 
    self.finish_request(request, client_address) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 641, in __init__ 
    self.finish() 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 694, in finish 
    self.wfile.flush() 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush 
    self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
error: [Errno 32] Broken pipe 
+1

查看这些[alternatives](http://stackoverflow.com/questions/12905426/faster-alternative-to-pythons-simplehttpserver)到Python的SimpleHTTPServer模块。 – mtadd

回答

6

作为sugested要么使用Python替代,What is a faster alternative to Python's http.server (or SimpleHTTPServer)?或完全使用全喷射织物serwer。 Quick google表示Mac支持Nignx和Apache2。

+2

感谢您选择链接,但[标记的答案](http://stackoverflow.com/a/12905427/2602869)建议[http-server](https://github.com/nodeapps/http-server )(对于node.js)似乎没有流式传输视频文件。但是,[twistd](http://twistedmatrix.com)(对于Python)如[另一个答案](http://stackoverflow.com/a/14618010/2602869)中所解释的那样很好! –

+0

@JikkuJose如何在终端中启动_twisted_?还纠正扭曲的链接[在这里](http://twistedmatrix.com)。 –