diff --git a/handle_imported_video.py b/handle_imported_video.py index 26e14f3..09fc035 100644 --- a/handle_imported_video.py +++ b/handle_imported_video.py @@ -23,7 +23,7 @@ elif sys.platform == "darwin": elif sys.platform == "win32": ops = "win" try: - opts, args = getopt.getopt(sys.argv[1:], "q:x:ta:r:fp:d:s:", ["command=", "help", "output=", "backup"]) + opts, args = getopt.getopt(sys.argv[1:], "q:x:ta:r:fp:d:s:z:", ["command=", "help", "output=", "backup"]) except getopt.GetoptError as err: # print help information and exit: print(str(err)) # will print something like "option -a not recognized" @@ -59,6 +59,9 @@ for o, a in opts: _TEST = True elif o in ("-x", "--file"): _FILE = a + elif o in ("-z", "--file"): + _SRC_FILE = a + elif o in ("-s", "--sequence"): a = a.split(",") for s in a: @@ -77,6 +80,14 @@ for o, a in opts: #print(_FULL_PATH) +def modify_creation_date(path,src_file): + create_date = filedate.File(src_file).get() + filedate.File(path).set( + created = create_date["created"], + modified = create_date["modified"], + accessed = create_date["accessed"] + ) + def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS): for _DAY_DIR in _DAY_DIRS: @@ -148,13 +159,8 @@ def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS): print(e) print(f"Failed to move {export_name}") - -if _ACTION == "flip": - flip_videos(_DEV, _SOURCE_DIR,_DAY_DIRS) - - - -if _ACTION == "join": + +def encode_videos(_DEV,_SOURCE_DIR,_DAY_DIRS): for _DAY_DIR in _DAY_DIRS: if ops == "win": _FULL_PATH = _SOURCE_DIR + "\\" + _DEV + "\\" + _DAY_DIR + "\\" @@ -233,34 +239,14 @@ if _ACTION == "join": # print(os.getcwd()) #status, output = subprocess.getstatusoutput(myCmd) - - if _FLIP: - if ops == "win": - myCmd = [ - "ffmpeg", "-f", "concat", "-i", "video.txt", "-c", "copy", "-metadata:s:v:0", "rotate=180","-y", export_name - ] - else: - # myCmd = [ - # "/usr/bin/ffmpeg", "-f", "concat", "-i", "video.txt", "-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name - - - - # ] - myCmd = [ - "/usr/bin/ffmpeg", "-f", "concat", "-i", "video.txt", "-c", "copy", "-metadata:s:v:0", "rotate=0", "-y", export_name - - ] - - + if ops == "win": + myCmd = [ + "ffmpeg", "-f", "concat", "-i", "video.txt","-vcodec", "copy", "-acodec", "copy", "-y", export_name + ] else: - if ops == "win": - myCmd = [ - "ffmpeg", "-f", "concat", "-i", "video.txt","-vcodec", "copy", "-acodec", "copy", "-y", export_name - ] - else: - myCmd = [ - "/usr/bin/ffmpeg", "-f", "concat", "-i", "video.txt","-c", "copy", "-y", export_name - ] + myCmd = [ + "/usr/bin/ffmpeg", "-f", "concat", "-i", "video.txt","-c", "copy", "-y", export_name + ] print(myCmd) d_print(" ".join(myCmd)) d_print(_FULL_PATH) @@ -345,6 +331,16 @@ if _ACTION == "join": os.remove("video.txt") except: pass + +if _ACTION == "modify_date": + modify_creation_date(_FILE,_SRC_FILE) + + +if _ACTION == "flip": + flip_videos(_DEV, _SOURCE_DIR,_DAY_DIRS) + +if _ACTION == "join": + encode_videos(_DEV, _SOURCE_DIR,_DAY_DIRS) if _ACTION == "encode": print("Encode Job")