From 4bd722681732a96c79c9d3cc10f0ade13e0dbee2 Mon Sep 17 00:00:00 2001 From: Xavier Loux Date: Thu, 19 Aug 2021 17:19:50 +0200 Subject: [PATCH] Add script --- ConvertVideoForResolve.py | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ConvertVideoForResolve.py diff --git a/ConvertVideoForResolve.py b/ConvertVideoForResolve.py new file mode 100644 index 0000000..82b06b3 --- /dev/null +++ b/ConvertVideoForResolve.py @@ -0,0 +1,46 @@ +print("start") + +import os +from os import listdir +from os.path import isfile, join +import time + +def VerifiDirs(directory): + # Check and create a folder if it does not exist + + if not os.path.exists(directory): + os.makedirs(directory) + return True + return False + +source_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"Source") +export_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"Export") +VerifiDirs(source_path) +VerifiDirs(export_path) + +files = [f for f in listdir(source_path) if isfile(join(source_path, f))] #Get all files + +def convert(fileName): + + SourceFile = os.path.join(source_path, fileName) + newFileName = fileName + #newFileName = newFileName[32:] #Lenge of vlc-record-2019-12-31-03h03m48s- + newFileName = newFileName[:-4] + #newFileName = newFileName+str(time.time()) + newFileName = newFileName+".mov" + ExportFile = os.path.join(export_path, newFileName) + + com = "cmd /k 'ffmpeg -i \""+SourceFile+"\" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov \""+ExportFile+"\"'" + com = "cmd /c ffmpeg -i \""+SourceFile+"\" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov \""+ExportFile+"\"" + #com = 'cmd /c "ffmpeg"' + print(com) + os.system(com) + + #video = moviepy.VideoFileClip(SourceFile) + #video.write_videofile(os.path.join(ExportFile),fps=24, codec='libx264', audio_codec='m4a') + #video.audio.write_audiofile(os.path.join(os.path.join(export_path, "sound"+".m4a"))) + + +for file in files: + print(file) + convert(file)