Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Issues saving images when recording window  (Read 454 times)

0 Members and 1 Guest are viewing this topic.

VerchaBercha

  • Newbie
  • *
  • Posts: 1
    • View Profile
Issues saving images when recording window
« on: September 08, 2023, 11:40:29 am »
Hello there.

I am using SFML to visualise and record a simulation for my thesis.

I have written a code for recording the window to use for visual analysis. Leaning on this blogpost https://en.sfml-dev.org/forums/index.php?topic=25254.0 I have the following:

if (recording) {
        sf::Texture texture;
        texture.create(window->getSize().x, window->getSize().y);
        texture.update(*window);
        std::string filename = "recordings/frame_" + counterToString(recordingCounter, 5) +".png";
        texture.copyToImage().saveToFile(filename);
        recordingCounter++;
        if (recordingCounter % 100 == 0) {
          std::cout << "Frames made: " << recordingCounter << std::endl;
        }
      }
 

where recording is a boolean that can be set to True via pressing the R key on the keyboard.

Unfortunately, it doesn't seem to be working, and I get an error message when trying to record:

Code: [Select]
Start recording...
Failed to save image "recordings/frame_00000.png"
Failed to save image "recordings/frame_00001.png"
Failed to save image "recordings/frame_00002.png"
Failed to save image "recordings/frame_00003.png"
Failed to save image "recordings/frame_00004.png"
Failed to save image "recordings/frame_00005.png"
Failed to save image "recordings/frame_00006.png"
Failed to save image "recordings/frame_00007.png"
Failed to save image "recordings/frame_00008.png"
Failed to save image "recordings/frame_00009.png"
Failed to save image "recordings/frame_00010.png"
Recording stopped.

Would somebody have an idea what the issue could be? In case it's necessary, I will attach the whole header file below. I've been sitting on this for a while now but my troubleshooting skills aren't necessary the best :(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10820
    • View Profile
    • development blog
    • Email
Re: Issues saving images when recording window
« Reply #1 on: September 08, 2023, 12:42:58 pm »
Make sure the executable has the correct permission to write to the destination folder. Also make sure the directory recordings exists.

Depending on what you use it for, you might also be interested to just use OBS to record your window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything