JakubKoralewski/cursor-recorder

why isn't the first timecode of the textfile 0 ?

Opened this issue · 13 comments

problem : the first line in the text file gives a timecode that seems pretty arbitrary such as
23.33333194255829 1182 -428

I think I figured out but I am not able to fix it.
To me it seems that the timecode of the saved text file is the elapsed time in OBS instead of being the elapsed time of the recording.

This issue occurs when the checkbox "Use's video FPS to capture cursor" is ticked in cursor-recorder UI in OBS. If the checkbox in not ticked, the first timecode will be 0.

Thanks for providing when the issue appears, that helps.

The issue needs to lie in cursor_recorder since that function is called instead of script_tick when use video fps is unchecked:

def cursor_recorder():

The code waits for 1/custom_fps value before taking first cursor measurement:

time.sleep(refresh_rate)

But given that the time provided by you (23seconds) then it's impossible to set a custom_fps value necessary for this to happen (~0.04fps):

custom_fps = obs.obs_properties_add_int_slider(props, "custom_fps", "Custom FPS", 1, 200, 1)

What is the value of "Custom FPS" you have set?

It's also possible that starting a separate thread for saving the cursor positions when in custom fps mode is causing a lag but it shouldn't be 23 seconds:

threading.Thread(target=cursor_recorder).start()

Let me know if you can share any more information that could help debug this. Did you try restarting OBS? 😅

I can see also a possibility where:

  1. you start a recording
  2. prev_x and prev_y are no longer -1, but some real values
    prev_x = -1
    prev_y = -1
  3. the recording is stopped without moving the mouse (keyboard shortcuts?)
  4. new recording is started without moving the mouse
  5. x == prev_x and y == prev_y so the cursor position is not saved
    if prev_x == x and prev_y == y:
    skipping = True
    if should_exit():
    break
    continue
  6. you move the cursor after 23s in the recording

but that would be highly unusual 😅

But given that the time provided by you (23seconds) then it's impossible to set a custom_fps value necessary for this to happen (~0.04fps):

custom_fps = obs.obs_properties_add_int_slider(props, "custom_fps", "Custom FPS", 1, 200, 1)

I don't understand what you are telling me here.

What is the value of "Custom FPS" you have set?

30 FPS, also tried with 25 FPS but results in same problem;

It's also possible that starting a separate thread for saving the cursor positions when in custom fps mode is causing a lag but it shouldn't be 23 seconds:

threading.Thread(target=cursor_recorder).start()

I ran different tests without closing OBS, the timecodes were increasing from the first text file to the last one. At the end It showed a timecode of 421 in the first line, that's how I deduced that the script writes logs of the tim elapsed in OBS

Let me know if you can share any more information that could help debug this. Did you try restarting OBS? 😅

seriously ? yes

thank you for your patience, I was wrong about the possible cause, your intuition was correct. I think I have found the problem. It's as you said, the starting time was never reset. Please try this script: (haven't tested)

https://github.com/JakubKoralewski/cursor-recorder/blob/%2312/scripts/cursor_recorder_for_obs.py

Let me know if works / any problems

I will try that. I also suggest that when the "use video fps to capture cursor" is ticked, the "custom FPS" slider gets greyed out to make the difference between the 2 options clear for the user.

Also in your installation tutorial, recommend the windows users to start OBS with administrator privileges by default by creating a shortcut of OBS then and ticking "always launch as administrator" in the shortcut settings.

Let me know if works / any problems

that update you did broke it, i no more see generated text files

works for me, it may only get saved after recording is stopped now, made some changes but probably just some stuff was broken on mac

ok I see these text files again and works fine with the first recording but from the second recording the first lines are

16.233332365751266 1667 798
16.26666569709778 1664 798
16.29999902844429 1633 798
16.333332359790802 1577 798
16.366665691137314 1475 800
16.399999022483826 1410 808
16.433332353830338 1341 823
16.46666568517685 1283 835
16.49999901652336 1221 837
16.533332347869873 1180 837
16.566665679216385 1145 837
16.599999010562897 1079 832
16.63333234190941 1036 817
16.66666567325592 1025 809

I tried the latest version of the script (see link above)

  1. Use video FPS checked: 0.033 first and then when starting next recording also 0.033
  2. Use video FPS unchecked (30fps): 0.034 first, 0.038 second

Can you try again? Maybe you forgot to reload the script?