saving video on SD card

Hi, so, I’ve tried with the M7 with v2.7.0 and v2.8.0 and gotten no errors with this:

import sensor, image, time, pyb, mjpeg

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

m = mjpeg.Mjpeg('openmv_video.mjpeg')

clock = time.clock()
start = pyb.millis()
with open("time_stamps.txt", "wb") as f:
   while(True):
       clock.tick()
       f.write("%d\n" % pyb.elapsed_millis(start))
       m.add_frame(sensor.snapshot())
       print(clock.fps())
       if pyb.elapsed_millis(start) > 100000:
           print('over')
           #print(time)
           m.close(clock.fps())
           break

It’s the same code as before. However, I was able to reproduce the issue… when the SD card was not mounted straight. Please check that your OpenMV Cam’s SD card is fully inserted and that the pads are coming off of the SD card socket. I have a cam that’s got a damaged SD card socket and I was getting all kinds of errors.

Hmm… I made sure that the SD card was firmly in place, but I still have the same problem. I now also get an EIO5 error after I reconnect the camera… I will try using maybe on older firmware?

Using older firmware didn’t work. Anyway I have noticed it seems like it disconnects at about 5 seconds…

What OS are you using? OpenMV IDE could be unstable on it. Mac?

As I mentioned before, I am using Windows 10.

Sorry, I’ll have the latest release out by Sunday. There are a few IDE protocol fixes in it that may help.

Ibrahim is digging deeper into this problem. He doesn’t quite know what it is yet. But, it will get solved. There’s definitely something funny going on with using the “with open” construct related to MicroPython - we’ve noticed that if you stop the cam using that call it crashes. If you try to open and close a file in the regular way things might improve.

@iScienceLuvr

Hi, can you please test the attached firmware ?
firmware.zip (1.06 MB)

nope, still not working…

I’m pretty sure this fixes it, hmm can you try uploading the fw again ? Note browse for the patched firmware don’t copy it to the IDE’s directories.

no I copied and pasted the file location into the box and pressed run to upload the firmware. I tried it again as you requested and it still doesn’t work.

Okay, Ibrahim’s still working on this.

Hi, I’m attaching a new image, can you give it a try and let me know if it fixes the issue ? Note I changed the fw version to 2.9.1 to avoid any confusion. Also I’d format the SD first.
firmware.zip (1.06 MB)

ok it looks like it works for like 10 sec but more than that it won’t work…

This firmware works for me… I don’t get any bugs with it and I can record for 100 seconds.

What error are you getting?

it just stops and camera disconnects, like previously…

Can you try this out:

It sounds like you may just have an IDE timeout issue and it’s disconnecting because the camera didn’t respond to a command in time. If the light keeps flashing then the camera is working fine and it’s just the IDE disconnecting.

import sensor, image, time, pyb, mjpeg

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
led0 = pyb.LED(1)
led1 = pyb.LED(2)

m = mjpeg.Mjpeg('openmv_video.mjpeg')

clock = time.clock()
start = pyb.millis()
led0.on()
with open("time_stamps.txt", "wb") as f:
   while(True):
       clock.tick()
       led1.toggle()
       f.write("%d\n" % pyb.elapsed_millis(start))
       m.add_frame(sensor.snapshot())
       print(clock.fps())
       if pyb.elapsed_millis(start) > 100000:
           print('over')
           #print(time)
           m.close(clock.fps())
           break
led0.off()

Hi again, I found two more bugs in SD and fixed them. This image should be good.

Attached.
firmware.zip (1.06 MB)

Hi,

I am using the code in this discussion but am unable to get images or videos (jpg or mjpeg) to save. The file name will only show up on my computer once I have disconnected the device and reconnected it but will have zero bytes in it.

Any help would be greatly appreciated!

I am using a mac with the M7.

Are you still having this problem ? You should use the IDE to reset the camera instead of disconnecting it to give it a chance to unmount the filesystem.