2015-10-18 45 views
1

我想從wsgi應用程序返回mp4。我沒有使用Django或其他框架。該mp4parseParams函數返回:從wsgi應用程序返回mp4

def parseParams(params): 
    // cmd invokes ffmpeg, which writes output to pipe:1 (stdout) 
    return [ call(cmd) ] 

form = "<html>...</html>" 

def application(environ, start_response): 
    x = handle_post(environ) 
    if (isinstance(x, dict)): 
     start_response('200 OK', [('Content-Type','video/mp4')]) 
     return parseParams(x) 
    else: 
     start_response('200 OK', [('Content-Type','text/html')]) 
     return [form] 

日誌是完全二進制的數據,ffmpeg想必輸出,並沒有返回到瀏覽器的,雖然我可以看到,MIME類型頭設置正確。我錯過了什麼?

回答

1

當然,我發佈一個問題的時間不會超過我的工作時間。我發現this post和修改parseParams這樣結束:

proc = Popen(cmd, stdout=PIPE) 
out, err = proc.communicate() 
return [ out ] 

完美的作品!

+0

我不得不從'return'語句中刪除括號。但除此之外,這正是我所需要的。 – Mike

+0

請注意,如果這對你有幫助:) –

+0

我已經有了。 – Mike

相關問題