fixed logging and added default number
This commit is contained in:
29
translate.py
29
translate.py
@@ -25,7 +25,6 @@ def getMetadata(filesArray):
|
||||
timecode = entry.get("H264:TimeCode")
|
||||
|
||||
filteredArray[fileName] = [userBit, timecode]
|
||||
print(filteredArray)
|
||||
return filteredArray
|
||||
|
||||
|
||||
@@ -42,10 +41,10 @@ def applyMetadataDict(fixedDict):
|
||||
metaDict = {}
|
||||
userBitArray = fixedDict[key][0]
|
||||
|
||||
metaDict["Act"] = userBitArray[3]
|
||||
metaDict["Scene"] = userBitArray[2]
|
||||
metaDict["Reel"] = userBitArray[1]
|
||||
metaDict["Shot"] = userBitArray[0]
|
||||
metaDict["Act"] = userBitArray[3] if userBitArray else 1
|
||||
metaDict["Scene"] = userBitArray[2] if userBitArray else 1
|
||||
metaDict["Reel"] = userBitArray[1] if userBitArray else 1
|
||||
metaDict["Shot"] = userBitArray[0] if userBitArray else 1
|
||||
|
||||
fixedDict[key][0] = metaDict
|
||||
|
||||
@@ -158,6 +157,7 @@ def makeFileNameDict(infoDict):
|
||||
|
||||
|
||||
def setFilePath(fileNameDict):
|
||||
os.makedirs("./output", exist_ok=True)
|
||||
for file in fileNameDict:
|
||||
fileName = "./output/" + fileNameDict[file][1] + ".mov"
|
||||
fileNameDict[file][1] = fileName
|
||||
@@ -168,6 +168,10 @@ def copyFiles(filePathDict):
|
||||
for file in filePathDict:
|
||||
command = [
|
||||
"ffmpeg",
|
||||
"-hide_banner",
|
||||
"-v",
|
||||
"error", # Hide everything except errors
|
||||
"-stats", # Force FFmpeg to print the progress line
|
||||
"-i",
|
||||
file,
|
||||
"-c:v",
|
||||
@@ -181,10 +185,12 @@ def copyFiles(filePathDict):
|
||||
]
|
||||
|
||||
try:
|
||||
subprocess.run(command, check=True, capture_output=True, text=True)
|
||||
print(f"copied {file} to {filePathDict[file][1]}")
|
||||
print(f"\nTranscoding {file} to {filePathDict[file][1]}...")
|
||||
# REMOVED capture_output=True so it streams directly to your terminal
|
||||
subprocess.run(command, check=True)
|
||||
print(f"Finished: {filePathDict[file][1]}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"FFmpeg failed for {inputMts}: {e.stderr}")
|
||||
print(f"FFmpeg failed for {file}")
|
||||
|
||||
|
||||
def generateResolveCsv(clipDict, outputCsvPath):
|
||||
@@ -202,7 +208,7 @@ def generateResolveCsv(clipDict, outputCsvPath):
|
||||
"Take",
|
||||
"Good Take",
|
||||
"Rating",
|
||||
"Bin",
|
||||
"Keywords",
|
||||
]
|
||||
|
||||
try:
|
||||
@@ -227,7 +233,7 @@ def generateResolveCsv(clipDict, outputCsvPath):
|
||||
"Take": str(meta["Take"]),
|
||||
"Good Take": "1" if meta["Good"] else "0",
|
||||
"Rating": "5" if meta["Good"] else "0",
|
||||
"Bin": f"Clips/Reel {meta['Reel']}",
|
||||
"Keywords": f"Reel {meta['Reel']}",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -238,14 +244,13 @@ def generateResolveCsv(clipDict, outputCsvPath):
|
||||
|
||||
|
||||
files = getFiles()
|
||||
print()
|
||||
userBitDict = getMetadata(files)
|
||||
fixedUBDict = orderUserBit(userBitDict)
|
||||
metadataDict = applyMetadataDict(fixedUBDict)
|
||||
takesDict = addTakeNumbers(metadataDict)
|
||||
final = addGoodKey(takesDict)
|
||||
print(final)
|
||||
fileNames = makeFileNameDict(final)
|
||||
filePaths = setFilePath(fileNames)
|
||||
copyFiles(filePaths)
|
||||
print(filePaths)
|
||||
generateResolveCsv(filePaths, "./out.csv")
|
||||
|
||||
Reference in New Issue
Block a user