Raspberry Pi 相机写入权限

Raspberry Pi camera writing permissions

当写一个 python 脚本在 Pi 上每分钟拍摄一张照片时,它吐出这个错误:

"mmal: main: Error opening output file:"

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 和超级用户运行它。

感谢您的帮助!

使用 subprocess 模块,特别是 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/表示你想打开frames目录下不存在的.jpg文件所以报错,去掉/