It is currently Thu May 23, 2019 3:01 pm


[Tool] TSR File Analyzer and Replayer

Maybe you're a programmer and you've made some cool tool for TS. Share it here with all the other players.

Moderator: Forum Moderators

  • Author
  • Message
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostSun Nov 02, 2014 7:12 am

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.
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 2:19 am

Whiplash 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.

FLFINDER.zip
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.

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.

Sorry, but I don't do web shit.
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 7:15 am

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. :wink:
Also, it would be great if you somehow could combine these two tools (tsr_reader and fl_finder) now to one. :wink:
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 7:36 am

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. :wink:
Also, it would be great if you somehow could combine these two tools (tsr_reader and fl_finder) now to one. :wink:

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.
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 8:46 am

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.

Oh! :oops: What a amateur. Well, I expected to see the loading and I didn't check the program folder. It's fast as hell. Nice work man!
Maybe you could let us define output folder. :wink:
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 9:15 am

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.
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 10:29 am

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.

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.

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.
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 11:05 am

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.
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 12:55 pm

Whiplash wrote:And, is it really that hard to download the track?

I wasn't that interested to see the video as I guessed already what was the problem. :wink:

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.

Now it should work like that.

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
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 1:24 pm

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. :wink:
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 1:40 pm

Oh shit, I forgot the button. Well, fixed now. Uhhh, Im getting tired of this program already.
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostMon Nov 03, 2014 2:01 pm

power79 wrote:Oh shit, I forgot the button. Well, fixed now. Uhhh, Im getting tired of this program already.

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.
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostTue Nov 04, 2014 2:41 pm

I think I fixed the lap bug problem. I updated also TSR_Reader for that.
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostTue Nov 04, 2014 2:58 pm

power79 wrote:I think I fixed the lap bug problem.

Yes, you did. Brilliant!
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostSat Dec 06, 2014 8:38 pm

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.
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostSun Dec 07, 2014 3:57 am

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.
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostSun Dec 07, 2014 6:59 am

Yep, worked. :wink: Thanks!
Offline
User avatar

Whiplash

Community User Level: 5

Community User Level: 5

  • Posts: 2309
  • Joined: Sun Apr 19, 2009 11:57 am
  • Location: Bosnia

Re: [Tool] TSR File Analyzer and Replayer

PostWed Dec 10, 2014 8:10 pm

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.
Offline
User avatar

Mike Nike

Community User Level: 5

Community User Level: 5

  • Posts: 1130
  • Joined: Sat Oct 30, 2004 10:11 am
  • Location: Germany

Re: [Tool] TSR File Analyzer and Replayer

PostWed Apr 19, 2017 4:08 am

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 :D ...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.

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`
}


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.
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostWed Apr 19, 2017 5:03 am

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.

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?

edit: Ok i found it from my video merge code. Weird that I haven't changed that to any of my other tools.
Offline
User avatar

Mike Nike

Community User Level: 5

Community User Level: 5

  • Posts: 1130
  • Joined: Sat Oct 30, 2004 10:11 am
  • Location: Germany

Re: [Tool] TSR File Analyzer and Replayer

PostWed Apr 19, 2017 5:19 am

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...
Offline

power79

Community User Level: 3

Community User Level: 3

  • Posts: 463
  • Joined: Sun Dec 16, 2012 6:10 pm
  • Location: Finland

Re: [Tool] TSR File Analyzer and Replayer

PostWed Apr 19, 2017 12:52 pm

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.

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.

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...

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.
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)
.
.
.


angle = still trying to figure out...

For (client) angle value :
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.
Previous

Return to Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron