1

I want to return an mp4 from a wsgi application. I'm not using Django or other framework. The mp4 is returned by the parseParams function:

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]

The logs are full of binary data, presumably the output of ffmpeg, and nothing is returned to the browser, although I can see that the mime type header is properly set. What am I missing?

Mike Slinn
  • 7,705
  • 5
  • 51
  • 85

1 Answers1

1

Of course, no sooner do I post a question than I get it to work. I found this post and modified parseParams to end this way:

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

Works perfectly!

Community
  • 1
  • 1
Mike Slinn
  • 7,705
  • 5
  • 51
  • 85
  • I had to remove the brackets from the `return` statement. But otherwise, this was just what I needed. – Mike Apr 22 '17 at 14:56