Reputation: 211
I am using python to create a Macro Module inside MevisLab environment. I wanted to use ffmpeg in command prompt inside Python. The Problem is the command prompt closes too fast that i couldnt read while executing ffmpeg.
My code
t = 'ffmpeg -r'+str(ctx.field("FrameRate").value)+'-f image2 -pix_fmt yuv44p -s 1920x1080 -i'+path+'%0d.png -vodec libx264 -crf 15'+path+'.mp4'
os.system(t)
Upvotes: 0
Views: 403
Reputation: 155
You can try to redirect stdout/stderr to file and read it later:
t = 'ffmpeg -r'+str(ctx.field("FrameRate").value)+'-f image2 -pix_fmt yuv420p -s 1920x1080 -i'+path+'%0d.png -vcodec libx264 -crf 15'+path+'.mp4'
log_path = r'C:\log.txt'
os.system(t + ' >> ' + log_path + ' 2>&1')
Probably, cause of such issue is lack of spaces between ffmpeg parameters (such as -f / -i).
Upvotes: 1
Reputation: 9172
You can capture the output and print it from Python itself. Say:
from subprocess import check_output, STDOUT
try:
output = check_output(t, shell=True, stderr=STDOUT)
except CalledProcessError, e:
output = e.output
check_output
will raise an exception if the command returns with status code != 0. I'm capturing the error output in there too, just in case.
Upvotes: 0