Skip to content

Commit 778996a

Browse files
author
arch
committed
pass next action point to python
1 parent cd6d64c commit 778996a

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

contrib/OpenFunscripter/funscript_generator_linux.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Settings = {}
2-
Settings.PythonScript = "/home/arch/repos/python-funscript-editor/funscript-editor.py"
2+
Settings.PythonScript = "/home/arch/Repos/public/Python-Funscript-Editor/funscript-editor.py"
33
Settings.TmpFile = "/tmp/funscript_actions.csv"
44
SetSettings(Settings)
55

6-
-- Version: 1.0.0
6+
-- Version: 1.2.0
77
function GetActions(video)
88
local at = {}
99
local pos = {}
10-
local command = 'python3 "'..Settings.PythonScript..'" --generator -s '..tostring(CurrentTimeMs)..' -i "'..video..'" -o "'..Settings.TmpFile..'"'
10+
local next_action = CurrentScript:GetClosestActionAfter(CurrentTimeMs)
11+
local command = 'python3 "'..Settings.PythonScript..'" --generator -s '..( next_action == nil and tostring(CurrentTimeMs) or tostring(CurrentTimeMs)..' -e '..tostring(next_action.at))..' -i "'..video..'" -o "'..Settings.TmpFile..'"'
1112
print(command)
1213
os.execute(command)
1314
local f = io.open(Settings.TmpFile)

funscript_editor/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ def main():
1111
parser.add_argument("--generator", action = 'store_true', help = "Run only the generator")
1212
parser.add_argument("-i", "--input", type = str, help = "Video File")
1313
parser.add_argument("-o", "--output", type = str, default = "/tmp/funscript_actions.csv", help = "Output Path")
14-
parser.add_argument("-s", "--start", type = int, default = 0, help = "Start Time in Milliseconds")
14+
parser.add_argument("-s", "--start", type = float, default = 0.0, help = "Start Time in Milliseconds")
15+
parser.add_argument("-e", "--end", type = float, default = -1.0, help = "End/Stop Time in Milliseconds")
1516
args = parser.parse_args()
1617

1718
if os.getcwd() not in os.environ['PATH']:
1819
os.environ['PATH'] = os.getcwd() + os.sep + os.environ['PATH']
1920

2021
if not args.generator: show_editor()
21-
else: generate_funscript(args.input, args.start, args.output)
22+
else: generate_funscript(args.input, args.start, args.end, args.output)

funscript_editor/algorithms/funscriptgenerator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FunscriptGeneratorParameter:
3131
""" Funscript Generator Parameter Dataclass with default values """
3232
video_path: str # no default value
3333
start_frame: int = 0 # default is video start (input: set current video position)
34+
end_frame: int = -1 # default is video end (-1)
3435
track_men: bool = True # set by userinput at start (message box)
3536
skip_frames: int = max((0, int(HYPERPARAMETER['skip_frames'])))
3637
max_playback_fps: int = max((0, int(SETTINGS['max_playback_fps'])))

funscript_editor/api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,22 @@ def show_editor() -> None:
2121
sys.exit(app.exec_())
2222

2323

24-
def generate_funscript(video_file: str, start_time: int, output_file: str) -> None:
24+
def generate_funscript(
25+
video_file: str,
26+
start_time: float,
27+
end_time :float,
28+
output_file: str) -> None:
2529
""" Generate a funscript with minimal UI
2630
2731
Args:
2832
video_file (str): path to video file
29-
start_time (int): start time in milliseconds
33+
start_time (float): start time in milliseconds
34+
end_time (float): end time in milliseconds (set -1.0 to use video end)
3035
output_file (str): path for the output file
3136
"""
3237
setup_logging()
3338
logging.info("Python Funscript Generator %s", VERSION)
3439
app = QtWidgets.QApplication(sys.argv)
35-
generator = MinimalFunscriptGenerator(video_file, start_time, output_file)
40+
generator = MinimalFunscriptGenerator(video_file, start_time, end_time, output_file)
3641
generator.run()
3742
sys.exit(app.exec_())

funscript_editor/ui/minimal.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ class MinimalFunscriptGenerator(QtWidgets.QMainWindow):
1919
2020
Args:
2121
video_file (str): path to video file
22-
start_time (int): start position in video (timestamp in milliseconds)
22+
start_time (float): start position in video (timestamp in milliseconds)
23+
end_time (float): end position in video (timestamp in milliseconds) use -1.0 for video end.
24+
output_file (str): csv output file path
2325
"""
2426

25-
def __init__(self, video_file, start_time, output_file):
27+
def __init__(self,
28+
video_file: str,
29+
start_time: float,
30+
end_time: float,
31+
output_file: str):
2632
super(MinimalFunscriptGenerator, self).__init__()
2733

2834
if os.path.isdir(output_file):
@@ -62,12 +68,14 @@ def __init__(self, video_file, start_time, output_file):
6268
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)
6369
trackMen = True if reply == QtWidgets.QMessageBox.Yes else False
6470

65-
start_frame = int(round(float(start_time)/(float(1000)/float(fps))))
71+
start_frame = int(round(float(start_time)/(float(1000)/float(fps)))) if start_time > 0.0 else 0
72+
end_frame = int(round(float(end_time)/(float(1000)/float(fps)))) if end_time > 0.0 else -1
6673

6774
self.funscript_generator = FunscriptGenerator(
6875
FunscriptGeneratorParameter(
6976
video_path = video_file,
7077
start_frame = start_frame,
78+
end_frame = end_frame,
7179
track_men = trackMen
7280
),
7381
self.funscript)

0 commit comments

Comments
 (0)