我正在开发一个Django应用程序,它使用FFMPEG。基本上,它接收用户上传的视频,并使用FFMPEG将其转码为240p、360p和480p。由于这是服务器端代码,许多用户可能会同时上载。同样在转码之后,记录被添加到数据库表中
out="media/uploads/"+folder #This is the upload path where folder is the name of the video
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
command = "ffmpeg -i '"+os.path.join(BASE_DIR,out)+"/"+fname+"' -s 426x240 '"+os.path.join(BASE_DIR,out)+"/240p.mp4'"
subprocess.call(command,shell=True)
convert = Convert.objects.get_or_create(vid=rec,name="240p.mp4",video=str(out+'/240p.mp4'))
command = "ffmpeg -i '"+os.path.join(BASE_DIR,out)+"/"+fname+"' -s 640x360 '"+os.path.join(BASE_DIR,out)+"/360p.mp4'"
subprocess.call(command,shell=True)
convert = Convert.objects.get_or_create(vid=rec,name="360p.mp4",video=str(out+'/360p.mp4'))
command = "ffmpeg -i '"+os.path.join(BASE_DIR,out)+"/"+fname+"' -s 854x480 '"+os.path.join(BASE_DIR,out)+"/480p.mp4'"
subprocess.call(command,shell=True)
convert = Convert.objects.get_or_create(vid=rec,name="480p.mp4",video=str(out+'/480p.mp4'))
由于此代码将在服务器上运行,因此多个用户可能会同时上载视频。我希望此代码在该场景中运行时不会出现任何问题。此外,数据库操作必须仅在执行FFMPEG命令后执行
必须对此代码进行哪些更改
目前没有回答
相关问题 更多 >
编程相关推荐