0

我正在尝试ffmpeg在服务器上进行视频裁剪,一旦用户上传的视频文件被保存,然后我ffmpeg在其上运行命令来裁剪视频并使用命令进一步用裁剪文件替换上传的文件mv。尽管此代码在控制台中逐步运行时运行manage.py良好,但上传的文件在测试时没有被裁剪。

new_video.save()
url=new_video.video_file.url
real_path = "/home/chanceapp/webapps/chanceapp/chanceapp"+url
fake_crop_path = "/home/chanceapp/webapps/chanceapp/chanceapp/fake1"+url
rotate_crop = "ffmpeg -i %s -vf "%(real_path)+r'"transpose=2 , crop=480:480:0:0" '+\
    "-vcodec libx264 -strict -2 -crf 18 %s"%(fake_crop_path)
move_cropped = "mv"+" %s"%(fake_crop_path)+" %s"%(real_path)
commands = [rotate_crop,move_cropped]
for command in commands:
    subprocess.call(command,shell=True ) 

谢谢你。

4

1 回答 1

0

You should debug it more:

from subprocess import Popen, PIPE

for command in commands:
    result = Popen(command, shell=True, stdout=PIPE).stdout.read()
    if len(result) > 0:
        raise Exception(result)

Does it raise any exception?

于 2013-09-28T15:17:53.253 回答