Python - How to Pass A Spaced File? -


this question has answer here:

i'm writing script use ffmpeg create video picture. need save file file name something.mp4 (with spaces between words in filename). when try this, receive error:

[null @ 02c2fa20] unable find suitable output format './lol/media/videos/lets' ./lol/media/videos/lets: invalid argument. 

the script gets first word of filename. here's code:

from subprocess import check_output import ntpath import os  class videomaker():     def makevidoes(self, path, savepath, time=15):         if not os.path.exists(savepath):             os.makedirs(savepath)         try:             filename = ntpath.basename(os.path.splitext(path)[0].replace('+', ' ') + ".mp4")             print filename #file name 'lets play games.mp4'             check_output("ffmpeg -loop 1 -i " + path + " -c:v libx264 -t " + str(time) + " -pix_fmt yuv420p -vf scale=1024:728 " + "" + savepath + filename + "", shell=true)             return savepath + filename         except:             print "error" 

pass check_output list of separate terms:

            check_output(["ffmpeg", "-loop", "1", "-i", path, "-c:v",                           "libx264", "-t", str(time), "-pix_fmt",                           "yuv420p", "-vf", "scale=1024:728",                           savepath + filename],                          shell=true) 

this ensure treated correctly distinct arguments when contain special characters.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -