Last active
January 17, 2020 04:12
-
-
Save zackbloom/2bf0971cc7a8f2d7a9aa84079bb00587 to your computer and use it in GitHub Desktop.
Revisions
-
zackbloom revised this gist
Jan 17, 2020 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,13 +16,14 @@ file = None def next_file(): global file if file is not None: file.flush() join_videos() file.close() file = tempfile.NamedTemporaryFile() def join_videos(): global current_file_index, file @@ -31,6 +32,7 @@ def join_videos(): current_file_index += 1 os.system("ffmpeg -f concat -safe 0 -i '%s' -c copy %i.mp4" % (file.name, current_file_index)) last = 0 for filepath in files: mtime = os.path.getmtime(filepath) -
zackbloom created this gist
Jan 17, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #!/usr/bin/env python import os import os.path import time import tempfile from glob import glob ONE_HOUR = 60 * 60 files = [f for f in glob('*.MP4') if os.path.isfile(f)] files.sort(key=os.path.getmtime) current_file_index = 0 file = None def next_file(): global file if file is not None: file.flush() join_videos() file = tempfile.NamedTemporaryFile() def join_videos(): global current_file_index, file if file.tell() > 0: current_file_index += 1 os.system("ffmpeg -f concat -safe 0 -i '%s' -c copy %i.mp4" % (file.name, current_file_index)) last = 0 for filepath in files: mtime = os.path.getmtime(filepath) if (mtime - last) > ONE_HOUR/2: next_file() last = mtime file.write("file '%s'\n" % os.path.join(os.getcwd(), filepath)) next_file()