fixed logging and added default number
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
/.venv
|
/.venv
|
||||||
/.session
|
/.session
|
||||||
/STREAM
|
/STREAM
|
||||||
|
/output
|
||||||
|
/out.csv
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
# 2. Create a wrapper script that runs your python file with the correct PATH
|
# 2. Create a wrapper script that runs your python file with the correct PATH
|
||||||
runScript = pkgs.writeShellScriptBin "run-python-script" ''
|
runScript = pkgs.writeShellScriptBin "run-python-script" ''
|
||||||
export PATH="${pkgs.exiftool}/bin:$PATH"
|
export PATH="${pkgs.exiftool}/bin:${pkgs.ffmpeg}/bin:$PATH"
|
||||||
exec ${myPython}/bin/python ./translate.py "$@"
|
exec ${myPython}/bin/python ./translate.py "$@"
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
|
|||||||
29
translate.py
29
translate.py
@@ -25,7 +25,6 @@ def getMetadata(filesArray):
|
|||||||
timecode = entry.get("H264:TimeCode")
|
timecode = entry.get("H264:TimeCode")
|
||||||
|
|
||||||
filteredArray[fileName] = [userBit, timecode]
|
filteredArray[fileName] = [userBit, timecode]
|
||||||
print(filteredArray)
|
|
||||||
return filteredArray
|
return filteredArray
|
||||||
|
|
||||||
|
|
||||||
@@ -42,10 +41,10 @@ def applyMetadataDict(fixedDict):
|
|||||||
metaDict = {}
|
metaDict = {}
|
||||||
userBitArray = fixedDict[key][0]
|
userBitArray = fixedDict[key][0]
|
||||||
|
|
||||||
metaDict["Act"] = userBitArray[3]
|
metaDict["Act"] = userBitArray[3] if userBitArray else 1
|
||||||
metaDict["Scene"] = userBitArray[2]
|
metaDict["Scene"] = userBitArray[2] if userBitArray else 1
|
||||||
metaDict["Reel"] = userBitArray[1]
|
metaDict["Reel"] = userBitArray[1] if userBitArray else 1
|
||||||
metaDict["Shot"] = userBitArray[0]
|
metaDict["Shot"] = userBitArray[0] if userBitArray else 1
|
||||||
|
|
||||||
fixedDict[key][0] = metaDict
|
fixedDict[key][0] = metaDict
|
||||||
|
|
||||||
@@ -158,6 +157,7 @@ def makeFileNameDict(infoDict):
|
|||||||
|
|
||||||
|
|
||||||
def setFilePath(fileNameDict):
|
def setFilePath(fileNameDict):
|
||||||
|
os.makedirs("./output", exist_ok=True)
|
||||||
for file in fileNameDict:
|
for file in fileNameDict:
|
||||||
fileName = "./output/" + fileNameDict[file][1] + ".mov"
|
fileName = "./output/" + fileNameDict[file][1] + ".mov"
|
||||||
fileNameDict[file][1] = fileName
|
fileNameDict[file][1] = fileName
|
||||||
@@ -168,6 +168,10 @@ def copyFiles(filePathDict):
|
|||||||
for file in filePathDict:
|
for file in filePathDict:
|
||||||
command = [
|
command = [
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
|
"-hide_banner",
|
||||||
|
"-v",
|
||||||
|
"error", # Hide everything except errors
|
||||||
|
"-stats", # Force FFmpeg to print the progress line
|
||||||
"-i",
|
"-i",
|
||||||
file,
|
file,
|
||||||
"-c:v",
|
"-c:v",
|
||||||
@@ -181,10 +185,12 @@ def copyFiles(filePathDict):
|
|||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(command, check=True, capture_output=True, text=True)
|
print(f"\nTranscoding {file} to {filePathDict[file][1]}...")
|
||||||
print(f"copied {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:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"FFmpeg failed for {inputMts}: {e.stderr}")
|
print(f"FFmpeg failed for {file}")
|
||||||
|
|
||||||
|
|
||||||
def generateResolveCsv(clipDict, outputCsvPath):
|
def generateResolveCsv(clipDict, outputCsvPath):
|
||||||
@@ -202,7 +208,7 @@ def generateResolveCsv(clipDict, outputCsvPath):
|
|||||||
"Take",
|
"Take",
|
||||||
"Good Take",
|
"Good Take",
|
||||||
"Rating",
|
"Rating",
|
||||||
"Bin",
|
"Keywords",
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -227,7 +233,7 @@ def generateResolveCsv(clipDict, outputCsvPath):
|
|||||||
"Take": str(meta["Take"]),
|
"Take": str(meta["Take"]),
|
||||||
"Good Take": "1" if meta["Good"] else "0",
|
"Good Take": "1" if meta["Good"] else "0",
|
||||||
"Rating": "5" 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()
|
files = getFiles()
|
||||||
|
print()
|
||||||
userBitDict = getMetadata(files)
|
userBitDict = getMetadata(files)
|
||||||
fixedUBDict = orderUserBit(userBitDict)
|
fixedUBDict = orderUserBit(userBitDict)
|
||||||
metadataDict = applyMetadataDict(fixedUBDict)
|
metadataDict = applyMetadataDict(fixedUBDict)
|
||||||
takesDict = addTakeNumbers(metadataDict)
|
takesDict = addTakeNumbers(metadataDict)
|
||||||
final = addGoodKey(takesDict)
|
final = addGoodKey(takesDict)
|
||||||
print(final)
|
|
||||||
fileNames = makeFileNameDict(final)
|
fileNames = makeFileNameDict(final)
|
||||||
filePaths = setFilePath(fileNames)
|
filePaths = setFilePath(fileNames)
|
||||||
copyFiles(filePaths)
|
copyFiles(filePaths)
|
||||||
print(filePaths)
|
|
||||||
generateResolveCsv(filePaths, "./out.csv")
|
generateResolveCsv(filePaths, "./out.csv")
|
||||||
|
|||||||
Reference in New Issue
Block a user