Created
December 24, 2016 01:48
-
-
Save MrValdez/d011ac39f2dc22305d690b3ea2785bd0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
So I was practicing my combo for xiaoyu when I came upon this video. (https://www.youtube.com/watch?v=cwwPr53mci4) | |
Problem is that the video creator didn't put in the proper notation so I had to eyeball how to do the combos. | |
Youtube is horrible for rewinding back to a specific time. I prefer using my video player. That's when I had the idea | |
to make this script to download and seperate the combos I'm interested in. | |
Note that there's a bug here where the filename saved is not xiaoyu.mp4. I had to comment out the download and re-run | |
the script with the filename renamed afterwards. ...but it works! | |
....after finishing this script, I lost interest in practicing the combo. *smh* | |
""" | |
import youtube_dl | |
import moviepy.editor | |
filename = "xiaoyu.mp4" | |
ydl_opts = { | |
"format": "best", | |
"outtmpl": filename, | |
"nocheckcertificate": True, # ymmv | |
} | |
with youtube_dl.YoutubeDL(ydl_opts) as ydl: | |
ydl.download(["https://www.youtube.com/watch?v=cwwPr53mci4"]) | |
timestamp = """.16 - .22 | |
.22 - .26 | |
.47 - .54 | |
.54 - .57 | |
1.18 - 1.23 | |
1.23 - 1.28 | |
2.24 - 2.28 | |
4.20 - 4.26 | |
4.16 - 4.20""".split("\n") | |
timestamp = [time.split(" - ") for time in timestamp] | |
for i, time in enumerate(timestamp): | |
start, end = time | |
def toseconds(s): | |
s = s.split(".") | |
s[0] = s[0] or 0 | |
return (int(s[0]) * 60) + int(s[1]) | |
start, end = toseconds(start), toseconds(end) | |
start, end = int(start), int(end) | |
timestamp[i] = start, end | |
#print(timestamp) | |
video = moviepy.editor.VideoFileClip(filename) | |
for i, time in enumerate(timestamp): | |
video.subclip(*time).write_videofile("xiaoyu {}.mp4".format(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment