From 51a5d97916159e297026cccdfe3be2bed157a35a Mon Sep 17 00:00:00 2001 From: jaydee Date: Mon, 16 Jun 2025 07:50:04 +0200 Subject: [PATCH] build --- handle_imported_video.py | 60 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/handle_imported_video.py b/handle_imported_video.py index c9cc37a..aaa93a7 100644 --- a/handle_imported_video.py +++ b/handle_imported_video.py @@ -82,18 +82,23 @@ if _ACTION == "flip": _FULL_PATH = _SOURCE_DIR + "\\" + _DEV + "\\" + _DAY_DIR + "\\" else: _FULL_PATH = _SOURCE_DIR + "/" + _DEV + "/" + _DAY_DIR + "/" - export_name = "X" + _FILE - if ops == "win": - myCmd = [ - "ffmpeg", "-i", _FILE ,"-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name - ] - else: - # myCmd = [ - # "/usr/bin/ffmpeg", "-f", "-i", _FILE, "-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name - # ] - myCmd = [ - "/usr/bin/ffmpeg", "-f", "-i", _FILE, "-vf", "hflip", "-c:a", "copy", "-y", export_name - ] + + for filename in os.listdir(_FULL_PATH): + FPATH = _FULL_PATH + filename + if filename.endswith(".MP4") and not filename.startswith("joined_"): + print(filename) + export_name = 'flipped_' + filename + if ops == "win": + myCmd = [ + "ffmpeg", "-i", filename ,"-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name + ] + else: + # myCmd = [ + # "/usr/bin/ffmpeg", "-f", "-i", _FILE, "-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name + # ] + myCmd = [ + "/usr/bin/ffmpeg", "-f", "-i", filename, "-vf", "hflip", "-c:a", "copy", "-y", export_name + ] #Path = "~/Documents/File.txt" # filedate.File(Path).set( @@ -101,28 +106,29 @@ if _ACTION == "flip": # modified = "3:00 PM, 04 May 2009", # accessed = "08/07/2014 18:30:45" # ) - create_date = filedate.File(_FULL_PATH + _FILE).get() - if _TEST: - print(_FULL_PATH) - print(myCmd) - os.chdir(_FULL_PATH) - proc = subprocess.Popen(myCmd,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT) - print(f"Fliping {_FILE} to {export_name} in {_DAY_DIR}...".ljust(100)) - ff = FfmpegProgress(myCmd) - with tqdm(total=100, position=1, desc="Fliping") as pbar: - for progress in ff.run_command_with_progress(): - pbar.update(progress - pbar.n) - pbar.close() + os.chdir(_FULL_PATH) + create_date = filedate.File(filename).get() + if _TEST: + print(_FULL_PATH) + print(myCmd) + + proc = subprocess.Popen(myCmd,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT) + print(f"Fliping {filename} to {export_name} in {_DAY_DIR}...".ljust(100)) + ff = FfmpegProgress(myCmd) + with tqdm(total=100, position=1, desc="Fliping") as pbar: + for progress in ff.run_command_with_progress(): + pbar.update(progress - pbar.n) + pbar.close() print(f"Done".ljust(130),end='', flush=True) # get the output #print(ff.stderr) #ffmpeg -i .\GH010149.MP4 -c:v hevc_amf -rc cqp -qp_i 42 -qp_p 42 -quality quality -crf 25 output7.mp4 try: - shutil.move(_FILE, "__" + export_name) - shutil.move(export_name, _FILE) + shutil.move(export_name, "__" + export_name) + shutil.move(export_name, export_name) - filedate.File(_FULL_PATH + _FILE).set( + filedate.File(_FULL_PATH + export_name).set( created = create_date["created"], modified = create_date["modified"], accessed = create_date["accessed"]