Results 1 to 6 of 6

Thread: Debugging your bots with video recordings

  1. #1
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default Debugging your bots with video recordings

    Do your bots ever run into a problem? Would you like to see the last couple of seconds/minute of gameplay leading up to this problem?

    With this include + ffmpeg, you can add video recording to your script as easily as:
    Simba Code:
    {$include_once recorder.simba}    

    begin
      VideoRecorder.Start(10, 15); //15 second clips @ 10 fps
      TheScript(); //Your bot's code
    end.
    In this example above, whenever the script is terminated you would have a video recording of the last 15 seconds ingame. This is similar in concept to Nvidia's Shadowplay.

    Combine these video recordings with a notification system (e.g. https://villavu.com/forum/showthread.php?t=118374) that lets you know whenever a bot stops and I really think you won't need to manually watch your bots in action anymore. Also, this could be used for getting better debugging information from other people, if you have other people running your scripts.

    See the "Extra Features" section for more information on what else the include can do.

    Installation

    Requirements
    Windows 7+ (other OSs have not been tested)
    Simba 1.2+
    ffmpeg
    recorder.simba

    Simba 1.2+
    Slacky's 1.2 was used to develop this: https://github.com/slackydev/Simba/r...-fixes.x86.exe
    Place into your simba folder if it's not already there (SRL/SRL users likely already have it)

    Olly's 1.3 (in development) currently also seems to work with this recorder. Simba 1.1 & the 1.2 without slacky's fixes don't seem to.

    ffmpeg
    64 bit ffmpeg needs to be available through command prompt, however way you want to do that should be fine. Latest stable version currently is 4.0.1. Older versions might not work.
    One way to do this be to:
    -download the latest 64 build from https://ffmpeg.zeranoe.com/builds/ (Here's the direct download link I used https://ffmpeg.zeranoe.com/builds/wi...n64-static.zip, the 4.0.1 versions work too.)
    -extract and put this into your c: folder as ffmpeg
    -append C:\ffmpeg\bin to your environment variables. (this filepath should be leading to ffmpeg.exe, if it doesn't, you probably messed up somewhere)

    Video demonstration https://streamable.com/z8iku
    Alternative source of video https://cdn.discordapp.com/attachmen...6_17-51-45.mp4

    recorder.simba
    Source: https://github.com/ICannotThinkOfAUs...recorder.simba
    This should be moved to your include folder, e.g. C:\Simba\Includes

    Confirming it works
    You can test if this has all been setup properly.
    1) Enter ffmpeg into command prompt. Did it work or was it not found? See "Video demonstration" for how this looks.

    2) trying to use the recorder. open up simba and try to run the following code
    Simba Code:
    {$include_once recorder.simba}    

    begin
      VideoRecorder.Start(10, 5); //5 second clips @ 10 fps
      wait(6000); //simulates a script running for 6 seconds
    end.
    You should see the following output
    Code:
    Compiled successfully in 530 ms.
    Stopping Recorder and doing a final save.
    Saving 50 Images to temp_videos\temp_images1
    Generating video: temp_videos\output1.mp4
    Successfully executed.


    Extra Features

    Optional
    Saving a video whenever you want

    Would you like to record video of an issue but also have your bot keep on going? You can call .Save() with whatever video name you want.
    Simba Code:
    VideoRecorder.Save('error');
    This would save the last X seconds (whatever clip duration is set to) as a video named error.mp4

    Optional
    Changing the folder that videos are saved in

    By default the videos will be saved in the folder temp_videos, inside your simba directory. You can change this folder to whatever you want, here's two examples.
    Simba Code:
    VideoRecorder.MainFolder := 'test';
    This would now save videos in the folder test, inside your simba directory

    Simba Code:
    const
      SCRIPT_FOLDER = 'C:\Users\USER\Desktop\EpicScript';
      RSN = 'zezima1337';

    begin
      VideoRecorder.MainFolder := SCRIPT_FOLDER + '\' + RSN;
    The path here in SCRIPT_FOLDER would need to already be existing. If this is the case, you'd now be saving videos in the folder zezima1337. Full path C:\Users\USER\Desktop\EpicScript\zezima1337
    USER in this example ofcourse would need to be changed to whatever was correct for your system.

    Recommended
    Recording the desktop's mouse

    Simba Code:
    VideoRecorder.RecordMouse := True;
    Self Explanatory ^

    You can also change the mouse's size and color, e.g like so:
    Simba Code:
    VideoRecorder.MouseColor := 13606815;
    VideoRecorder.MouseSizeX := 2;  
    VideoRecorder.MouseSizeY := 5;
    This will be an odd mouse ^ leaving these as defaults is fine.

    The MouseColor's data type is "TColor". See here for conversions to TColor http://docs.villavu.com/simba/script...onversion.html

    Not recommended
    Saving constantly

    If your script crashes due to something like an access violation, then whatever is set to run on terminate won't be ran. You could 0) Shrug your shoulders and just try to fix the code giving acess violations 1) wrap your code in a try block and lose out on debug messages 2) wrap the code that gets an access violation with something like try BadCode(); except TerminateScript(); so that it terminates more gracefully or 3) save to disk constantly

    I'd recommend #2 or even #0, but if you want to do #3 you could. Like so:
    Simba Code:
    VideoRecorder.SaveConstantly := True;  
    VideoRecorder.KeepCopies := 3; //is 2 by default
    I don't recommend this because it's pretty resource intensive, even if you set .DontProcessVideos to true (which means that only the images are saved to disk, processing into a video via ffmpeg is skipped).



    Caveats

    The images in memory are quite raw and thus they take up quite a bit of space. I would thus recommend playing around with clip duration and clip FPS to determine what works best for you memory usage wise. If somebody else is interested in making higher fps/much longer durations feasible, they should look into adding in image compression.

    I'm probably not going to be adding much more functionality to this project, if at all. If you wish to create an alternative to this program I'd be very happy to link it here and recommend it to others, even if it's simply a small fork of this project.




    Credits:
    @slacky; for both explaining that this was feasible with just a simba include and for helping to make this a reality.
    @Citrus; for mentioning ffmpeg and how it can be used via a simba script
    Other people in the srl discord for discussing this/helping test it/etc

    The brief history behind this project

    When I was botting, I had a taped together frankentstein of a solution with third party software that gave me video recording. It only worked for my use case because I was already willing to dedicate a full VM for each bot. However, it got the job done. I for the most part didn't have to watch my bots in action anymore in order to see mistakes with my script, this was huge! Just press play, come back when the bot stops due to some problem, and I'd see the last ~15 seconds of gameplay leading up the problem. This made bug fixing a breeze for the most part, a ton of time saved.

    Later on, discussing some stuff on the srl discord with citrus/slacky/others I saw that it might be feasible to write a simba include that can record video. While by then I'd decided to stop botting rs, having seen the usefulness of video debugging in my own experiences, I was interested in making this available for other people here. I did a prototype and got it working in a single threaded manner. This was pretty easy and straightford, you're basically just creating and maintaining a bitmap array of what simba sees. Once the array is full, each new bitmap means the oldest one should be removed. To turn this into a video I then just save them all to disk and have ffmpeg process the images into a video. The main problem was being able to do this in a seperate thread. Slacky's help with this problem was critical for turning this prototype into the somewhat useful thing that's available here now. I'm still not 100% sure what exactly is being utilized to get things working this smoothly outside of simba's main thread (without using a plugin).

    If you end up finding this software useful to you, please do give slacky a thank you.
    Last edited by acow; 01-19-2022 at 07:04 PM.

  2. #2
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Wow awesome! I remember the days when I use to have my HyperCam run for hours/day. The crappy part was I would have to scroll back and forth until I found the issue that caused my player go off path, it was such a pain in the butt

  3. #3
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    This is very nice! Thanks a lot for sharing

  4. #4
    Join Date
    May 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    This is awesome!! Thank you.

  5. #5
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

  6. #6
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    I've yet to use this but I'll probably start utilizing it when my in-development scripts get to a point of strenuous testing. This tool can be crucial for developers. As always, nice work Olly.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •