Created
February 20, 2018 00:29
-
-
Save trolleway/68c45abcf384e2af73e8da5377a64bce 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
import os,shutil | |
def slice(video,folder='frames',fps=2,timecode_start='00:00:00',duration=3): | |
shutil.rmtree(folder, ignore_errors=True) | |
if not os.path.exists(folder): | |
os.mkdir(folder) | |
cmd = 'ffmpeg -ss {timecode_start} -i "{video}" -t {duration} -r {fps} -f image2 -vcodec mjpeg -qscale 1 "{folder}/frame_%05d.jpg"'.format(folder=folder,video=video,fps=fps,timecode_start=timecode_start,duration=duration) | |
os.system(cmd) | |
video = u"kiev1983.mkv" | |
''' | |
folder = "Kiev 1983 01 memorial" | |
fps = 3 | |
timecode_start = '00:03:30' | |
duration = 17 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 02 cathedral" | |
fps = 3 | |
timecode_start = '00:03:47' | |
duration = 12 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 03 street" | |
fps = 4 | |
timecode_start = '00:03:59' | |
duration = 20 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 05 hill" | |
fps = 2 | |
timecode_start = '00:07:17' | |
duration = 55-17 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 06 hill" | |
fps = 2 | |
timecode_start = '00:07:52' | |
duration = 35+8 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 07 oktyabrskoy revolutsii square" | |
fps = 10 | |
timecode_start = '00:34:56' | |
duration = 56-32-1 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 08 aerial scene" | |
fps = 10 | |
timecode_start = '00:48:49' | |
duration = 8+11 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 09 aerial scene" | |
fps = 10 | |
timecode_start = '00:49:08' | |
duration = 36-8 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
''' | |
''' | |
folder = "Kiev 1983 10 aerial scene Kreshatik" | |
fps = 2 | |
timecode_start = '00:49:43' | |
duration = 25+(60-43) | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 11 aerial scene" | |
fps = 2 | |
timecode_start = '00:50:25' | |
duration = 19 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
folder = "Kiev 1983 12 aerial scene" | |
fps = 2 | |
timecode_start = '00:50:45' | |
duration = 39+15 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
''' | |
folder = "Kiev 1983 13 aerial scene" | |
fps = 2 | |
timecode_start = '00:56:25' | |
duration = 35+15 | |
slice(video=video,folder=folder,fps=fps,timecode_start=timecode_start,duration=duration) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment