[Tool] TSR File Analyzer and Replayer
Moderator: Forum Moderators
Re: [Tool] TSR File Analyzer and Replayer
O.K., power79, this is what I would like you to make...
Let's say I have one folder (maybe sub-folders too) with tons of videos. I would like to have a tool that I can type track/player/car names in and wait it to extract me the fastest lap .tsr video based on that.
It would be even better if such a tool could be web-based and exist on TS's website. It could be connected to FTP "video" auto-servers' folders and let you get any video you want.
Let's say I have one folder (maybe sub-folders too) with tons of videos. I would like to have a tool that I can type track/player/car names in and wait it to extract me the fastest lap .tsr video based on that.
It would be even better if such a tool could be web-based and exist on TS's website. It could be connected to FTP "video" auto-servers' folders and let you get any video you want.
Re: [Tool] TSR File Analyzer and Replayer
FLFINDER.zipWhiplash wrote:O.K., power79, this is what I would like you to make...
Let's say I have one folder (maybe sub-folders too) with tons of videos. I would like to have a tool that I can type track/player/car names in and wait it to extract me the fastest lap .tsr video based on that.
You can probably expect to find bugs. Also prepare it to be slow. It skips other files pretty fast but if search criteria is met in the recording then processing one file takes as long as loading it to TSR_Reader.
Sorry, but I don't do web shit.It would be even better if such a tool could be web-based and exist on TS's website. It could be connected to FTP "video" auto-servers' folders and let you get any video you want.
Re: [Tool] TSR File Analyzer and Replayer
Oh, it's quite fast actually while it searches the fastest lap.
But the option "Create TSR" doesn't work. Whenever I clicked on it - nothing happened. And it should be named "Extract TSR", or "Get fastest lap TSR" - I think. 
Also, it would be great if you somehow could combine these two tools (tsr_reader and fl_finder) now to one.


Also, it would be great if you somehow could combine these two tools (tsr_reader and fl_finder) now to one.

Re: [Tool] TSR File Analyzer and Replayer
It being fast could be a sign that maybe it didn't find the lap. Did lap appear in the drop down list after search was over? Make sure you wrote search criteria correctly. If it finds a lap and you click the create button - file should be created in same folder with the program. It doesn't give any message when it finishes but it shouldn't take long.Whiplash wrote:Oh, it's quite fast actually while it searches the fastest lap.But the option "Create TSR" doesn't work. Whenever I clicked on it - nothing happened. And it should be named "Extract TSR", or "Get fastest lap TSR" - I think.
Also, it would be great if you somehow could combine these two tools (tsr_reader and fl_finder) now to one.
Re: [Tool] TSR File Analyzer and Replayer
Oh!power79 wrote:...file should be created in same folder with the program. It doesn't give any message when it finishes but it shouldn't take long.

Maybe you could let us define output folder.

Re: [Tool] TSR File Analyzer and Replayer
O.K., I got some buggy video results. Here is the video that I had, and fl video that I got by the tool.
Anyway, it would be nice if the tool could give some info when there is "NO TIMES". It should say why there is no times:
- no such player
- no such track
- no such car
Then I would know what I mistyped.
Also, the tool should remember the folder that I set to be analyzed. Now I always have to set it all up again after the tool is restarted.
Anyway, it would be nice if the tool could give some info when there is "NO TIMES". It should say why there is no times:
- no such player
- no such track
- no such car
Then I would know what I mistyped.
Also, the tool should remember the folder that I set to be analyzed. Now I always have to set it all up again after the tool is restarted.
Re: [Tool] TSR File Analyzer and Replayer
I can't watch the video as I don't have that track, but anyway that problem probably exists at TSR_Reader too, you can try to extract that lap from there and see if it works. If it doesn't then it's the same problem that I haven't located from my code. So your's is lap 2/3, if you extract laps 1-2 together using TSR_Reader then that lap might work ok. If not, then it's probably some new bug.Whiplash wrote:O.K., I got some buggy video results. Here is the video that I had, and fl video that I got by the tool.
Anyway, it would be nice if the tool could give some info when there is "NO TIMES". It should say why there is no times:
- no such player
- no such track
- no such car
Then I would know what I mistyped.
Also, the tool should remember the folder that I set to be analyzed. Now I always have to set it all up again after the tool is restarted.
For NO TIMES message I see what I can do. But there could be sometimes be many reasons. Some track doesn't have wanted car, some doesn't have the player, or the player with the car, or neither car or player etc. So it could be difficult to point the exact reason.
For the folder issue, I guess I have to save the last used folder to a file and load it when program starts.
Re: [Tool] TSR File Analyzer and Replayer
When extracting fastest lap with tsr_reader, same problem happens. But, yeah, when doing 1-2, it's good. And, is it really that hard to download the track?
Anyway, it would be also better if you could add extra 2 secs from both sides of video. I mean, video should starts 2 secs before a car touched the start line, and 2 secs after it touched the finish line.
Anyway, it would be also better if you could add extra 2 secs from both sides of video. I mean, video should starts 2 secs before a car touched the start line, and 2 secs after it touched the finish line.
Re: [Tool] TSR File Analyzer and Replayer
I wasn't that interested to see the video as I guessed already what was the problem.Whiplash wrote:And, is it really that hard to download the track?

Now it should work like that.Anyway, it would be also better if you could add extra 2 secs from both sides of video. I mean, video should starts 2 secs before a car touched the start line, and 2 secs after it touched the finish line.
I wasn't able to fix the lap bug and I didn't come up with any good solution for NO TIMES definition, but now program should remember previous directories and you can also set up output directory. FLFINDER.zip
Re: [Tool] TSR File Analyzer and Replayer
Good! But seems like output directory button is bugged. Or it's supposed to look like that? I guess you planned it to work like that upper directory picking for the video folder - which would be better of course. 

Re: [Tool] TSR File Analyzer and Replayer
Oh shit, I forgot the button. Well, fixed now. Uhhh, Im getting tired of this program already.
Re: [Tool] TSR File Analyzer and Replayer
Well, nobody is forcing you to upload updates every 15 min. If you got it all working in next week or two, it's great. This tool is already very useful.power79 wrote:Oh shit, I forgot the button. Well, fixed now. Uhhh, Im getting tired of this program already.
Re: [Tool] TSR File Analyzer and Replayer
I think I fixed the lap bug problem. I updated also TSR_Reader for that.
Re: [Tool] TSR File Analyzer and Replayer
Yes, you did. Brilliant!power79 wrote:I think I fixed the lap bug problem.
Re: [Tool] TSR File Analyzer and Replayer
Blah. Now I tried to exctract my and T's AntiSlider rec from one track folder. After I press Search FL, I get pop-up saying: "Wrong Driver id".
When I press OK on it, I get another pop-up saying:
"Access violation at address 0046CAB1 in module 'FLFINDER.exe'. Write of address 000000 10."
Too bad cause I would probably use this tool a lot for videos of this new Hot Lap server.
THIS is the folder that I was searching from.
When I press OK on it, I get another pop-up saying:
"Access violation at address 0046CAB1 in module 'FLFINDER.exe'. Write of address 000000 10."
Too bad cause I would probably use this tool a lot for videos of this new Hot Lap server.
THIS is the folder that I was searching from.
Re: [Tool] TSR File Analyzer and Replayer
Ok, I hope it works now if you download the updated version(FLFINDER & TSR_Reader). There might be problems if you try to extract first lap of the race but otherwise my quick fix should (fingers crossed) work.
Re: [Tool] TSR File Analyzer and Replayer
Yep, worked.
Thanks!

