转换用户上传的视频文件服务它使用django,python [英] Converting video files uploaded by user & serving it using django, python
问题描述
我需要使用用户上传的任何视频文件,将其转换为flv或webM&然后将其显示给用户。在做了一些研究之后,我得出结论,我必须使用ffmpeg进行转换,但我不确定如何处理整个管道。也就是说,
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,
- 由用户获取刚上传的文件。
- 在django后端,文件处理?
- 处理完毕后,删除用户&将其替换为已转换的文件。
我只知道这个广泛的步骤,但是如何以流线型连接每个步骤?例如如何启动系统调用ffmpeg在CLI上从python&继续等待转换过程完成。另外如何更新DB现在指向新的转换文件&删除旧的。如何告诉用户(实时)文件转换,转换等,像进度条?
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 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:
可能只是事情。 python中的系统调用可以通过os模块中的函数完成,如os.system:
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
或os.popen:
>>> f=os.popen("/bin/ls")
>>> f.read()
'api-manual.pdf\nC++\nGUI\nJava\nREADME\n'
>>> f.close()
有一个关于进程间通信的部分等等在python文档中。我确定。
there's a section on inter-process communication and so on in the python docs. I'm sure.
这篇关于转换用户上传的视频文件服务它使用django,python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!