acow
07-31-2018, 06:31 AM
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:
{$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.
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/releases/download/Simba-1.2.0-rc6_fixes/Simba1206-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/win64/static/ffmpeg-20180726-bce4da8-win64-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/attachments/233405586698403841/472161464728289280/2018-07-26_17-51-45.mp4
recorder.simba
Source: https://github.com/ICannotThinkOfAUsername/SimbaRecorder/releases/download/v1.0/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
{$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
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.
Optional
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.
VideoRecorder.Save('error');
This would save the last X seconds (whatever clip duration is set to) as a video named error.mp4
Optional
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.
VideoRecorder.MainFolder := 'test';
This would now save videos in the folder test, inside your simba directory
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
VideoRecorder.RecordMouse := True;
Self Explanatory ^
You can also change the mouse's size and color, e.g like so:
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/scriptref/color%20conversion.html
Not recommended
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:
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).
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.
https://github.com/ollydev/SimbaRecorder
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
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.
With this include + ffmpeg, you can add video recording to your script as easily as:
{$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.
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/releases/download/Simba-1.2.0-rc6_fixes/Simba1206-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/win64/static/ffmpeg-20180726-bce4da8-win64-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/attachments/233405586698403841/472161464728289280/2018-07-26_17-51-45.mp4
recorder.simba
Source: https://github.com/ICannotThinkOfAUsername/SimbaRecorder/releases/download/v1.0/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
{$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
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.
Optional
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.
VideoRecorder.Save('error');
This would save the last X seconds (whatever clip duration is set to) as a video named error.mp4
Optional
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.
VideoRecorder.MainFolder := 'test';
This would now save videos in the folder test, inside your simba directory
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
VideoRecorder.RecordMouse := True;
Self Explanatory ^
You can also change the mouse's size and color, e.g like so:
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/scriptref/color%20conversion.html
Not recommended
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:
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).
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.
https://github.com/ollydev/SimbaRecorder
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
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.