Skip to content

Commit b5a2b42

Browse files
authored
Update README.md
1 parent 9f9b5f5 commit b5a2b42

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

README.md

+47-10
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,19 @@ This will create a shim between your code and the module binaries that gets upda
8181

8282
```py
8383
from tkinter import *
84+
85+
from ttkwidgets import TickScale
86+
8487
from tkvideoutils import VideoPlayer
8588
from tkinter import filedialog, messagebox
8689

90+
91+
def on_closing():
92+
player.loading = False
93+
root.quit()
94+
root.destroy()
95+
96+
8797
if __name__ == '__main__':
8898
# create instance of window
8999
root = Tk()
@@ -99,9 +109,10 @@ if __name__ == '__main__':
99109
forward_button = Button(root, image=skip_forward)
100110
backward_button = Button(root, image=skip_backward)
101111
video_label = Label(root)
102-
video_path = filedialog.askopenfilename()
112+
video_path = 'recorded_video.mp4'
113+
audio_path = 'recorded_video.wav'
103114
slider_var = IntVar(root)
104-
slider = Scale(root, orient=HORIZONTAL, variable=slider_var)
115+
slider = TickScale(root, orient="horizontal", variable=slider_var)
105116
# place elements
106117
video_label.pack()
107118
button.pack()
@@ -111,15 +122,16 @@ if __name__ == '__main__':
111122

112123
if video_path:
113124
# 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),
116126
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)
118128
else:
119129
messagebox.showwarning("Select Video File", "Please retry and select a video file.")
120130
sys.exit(1)
131+
player.set_clip(50, 70)
121132
forward_button.config(command=player.skip_video_forward)
122133
backward_button.config(command=player.skip_video_backward)
134+
root.protocol("WM_DELETE_WINDOW", on_closing)
123135
root.mainloop()
124136
```
125137

@@ -131,6 +143,24 @@ from tkvideoutils import VideoRecorder
131143
from tkinter import messagebox
132144

133145

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+
134164
if __name__ == '__main__':
135165
# create instance of window
136166
root = Tk()
@@ -142,26 +172,33 @@ if __name__ == '__main__':
142172
# create user interface
143173
button = Button(root, image=play_image)
144174
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'
146178
# place elements
147179
video_label.pack()
148180
button.pack()
149181
# 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''
151187

152188
if video_sources:
153189
if video_path:
154190
# 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))
156194
player.start_playback()
157195
else:
158196
messagebox.showwarning("Select Video File", "Please retry and select a video file.")
159197
sys.exit(1)
160-
button.config(command=player.start_recording)
198+
button.config(command=start_recording)
161199
root.mainloop()
162200
else:
163201
print("No video sources found!")
164-
165202
```
166203
## Issues / Suggestions
167204

0 commit comments

Comments
 (0)