为什么 每次录制视频的时间都会少呢?哪位大佬帮忙看看 设置的是录制15个小时 出来每段视频只有20分钟 共30段视频
-
import sensor, image, time, mjpeg, pyb from pyb import RTC RED_LED_PIN = 1 BLUE_LED_PIN = 3 Time = [2023, 6, 4, 7, 0, 1, 0, 0] Act_Time = [4, 7 , 0 , 0] Set_Time = [0, 15, 0, 0] Days = 2 X = 30 Fps = 44 sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.set_windowing((240, 240)) sensor.skip_frames(time = 2000) clock = time.clock() rtc = RTC() rtc.datetime(Time) m = [0] for B in range(X * Days): m.append(mjpeg.Mjpeg(str(B + 1) + ".mjpeg")) for Day_count in range(Days): pyb.LED(RED_LED_PIN).on() sensor.skip_frames(time = 2000) print("You're on camera!") while((rtc.datetime()[2] * 86400 + rtc.datetime()[4] * 3600 + rtc.datetime()[5] * 60 + rtc.datetime()[6]) < ((Act_Time[0] + Day_count) * 86400 + Act_Time[1] * 3600 + Act_Time[2] * 60 + Act_Time[3])): print("**********Wait**********" + '\n') print(str(rtc.datetime()[4]) + 'h', str(rtc.datetime()[5]) + 'm', str(rtc.datetime()[6]) + 's') print("wait" + '\n') pyb.LED(RED_LED_PIN).off() pyb.LED(BLUE_LED_PIN).on() for A in range(X): for i in range(Fps * ((Set_Time[0] * 86400 + Set_Time[1] * 3600 + Set_Time[2] * 60 + Set_Time[3]) / X)): print("**********ACT**********" + '\n') print(str(rtc.datetime()[4]) + 'h', str(rtc.datetime()[5]) + 'm', str(rtc.datetime()[6]) + 's') clock.tick() m[A + 1 + X * Day_count].add_frame(sensor.snapshot()) print(str(clock.fps()) + 'fps' +'\n', "Num = " + str(i)) print(A + 1 + X * Day_count, '\n' ) m[A + 1 + X * Day_count].close(clock.fps()) pyb.LED(BLUE_LED_PIN).off() print("Done! Reset the camera to see the saved recording.", '\n')
-
你这个rtc我看着不知道什么意思,如果要录制15小时, 可以用millis()判断.
import sensor, image, time, mjpeg, pyb RED_LED_PIN = 1 BLUE_LED_PIN = 3 sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others) sensor.skip_frames(time = 2000) # Let new settings take affect. clock = time.clock() # Tracks FPS. pyb.LED(RED_LED_PIN).on() sensor.skip_frames(time = 2000) # Give the user time to get ready. pyb.LED(RED_LED_PIN).off() pyb.LED(BLUE_LED_PIN).on() m = mjpeg.Mjpeg("example.mjpeg") print("You're on camera!") start = pyb.millis() while (pyb.millis()-start) < 15*60*60*1000: clock.tick() m.add_frame(sensor.snapshot()) print(clock.fps()) m.close(clock.fps()) pyb.LED(BLUE_LED_PIN).off() print("Done! Reset the camera to see the saved recording.")