Weird issue with downloading files from a GoPro.

edited March 2017 in Library Questions

I have a Sketch that is intended to download the files from a WiFi attached GoPro. The GoPro runs a Web server so the only way to download the files is to scrape the filenames from the webpage and download them which is mostly working. In this case though the GoPro currently has files from "GOPR00302.JPG" to "GOPR0509.JPG" on it's SD card. The sketch below works fine until it gets to one particular file "GOPR0335.JPG" and then it just locks up, no errors or anything if I artificially create "GOPR0335.JPG" in the download directory then as designed the code skips it as already downloaded and downloads the rest of the files with no issues. The file doesn't appear to be obviously corrupt as I can view and download it from a web browser but even if it was corrupt without any sort of trappable error I can't skip it. If I force the sketch to always download a specific file (E.G. GOPR0334 or 0336) by inserting the line "LastFIle="GOPR0334"; etc. before the line "img = loadImage(URL_BASE +LastFile+".JPG");" then it download those images fine and if I set it to LastFIle="GOPR0335" it locks up so it only seems to have an issue with that one particular file with no obvious way to trap the problem.


Client c;
String URL_BASE = "http://" + "";  // Where the Gopro stores it's images
String LastFile=".";  
int LastSavedFile=0;
String NewFile=".";
PImage GoProImage;

void draw() {
  background(220, 220, 255);

//Scan Gopro and return last file saved as "LastFile"
String ScanGoProDisk(String URL)
  String lines[] = loadStrings(URL);

  for (int i = 0; i < lines.length; i++) 
    String[] m=match(lines[i], "href=\"(.*?).JPG\">GO"); 
    String[] mn=match(lines[i], "href=\"GOPR(.*?).JPG\">GO"); 
    if (m != null)

      if (int(mn[1])>LastSavedFile)
        PImage img = loadImage(LastFile+"B.JPG");
        if (img == null) // Not downloaded yet
          img = loadImage(URL_BASE +LastFile+".JPG");
          if (img != null)
  "B.JPG"); // Cache of the file
            LastSavedFile=int(mn[1]); //store last downloaded image to speed up scanning
          } else
            println("Unable to load the image from " + URL_BASE + LastFile+".JPG");

  return LastFile;


  • .... I don't know how this ended up in "Library questions" When I'm 99.9% certain I posted it in "Programming questions" ?!?!?! And there appears to be no way of deleting it and moving it.

  • LastFIle="GOPR0035" or LastFIle="GOPR0335" ?

    edited March 2017

    Sorry obvious typo yes 0335

  • No need to worry about the section. Just mention it and one of the moderators will read your post and they will move the post for you.


  • Draw executes 60 times a second. Having heavy processes in draw is going to kill your sketch.

  • Draw executes 60 times a second.

    If that was the problem then I'd expect it to fail more randomly and with more files, not consistently just one file. I can try dropping the framerate but I'm not convinced it will make any difference TBH. I'll also try another GoPro with the same number/more files on it and also copy the files from the first GoPro across to the PC and modify the sketch to see if it has the same trouble reading them from the PC as the GoPro.

  • it's not THE current problem, no. but it'll be A problem when you've got the current glitches out.

  • TBH there's a few things I don't like about it and will change but really need to get this issue sorted first. I particularly don't like loading the image as a method to detect whether it already exists, it's slow and I'm concerned it may lead to memory/memory leak issues over time but don't want to get too sidetracked from the main problem.

Sign In or Register to comment.