Convert user uploaded video files and maintenance using django, python

I need to take any video file uploaded by the user, convert it to flv or webM, and then display it to the user. Now, after some research, I have come to the conclusion that I should use ffmpeg for conversion, but I'm not sure how to care for the entire pipeline. Namely,

  • Get the downloaded file by the user.
  • Does the django backend somehow send the file for processing?
  • After processing is complete, delete the original file downloaded by the user and replace it with the converted file.

I just know about these broad steps, but how about how to connect each step in an optimized way? for example, how to start the ffmpeg system call on the CLI from python and continue to wait for the conversion process to complete. Also, how to update the database to now point to a new converted file and delete the old one. How to inform the user (live) that the file has been converted, in the conversion, etc., As a progress bar?

I know this is kind of a comprehensive question, but help with any / all bits will be great!

+4
source share
1 answer

If the conversion takes a long time, you may need to pass them to the task handler:

http://celeryproject.org/

maybe just a thing. Python system calls can be made using functions in the os module, for example, 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 is a section on interprocess communication, etc. in python docs. I'm sure.

+3
source

Source: https://habr.com/ru/post/1336735/


All Articles