Converting video files uploaded by user & serving it using django, python
I need to take any video file uploaded by the user, convert it into flv or webM & then display it to the user. Now after doing some research I came to the conclusion that I must use ffmpeg to do the conversion but I am unsure on how to take care of the entire pipeline. Namely,
- Get the just uploaded file by the user.
- In django backend somehow send the file for processing?
- After processing is complete remove the original file uploaded by the user & replace it with the converted file.
I just know of this broad steps but like how to connect each step in a streamlined fashion? e.g. how to start a system call to ffmpe开发者_JAVA技巧g on CLI from python & keep on waiting till the conversion process is done. Also how to update the DB to now point to the new converted file & delete the old one. How to tell the user (live) that the file is converted, in conversion etc, like a progress bar?
I know that this is kind of an overarching question but help with any/all bits will be great!
If a conversion is going to take a long time, you might want to consider passing them off to a task handler:
http://celeryproject.org/
might be just the thing. System calls in python can be done with functions in the os module, such as os.system:
>>> os.system("/bin/ls")
api-manual.pdf C++ GUI Java README
or os.popen:
>>> f=os.popen("/bin/ls")
>>> f.read()
'api-manual.pdf\nC++\nGUI\nJava\nREADME\n'
>>> f.close()
there's a section on inter-process communication and so on in the python docs. I'm sure.
精彩评论