开发者

Python: How to use os.spawnv with a lot of arguments?

Im working in a Python plugin for XBMC (xbmc.org) and I want to execute a program (ffmpeg.exe) from my plugin without the cmd window appears. If I use os.system() to call ffmpeg.exe works fine but the xbmc minimizes because os.system open a cmd window a few seconds. So, I try to use os.spawnv() that I think its possible that allow me to call ffmpeg.exe without cmd window appears. The problem is I know how to use os.system but I dont know how to use os.spawnv. Im trying this, but doesnt work:

os.spawnv(os.P_DETACH,'"C:\Program Files (x86)\XBMC\scripts\Base De Datos\ffmpeg.exe" -y -ss 30 -i "C:\Program Files (x86)\XBMC\scripts\Base De Datos\Movie.avi" -f mjpeg -vframes 1 -s 720x400 -an  "C:\Program Files (x86)\XBMC\scripts\Base De Datos\thumbnail.jpg"')

"C:\Program Files (x86)\XBMC\scripts\Base De Datos\ffmpeg.exe" = The path of the ffmpeg.exe
-y -ss 30 -i = Arguments for ffmpeg.exe
"C:\Program Files (x86)\XBMC\scripts\Base De Datos\Movie.avi" = The path of the movie I want to use with ffmpeg.exe to make a thumbnail (argument for ffmpeg.exe)
-f mjpeg -vframes 1 -s 720x400 = More arguments for ffmpeg.exe
"C:\Program Files (x86)\XBMC\scripts\Base De Datos\thumbnail.jpg" = The path for save the thumbnail.

I trying a lot of methods to make a thumbnail but its seems to me there is really complicated in a xbmc plugin, I cannot use pyffmpeg because I cannot import the module from my plugin without installing it into de S.O. and my plugin must be portable, I could use PIL but only could make thumbnails of pictures and I need to make thumbnails of videos. I know some modules in python that allow me to call process without cmd windo开发者_Python百科w appears but depends of others modules like win32api that I cannot import for the same reasons I cannot use/import pyffmpeg... so I triying the "bad way" using this method, with os.system works but I loose control of my plugin window. If someone know other way to make a thumbnail of a video using python, please tell me. The other matter is my plugin must be multiplataform (Win and Linux at least) so this way is not good enought but it could be a big step for me.

Thanks a lot.


As per http://docs.python.org/library/os.html#os.spawnv, pass the arguments in a list:

os.spawnv(os.P_DETACH, "path\to\program.exe", ["arg1", "arg2", "arg3"])


This way:

os.system(""C:\\Program Files (x86)\\XBMC\\scripts\\Base De Datos\\ffmpeg.exe" -y -ss 423 -i "C:\Program Files (x86)\XBMC\scripts\Base De Datos\Movie.avi" -f mjpeg -vframes 1 -s 720x320 -an "C:/Program Files (x86)/XBMC/scripts/Base De Datos/thumbnail.jpg"")

Works fine but minimizes xbmc because pop up a cmd window, so Im trying to do the same using os.spawnv but gives me an Error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