This commit is contained in:
2025-06-19 18:04:30 +02:00
parent 7e04570725
commit c39cfc51d0

View File

@@ -107,10 +107,13 @@ def export_gps(_DEV,_SOURCE_DIR,_DAY_DIRS):
if ops == "win": if ops == "win":
_FULL_PATH = _SOURCE_DIR + "\\" + _DEV + "\\" + _DAY_DIR + "\\" _FULL_PATH = _SOURCE_DIR + "\\" + _DEV + "\\" + _DAY_DIR + "\\"
else: else:
_FULL_PATH = _SOURCE_DIR + "/" + _DEV + "/" + _DAY_DIR + "/" _FULL_PATH = _SOURCE_DIR + _DEV + "/" + _DAY_DIR + "/"
shutil.copyfile("/usr/bin/ffmpeg", _FULL_PATH + "ffmpeg") shutil.copyfile("/usr/bin/ffmpeg", _FULL_PATH + "ffmpeg")
shutil.copyfile("/usr/bin/ffprobe", _FULL_PATH + "ffprobe") shutil.copyfile("/usr/bin/ffprobe", _FULL_PATH + "ffprobe")
os.chdir(_FULL_PATH) os.chdir(_FULL_PATH)
if not os.path.exists("gps_data"):
os.mkdir("gps_data")
for filename in os.listdir(_FULL_PATH): for filename in os.listdir(_FULL_PATH):
if _FILTER: if _FILTER:
if _PATERN in filename: if _PATERN in filename:
@@ -121,7 +124,20 @@ def export_gps(_DEV,_SOURCE_DIR,_DAY_DIRS):
myCmd = f"gopro2gpx -s {filename} {filename.replace('.MP4', '')}" myCmd = f"gopro2gpx -s {filename} {filename.replace('.MP4', '')}"
print(myCmd) print(myCmd)
status, output = subprocess.getstatusoutput(myCmd) status, output = subprocess.getstatusoutput(myCmd)
print(output) #print(output)
print(status)
if os.path.exists(f"{_FULL_PATH}gps_data/{filename.replace('.MP4', '.csv')}"):
os.remove(f"{_FULL_PATH}gps_data/{filename.replace('.MP4', '.csv')}")
if os.path.exists(f"{_FULL_PATH}gps_data/{filename.replace('.MP4', '.gpx')}"):
os.remove(f"{_FULL_PATH}gps_data/{filename.replace('.MP4', '.gpx')}")
if os.path.exists(f"{_FULL_PATH}gps_data/{filename.replace('.MP4', '.kml')}"):
os.remove(f"{_FULL_PATH}gps_data/{filename.replace('.MP4', '.kml')}")
try:
shutil.move(f"{_FULL_PATH}{filename.replace('.MP4', '.csv')}", f"{_FULL_PATH}gps_data/","")
shutil.move(f"{_FULL_PATH}{filename.replace('.MP4', '.gpx')}", f"{_FULL_PATH}gps_data/")
shutil.move(f"{_FULL_PATH}{filename.replace('.MP4', '.kml')}", f"{_FULL_PATH}gps_data/")
except:
pass
os.remove(_FULL_PATH + "ffmpeg") os.remove(_FULL_PATH + "ffmpeg")
os.remove(_FULL_PATH + "ffprobe") os.remove(_FULL_PATH + "ffprobe")
def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS): def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS):
@@ -130,10 +146,11 @@ def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS):
if ops == "win": if ops == "win":
_FULL_PATH = _SOURCE_DIR + "\\" + _DEV + "\\" + _DAY_DIR + "\\" _FULL_PATH = _SOURCE_DIR + "\\" + _DEV + "\\" + _DAY_DIR + "\\"
else: else:
_FULL_PATH = _SOURCE_DIR + "/" + _DEV + "/" + _DAY_DIR + "/" _FULL_PATH = _SOURCE_DIR + _DEV + "/" + _DAY_DIR + "/"
os.chdir(_FULL_PATH) os.chdir(_FULL_PATH)
_PROCESSED = _FULL_PATH + "processed" _PROCESSED = _FULL_PATH + "processed"
print(f"Processed folder : {_PROCESSED}")
if not os.path.exists(_PROCESSED): if not os.path.exists(_PROCESSED):
os.mkdir(_PROCESSED) os.mkdir(_PROCESSED)
for filename in os.listdir(_FULL_PATH): for filename in os.listdir(_FULL_PATH):
@@ -144,8 +161,6 @@ def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS):
continue continue
if filename.endswith(".MP4") and not filename.startswith("joined_"): if filename.endswith(".MP4") and not filename.startswith("joined_"):
create_date = filedate.File(filename).get() create_date = filedate.File(filename).get()
print(filename) print(filename)
export_name = 'flipped_' + filename export_name = 'flipped_' + filename
@@ -154,42 +169,21 @@ def flip_videos(_DEV,_SOURCE_DIR,_DAY_DIRS):
"ffmpeg", "-i", filename ,"-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name "ffmpeg", "-i", filename ,"-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name
] ]
else: else:
# myCmd = [
# "/usr/bin/ffmpeg", "-i", filename, "-c", "copy", "-metadata:s:v:0", "rotate=180", "-y", export_name
# ]
# myCmd = [
# "/usr/bin/ffmpeg", "-i", filename, "-vf", "transpose=2,transpose=2", "-y", export_name
# ]
# myCmd = [
# "/usr/bin/ffmpeg", "-i", filename, "-vf", "hflip", "-c:a", "-codec", "copy", "-y", export_name
# ]
myCmd = f"exiftool -rotation=180 {filename}" myCmd = f"exiftool -rotation=180 {filename}"
#Path = "~/Documents/File.txt"
# filedate.File(Path).set(
# created = "1st February 2003, 12:30",
# modified = "3:00 PM, 04 May 2009",
# accessed = "08/07/2014 18:30:45"
# )
if _TEST: if _TEST:
print(_FULL_PATH) print(_FULL_PATH)
print(myCmd) print(myCmd)
print(myCmd) print(myCmd)
status, output = subprocess.getstatusoutput(myCmd) status, output = subprocess.getstatusoutput(myCmd)
print(output) print(output)
#proc = subprocess.Popen(myCmd,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
# print(f"Fliping {filename} 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()
# 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: try:
shutil.move(filename + "_original", _PROCESSED + "/" + filename) print("Moving file to processed")
src = _FULL_PATH + filename + "_original"
dest = _PROCESSED + "/" + filename
print(f"Source : {src}")
print(f"Destination : {dest}")
shutil.move(src, dest)
# shutil.move(export_name, export_name) # shutil.move(export_name, export_name)
filedate.File(filename).set( filedate.File(filename).set(
@@ -355,10 +349,14 @@ def join_videos(_DEV,_SOURCE_DIR,_DAY_DIRS):
if status == 0 and not _TEST: if status == 0 and not _TEST:
print("Moving...") print("Moving...")
for p in parts: for p in parts:
try:
shutil.move(p, _PROCESSED) if os.path.exists(_PROCESSED + p):
except: os.remove(p)
print(f"Failed to move {p}") else:
try:
shutil.move(p, _PROCESSED)
except:
print(f"Failed to move {p}")
try: try:
shutil.move(p.replace("MP4", "THM"), _PROCESSED) shutil.move(p.replace("MP4", "THM"), _PROCESSED)
except: except: