Hello
I’m having an issue when recording videos with compressed images:
When using an ImageIO object to record raw images (i.e. result from sensor.snapshot()
) everything works fine, and I can play and convert the recorded video file afterwards.
But when recording compressed images, the recording itself goes on without any error messaged, but when I try to open or convert the file, I always get a “File is corrupt!” error from the IDE.
I don’t think this is an issue with the SD card, as the behaviour is consistent and the raw recording, with its higher data rate, is working flawlessly.
Also this used to work a while back ago (Sep/Oct perhaps), but I haven’t tried to get the exact firmware version where this stopped working for me.
Am I missing something here?
My actual script is a bit more complex and recording gray scale VGA pictures, but I can reproduce the very same behaviour with a slightly modified imageio_write.py
example script (GRAYSCALE to suit my global shutter sensor, and reduced recording time):
import sensor, image, pyb, time
record_time = 2000 # 10 seconds in milliseconds
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
stream = image.ImageIO("/stream.bin", "w")
# Red LED on means we are capturing frames.
pyb.LED(1).on()
start = pyb.millis()
while pyb.elapsed_millis(start) < record_time:
clock.tick()
img = sensor.snapshot()
# Modify the image if you feel like here...
stream.write(img)
print(clock.fps())
stream.close()
# Blue LED on means we are done.
pyb.LED(1).off()
pyb.LED(3).on()
The above works fine. If I replace the line stream.write(img)
with stream.write(img.compress())
the recorded file gets corrupted.
HW: H7 or H7+
Firmware: 4.2.0 (but also happening with 4.1.4., possibly older ones as well, not checked)
IDE: 2.8.1
OS: Win 10
Thanks
Felix