ffmpeg子进程check_call中的concat字符串

时间:2012-07-06 06:02:11

标签: python ffmpeg

需要替换子进程命令中的文件名,即文件名

filename = '\'D\:/imagesequence/thumbnail.jpg\''


task = '\"movie= ' + filename + '[watermark]; [in][watermark] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/3 [out]\"'

c = subprocess.check_call([“ffmpeg”,“ - i”,“D:/imagesequence/background222.jpg”,“ - vf”,task,“D:/imagesequence/fwtm108.jpg”],shell = TRUE)

这会给出错误

# Error: CalledProcessError: Command '['ffmpeg', '-i', 'D:/imagesequence/background222.jpg', '-vf', '"movie= \'D\\:/imagesequence/thumbnail.jpg\'[watermark];[in][watermark] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/3 [out]"', 'D:/imagesequence/fwtm107.jpg']' returned non-zero exit status 1 # 

当完全放好时它运作良好

c = subprocess.check_call(["ffmpeg", "-i", "D:/imagesequence/background222.jpg", "-vf", "movie= 'D\:/imagesequence/thumbnail.jpg'[watermark]; [in][watermark] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/3 [out]", "D:/imagesequence/fwtm101.jpg"],shell=True)

即使这样也可以

task = "movie= 'D\:/imagesequence/thumbnail.jpg'[watermark]; [in][watermark] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/3 [out]"

c = subprocess.check_call(["ffmpeg", "-i", "D:/imagesequence/background222.jpg", "-vf", task, "D:/imagesequence/fwtm102.jpg"],shell=True)

任何不同的观点。我无法看到它。

1 个答案:

答案 0 :(得分:0)

q = "D\:/imagesequence/thumbnail.jpg"
task = "movie= '%s'[watermark]; [in][watermark] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/3 [out]" % q

c = subprocess.check_call(["ffmpeg", "-i", "D:/imagesequence/background222.jpg", "-vf", task, "D:/imagesequence/fwtm106.jpg"],shell=True)

这很有用。谢谢你

http://comments.gmane.org/gmane.comp.python.tutor/65858