在编写python脚本以在pi上每分钟拍摄一张照片时,它会弹出以下错误:
“mmal:main:打开输出文件时出错:”
Python代码:
jpeg_list = open('jpeg_still_list.txt','w')
count = 0
tlcount = 0
while True:
os.system("raspistill -w 1920 -h 1080 -q 80 -o frames/%s.jpg" % count)
jpeg_list.write("frames%s.jpg" % count)
time.sleep(60)
count = count+1
if count == 180:
count = 0
os.system("mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o %s -mf type=jpeg:fps=24 mf://@jpeg_still_list.txt" %"lol")
我在谷歌上搜索了大量的问题,我发现了另一个堆栈溢出的答案,这可能是我需要做的。
https://raspberrypi.stackexchange.com/questions/24460/how-to-write-raspistill-image-to-usb-drive
但我认为他们正在改变的文件已经改变了格式,因为还不太清楚如何做到这一点。
我试过用sudo和superuser来运行它。
谢谢你的帮助!
最佳答案
使用子流程模块,特别是check_call:
with open('jpeg_still_list.txt', 'w') as jpeg_list:
from subprocess import check_call
count = 0
tlcount = 0
while True:
check_call(["raspistill", "-w", "1920", "-h",
"1080", "-q", "80", "-o", "frames{}.jpg".format(count)])
jpeg_list.write("frames{}.jpg".format(count))
time.sleep(60)
count += 1
if count == 180:
count = 0
check_call(["mencoder", "-nosound", "-ovc", "lavc", "-lavcopts",
"vcodec=mpeg4:aspect=16/9:vbitrate=8000000", "-vf",
"scale=1920:1080", "-o", "lol", "-mf",
"type=jpeg:fps=24", "mf://@jpeg_still_list.txt"])
frames/
意思是你想在不存在的框架目录中打开.jpg文件,这样你就得到了错误,删除了/
。关于python - Raspberry Pi相机写入权限,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29728418/