@@ -81,9 +81,19 @@ This will create a shim between your code and the module binaries that gets upda
81
81
82
82
``` py
83
83
from tkinter import *
84
+
85
+ from ttkwidgets import TickScale
86
+
84
87
from tkvideoutils import VideoPlayer
85
88
from tkinter import filedialog, messagebox
86
89
90
+
91
+ def on_closing ():
92
+ player.loading = False
93
+ root.quit()
94
+ root.destroy()
95
+
96
+
87
97
if __name__ == ' __main__' :
88
98
# create instance of window
89
99
root = Tk()
@@ -99,9 +109,10 @@ if __name__ == '__main__':
99
109
forward_button = Button(root, image = skip_forward)
100
110
backward_button = Button(root, image = skip_backward)
101
111
video_label = Label(root)
102
- video_path = filedialog.askopenfilename()
112
+ video_path = ' recorded_video.mp4'
113
+ audio_path = ' recorded_video.wav'
103
114
slider_var = IntVar(root)
104
- slider = Scale (root, orient = HORIZONTAL , variable = slider_var)
115
+ slider = TickScale (root, orient = " horizontal " , variable = slider_var)
105
116
# place elements
106
117
video_label.pack()
107
118
button.pack()
@@ -111,15 +122,16 @@ if __name__ == '__main__':
111
122
112
123
if video_path:
113
124
# read video to display on label
114
- player = VideoPlayer(video_path, video_label,
115
- loop = False , size = (700 , 500 ),
125
+ player = VideoPlayer(root, video_path, audio_path, video_label, size = (700 , 500 ),
116
126
play_button = button, play_image = play_image, pause_image = pause_image,
117
- slider = slider, slider_var = slider_var)
127
+ slider = slider, slider_var = slider_var, keep_ratio = True , cleanup_audio = True )
118
128
else :
119
129
messagebox.showwarning(" Select Video File" , " Please retry and select a video file." )
120
130
sys.exit(1 )
131
+ player.set_clip(50 , 70 )
121
132
forward_button.config(command = player.skip_video_forward)
122
133
backward_button.config(command = player.skip_video_backward)
134
+ root.protocol(" WM_DELETE_WINDOW" , on_closing)
123
135
root.mainloop()
124
136
```
125
137
@@ -131,6 +143,24 @@ from tkvideoutils import VideoRecorder
131
143
from tkinter import messagebox
132
144
133
145
146
+ def merge_sources ():
147
+ if player.merge_sources(merged_path, ffmpeg_exe):
148
+ print (" Sources merged!" )
149
+ else :
150
+ print (" Something went wrong" )
151
+
152
+
153
+ def stop_recording ():
154
+ player.stop_recording()
155
+ player.stop_playback()
156
+ button[' command' ] = merge_sources
157
+
158
+
159
+ def start_recording ():
160
+ player.start_recording()
161
+ button[' command' ] = stop_recording
162
+
163
+
134
164
if __name__ == ' __main__' :
135
165
# create instance of window
136
166
root = Tk()
@@ -142,26 +172,33 @@ if __name__ == '__main__':
142
172
# create user interface
143
173
button = Button(root, image = play_image)
144
174
video_label = Label(root)
145
- video_path = ' test.mp4'
175
+ video_path = ' raw_video.mp4'
176
+ audio_path = ' recorded_video.wav'
177
+ merged_path = ' recorded_video.mp4'
146
178
# place elements
147
179
video_label.pack()
148
180
button.pack()
149
181
# Get existing video sources
150
- video_sources = VideoRecorder.get_sources()
182
+ video_sources = VideoRecorder.get_video_sources()
183
+ audio_sources = VideoRecorder.get_audio_sources()
184
+ print (video_sources, audio_sources)
185
+ # TODO : Fill out FFMPEG path
186
+ ffmpeg_exe = r ' '
151
187
152
188
if video_sources:
153
189
if video_path:
154
190
# read video to display on label
155
- player = VideoRecorder(source = video_sources[0 ], path = video_path, fps = 30 , label = video_label, size = (700 , 500 ))
191
+ player = VideoRecorder(video_source = video_sources[0 ], audio_source = audio_sources[1 ],
192
+ video_path = video_path, audio_path = audio_path, fps = 8 , label = video_label,
193
+ size = (700 , 500 ))
156
194
player.start_playback()
157
195
else :
158
196
messagebox.showwarning(" Select Video File" , " Please retry and select a video file." )
159
197
sys.exit(1 )
160
- button.config(command = player. start_recording)
198
+ button.config(command = start_recording)
161
199
root.mainloop()
162
200
else :
163
201
print (" No video sources found!" )
164
-
165
202
```
166
203
## Issues / Suggestions
167
204
0 commit comments