Skip to content

Commit ce6e6dd

Browse files
author
arch
committed
fix raw output
1 parent e98ad96 commit ce6e6dd

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,12 @@ def create_funscript(self, idx_dict: dict) -> None:
760760
"""
761761
if self.params.raw_output:
762762
output_score = copy.deepcopy(self.score[self.params.metric])
763+
self.logger.warning("Insert %d raw points", len(output_score))
763764
for idx in range(len(output_score)):
764765
self.funscript.add_action(
765-
output_score[idx],
766-
FFmpegStream.frame_to_millisec(self.get_absolute_framenumber(idx), self.video_info.fps)
766+
round(output_score[idx]),
767+
FFmpegStream.frame_to_millisec(self.get_absolute_framenumber(idx), self.video_info.fps),
768+
True
767769
)
768770

769771
else:

funscript_editor/data/funscript.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,21 @@ def get_stroke_height(self, current_timestamp: int) -> int:
205205
return int(round(abs(self.get_next_action(current_timestamp)['pos'] - self.get_prev_action(current_timestamp)['pos'])))
206206

207207

208-
def add_action(self, position: int, time: int):
208+
def add_action(self, position: int, time: int, insert_raw: bool = False):
209209
""" Add a new action to the Funscript
210210
211211
Args:
212212
position (int): position in percent (0-100)
213213
time (int): time to be at position in milliseconds
214+
insert_raw (bool): do not delete near points
214215
215216
Returns:
216217
Funscript: current funscript instance
217218
"""
219+
print('raw is', insert_raw)
218220
self.changed = True
219-
self.delete_action(time)
221+
if not insert_raw:
222+
self.delete_action(time)
220223
self.data['actions'].append({'pos': int(round(position)), 'at': time})
221224
self.data['actions'].sort(key = lambda x: x['at'])
222225
return self

funscript_editor/ui/funscript_generator_window.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from funscript_editor.ui.settings_dialog import SettingsDialog
1212
import funscript_editor.definitions as definitions
1313
from funscript_editor.ui.theme import setup_theme
14+
from funscript_editor.utils.config import SETTINGS
1415

1516
from PyQt5 import QtCore, QtGui, QtWidgets
1617

@@ -99,7 +100,7 @@ def __show_message(self, message :str, error: bool = False) -> None:
99100
def __funscript_generated(self, funscript, msg, success) -> None:
100101
if isinstance(self.output_file, Funscript):
101102
for item in funscript.get_actions():
102-
self.output_file.add_action(item['pos'], item['at'])
103+
self.output_file.add_action(item['pos'], item['at'], SETTINGS['raw_output'])
103104
self.funscriptCompleted.emit(self.output_file, msg, success)
104105
else:
105106
os.makedirs(os.path.dirname(self.output_file), exist_ok=True)

0 commit comments

Comments
 (0)