简体   繁体   中英

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,

  1. Get the just uploaded file by the user.
  2. In django backend somehow send the file for processing?
  3. 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? eg how to start a system call to ffmpeg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM