add more files

This commit is contained in:
Tanishq Dubey 2022-10-21 20:25:53 -04:00
parent 80d8845eda
commit 8cef9fe666
2 changed files with 20 additions and 0 deletions

7
src/math/cost.py Normal file
View File

@ -0,0 +1,7 @@
"""
Functions in this file should always target for 0 to be the
lowest possible error -> smaller values win
"""
def quadratic_loss(target, result):
return (target - result)**2.0

13
src/mediautils/video.py Normal file
View File

@ -0,0 +1,13 @@
import moviepy.editor as mp
def get_subclips(source_video_path, moments):
vid = mp.VideoFileClip(source_video_path)
clips = []
for m in moments:
clips.append(vid.subclip(m.start, m.stop))
return clips, vid
def render_moments(moments, input_video_path, output_path):
clips, vid = get_subclips(input_video_path, moments)
to_render = mp.concatenate_videoclips(clips, logger=None)
to_render.write_videofile(output_path, logger=None)