Re: [Tool] TSR File Analyzer and Replayer
Ey, power79, seems like T's tool for comparing videos is broken. Maybe you could make your own tool for that too?
Basically, we should just put 2 videos in a folder "video1" and "video2" and the tool should make an output video that will merge them both together.
Basically, we should just put 2 videos in a folder "video1" and "video2" and the tool should make an output video that will merge them both together.
- Mike Nike
- Community User Level: 5
- Posts: 1132
- Joined: Sat Oct 30, 2004 3:11 pm
- Location: Germany
- Contact:
Re: [Tool] TSR File Analyzer and Replayer
Finally good "TSR Extractor" news, i need for big races for my 3D Replayer...
After power79 has sent me some code, me reading and understanding it, testing a lot and making good progress in some hours...my tsr extractor tool still failed. (lol etc)
BUT
...that made me try harder to hack the hex$ out of this binary spaghetti!
So, i added the line "unknown bytes: 33 bytes" into the format and now i can continue and read message types in a loop, which works nicely so far. It was the +-5th tsr binary file i tried. Circly client race with 20 players.
The magical 33 bytes:
int(byte33[0..32]) = (0 0 1 4, 0 0 0 0, 87 0 0 0, then 21 times a "0" again)
the byte33 first 4 bytes are 0 0 1 4, so: int = 260 -> could be the TS version 2.6.0
87 is a "W", whatever that could mean.
After power79 has sent me some code, me reading and understanding it, testing a lot and making good progress in some hours...my tsr extractor tool still failed. (lol etc)
BUT

