Shanjor1256 / ESP32CamPhotoBurst

0 stars 0 forks source link

jpeg vs mjpeg #1

Open jameszah opened 1 year ago

jameszah commented 1 year ago

Can't quite remember how the mjpeg works - I thought vlc used to play it, but I just see the first jpeg now???

Use the "true" here to prevent the big led from flashing

  if (!SD_MMC.begin("", true)) {
    Serial.println("Card Mount Failed");
    return;
  }

Use this to turn on the led

  //Turn on on-board LED
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);

You can break up the big jpeg for uxga quality 10, with something like this:

#define fbs 8
uint8_t framebuffer_static[fbs * 1024];
  while (timeElapsed - timeStart < 3500) { //take pictures for 3.5 seconds

    SDpath = "/incident" + String(incidentNumber) + "/" + String(pictures) + ".jpeg";
    file = SD_MMC.open(SDpath.c_str(), FILE_WRITE);

    fb = esp_camera_fb_get();

    int remaining = fb->len;
    uint8_t* block_start = fb->buf;
    int write_size = 0;
    Serial.printf("pic %5d, size %6d, delta %4d, time %6d\n", pictures, remaining, millis() - prev, millis());
    prev = millis();

    while (remaining > 0) {
      if (remaining > fbs * 1024) {
        write_size = fbs * 1024;
      } else {
        write_size = remaining;
      }

      memcpy(framebuffer_static, block_start,  write_size);
      file.write(framebuffer_static, write_size);
      remaining = remaining - write_size;
      block_start = block_start + write_size;
    }

    esp_camera_fb_return(fb);
    file.close();
Shanjor1256 commented 1 year ago

Thank you!!! It works well. This has solved a lot of my problems, and I have no problems with speed now.