Skip to content

Commit

Permalink
improved input recording
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmagne committed Jun 19, 2024
1 parent d6aafec commit 290ebfd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
!LICENSE
!README.md
!Makefile
!/align-rec
!/irec

# Exclude lock files
*.lock.json
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion align-rec/aligner.py → irec/aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def align(
def viz(
path_video: str,
path_inputs: str,
offset: int = 0,
):
"""
Run the video and display the inputs at the bottom of the screen
Expand Down Expand Up @@ -103,6 +104,9 @@ def get_frame(cap, frame_number):
frame_data = df.row(current_frame, named=True)
if frame is None:
break
if current_frame < offset:
current_frame = offset
continue

frame = cv2.resize(frame, (800, 600))
new_width = frame.shape[1] + 200
Expand Down Expand Up @@ -151,7 +155,7 @@ def cli_align(args):


def cli_viz(args):
viz(args.video, args.inputs)
viz(args.video, args.inputs, args.o)


def cli_main():
Expand All @@ -172,6 +176,7 @@ def cli_main():
viz_parser = subparsers.add_parser("viz", help="Visualize inputs on video")
viz_parser.add_argument("video", help="Path to video file")
viz_parser.add_argument("inputs", help="Path to inputs .parquet file")
viz_parser.add_argument("-o", type=int, default=0, help="Offset to start from")
viz_parser.set_defaults(func=cli_viz)

args = parser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion align-rec/pyproject.toml → irec/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.1.0"
authors = [
{ name="Loïc Magne", email="loic.magne@outlook.com" },
]
description = "Tool to align a video recording with an input recording"
description = "Utilities for recording inputs"
dependencies = [
"polars>=0.20.31",
"opencv-python>=4.10.0.82",
Expand Down
6 changes: 4 additions & 2 deletions src/input_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gamepad_manager::gamepad_manager():
SDL_SetHint(SDL_HINT_JOYSTICK_ROG_CHAKRAM, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_LINUX_DEADZONES, "1");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) != 0) {
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) != 0) {
obs_log(LOG_ERROR, "SDL_Init Error: %s", SDL_GetError());
}

Expand Down Expand Up @@ -157,10 +157,12 @@ void gamepad_manager::loop() {
remove_gamepad(event.gdevice.which);
std::cout << "Gamepad removed" << std::endl;
break;
default:
break;
}
}
save_gamepad_state();
SDL_Delay(5);
SDL_Delay(2);
}

int gamepad_manager::get_gamepad_idx(SDL_JoystickID joystickid) {
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ bool obs_module_load(void) {
obs_frontend_add_event_callback([](enum obs_frontend_event event, void *private_data) {
UNUSED_PARAMETER(private_data);
switch (event) {
case OBS_FRONTEND_EVENT_RECORDING_STARTING:
obs_log(LOG_INFO, "OBS_FRONTEND_EVENT_RECORDING_STARTING received");
case OBS_FRONTEND_EVENT_RECORDING_STARTED:
obs_log(LOG_INFO, "OBS_FRONTEND_EVENT_RECORDING_STARTED received");
REC_TIMER.start();
break;
case OBS_FRONTEND_EVENT_RECORDING_STOPPING:
Expand Down

0 comments on commit 290ebfd

Please sign in to comment.