So, i added the line "unknown bytes: 33 bytes" into the format and now i can continue and read message types in a loop, which works nicely so far. It was the +-5th tsr binary file i tried. Circly client race with 20 players.
Code: Select all
unknown bytes: 33 bytes
int starting_grid: `player_count` bytes
int car_data_length: 4 bytes
{
int player_count: 4 bytes
car_data = {
int car_hash: 8 bytes
int car_name_length: 4 bytes
int car_name: `car_name_length` bytes
} × `player_count`
}
int(byte33[0..32]) = (0 0 1 4, 0 0 0 0, 87 0 0 0, then 21 times a "0" again)
the byte33 first 4 bytes are 0 0 1 4, so: int = 260 -> could be the TS version 2.6.0
87 is a "W", whatever that could mean.
Re: [Tool] TSR File Analyzer and Replayer
I have a feeling I ran into this same thing a while ago, but I can't find any proof from my code for it. Maybe it's something in new version. Have you tested tsr files from old version if they have same "unknown bytes" thing?Mike Nike wrote: So, i added the line "unknown bytes: 33 bytes" into the format and now i can continue and read message types in a loop, which works nicely so far. It was the +-5th tsr binary file i tried. Circly client race with 20 players.
edit: Ok i found it from my video merge code. Weird that I haven't changed that to any of my other tools.
- Mike Nike
- Community User Level: 5
- Posts: 1132
- Joined: Sat Oct 30, 2004 3:11 pm
- Location: Germany
- Contact:
Re: [Tool] TSR File Analyzer and Replayer
Maybe, i did. But i doubt it. I will most likely try to test older videos and then adjust the tool (and post results here), if i don't die trying to hack another plate of binary spaghetti.
By the way, just tested your FLFinder, awesome work! Reminds me to the LVP query page. And some tools i made for .rec import.
Edit:
my coding language Blitz3D does not support ReadFloatEndian, so i wrote it myself.
power79s format for msg type 9 is not really matching for my tsr files, so far.
But for 1 player local i hacked it. Multiplayer wont be hard.
Client tsr will be tough, since i have to write an ReadFloatEndian for 16bit (2 bytes), if i understood power's code correctly. Let's see how nervy that's gonna be..
Edit2:
It wasn't too hard.
But unfortunately in +-20 different ways to interpretate 2byte data, no startposition matches yet. I'll try to see if startpos[car]-startpos[car-1] differences are somehow visible and therefore some other formula might work..
Edit3:
ok, seems power79 left out an essential thingy in storing the locations. Or he didnt tell me if there is a special function behind "StrToInt(hex)".
So the solution was: 2byte storing seems to be integer (1byte) values. And starting from byte 25 (angle from 23) and not x/y/a/.. from byte 1/3/5...; also there are some unknown bytes in the end as well.
xPos = int(byte1)*16+int(byte2)/16
yPos = int(byte3)*16+int(byte4)/16
angle = still trying to figure out...
By the way, just tested your FLFinder, awesome work! Reminds me to the LVP query page. And some tools i made for .rec import.
Edit:
my coding language Blitz3D does not support ReadFloatEndian, so i wrote it myself.
power79s format for msg type 9 is not really matching for my tsr files, so far.
But for 1 player local i hacked it. Multiplayer wont be hard.
Client tsr will be tough, since i have to write an ReadFloatEndian for 16bit (2 bytes), if i understood power's code correctly. Let's see how nervy that's gonna be..
Edit2:
It wasn't too hard.
But unfortunately in +-20 different ways to interpretate 2byte data, no startposition matches yet. I'll try to see if startpos[car]-startpos[car-1] differences are somehow visible and therefore some other formula might work..
Edit3:
ok, seems power79 left out an essential thingy in storing the locations. Or he didnt tell me if there is a special function behind "StrToInt(hex)".
So the solution was: 2byte storing seems to be integer (1byte) values. And starting from byte 25 (angle from 23) and not x/y/a/.. from byte 1/3/5...; also there are some unknown bytes in the end as well.
xPos = int(byte1)*16+int(byte2)/16
yPos = int(byte3)*16+int(byte4)/16
angle = still trying to figure out...
Re: [Tool] TSR File Analyzer and Replayer
All the information shown in code should be found in the positions where it is indicated, but it's true that my code jumps over lots of stuff I don't need. So if you try to interpret every byte of the messages then my code is not complete. At least server video code is matching my format when I checked it.Mike Nike wrote: power79s format for msg type 9 is not really matching for my tsr files, so far.
But for 1 player local i hacked it. Multiplayer wont be hard.
Those values are read with special TDemo structure. Check it out. I found that from the net as I couldn't figure out how to convert those hex values to decimals specially the float numbers.ok, seems power79 left out an essential thingy in storing the locations. Or he didnt tell me if there is a special function behind "StrToInt(hex)".
So the solution was: 2byte storing seems to be integer (1byte) values. And starting from byte 25 (angle from 23) and not x/y/a/.. from byte 1/3/5...; also there are some unknown bytes in the end as well.
xPos = int(byte1)*16+int(byte2)/16
yPos = int(byte3)*16+int(byte4)/16
angle = still trying to figure out...
And the "case fc of" structure doesn't indicate byte positions. You calculate position with the (bc = ...) formula.
Here is example of server video(4 bytes/value):
So Server formula for finding starting position in message for players X-coordinate (and other values after that) is 32*player+20 (player = 0-19)
And remember: Bytes start from position 0 in my code, because arrays start from 0.
Code: Select all
00 00 00 09 <- id (not part of message)
00 13 cf 04 <- racetime (message bytes 0-3)
00 00 00 00 (bytes 4-7)
ff ff ff ff (bytes 8-11)
00 00 00 00 (bytes 12-15)
00 01 00 14 <- $14 = 20 = player count (byte 19)
43 ab 09 00 <- X-coordinate of player 0 (starts at byte 20 = 32*(player=0)+20)
45 55 11 60 <- Y
40 8e e7 10 <- Angle1
43 22 10 00 <- Speed
40 8e a1 f2 <- Angle2
00 00 00 00
00 00 00 00
06 00 00 00
44 b5 ff c0 <- X-coordinate of player 1 (starts at byte 52 = 32*(player=1)+20)
44 fe a3 80
40 3a 2d 1a
43 30 80 00
40 39 d6 b6
00 00 00 00
00 00 00 00
06 00 00 00
45 49 a3 60 <- X-coordinate of player 2 (starts at byte 84 = 32*(player=2)+20)
.
.
.
For (client) angle value :angle = still trying to figure out...
HexToInt(angle value)/65535*DegToRad(360); edit: // 65535 = $ffff, DegToRad(360) = 2*Pi
edit:
Yeah, I haven't dealt with client videos (2 bytes) for a while so I forgot those transformations. So for X,Y and Speed client values you take then Int value of those 2 bytes and divide it with 16.