Hi All,
I use Avidemux primarily to adjust the audio in bought videos,
I keep the original source video format "mp4" or what ever else the source is!
which are stored on my Hard Drive.
I don't do this by choice, but by necessity.
I have to keep the volume up, with as much clarity retained in the sound as possible!
I use a script.py that was kindly given to me.
I find the script slow when doing multiple videos at once.
I was hoping someone could take a look at the script and
advise me if it could it could be optimized to speed up the process?
I do have a "Nvidia geforce graphic card" in the PC.
I don't know if this has any value to the question I am asking ?
Thank you.
_____________________
Here is my Script.py:
_____________________
#PY <- Needed to identify #
#
ui = Gui()
adm = Avidemux()
ext = "mp4"
sep = "\\"
#
# Function to convert an individual video
#
def convert(filein,out):
if not adm.loadVideo(filein):
ui.displayError("oops","cannot load "+filein)
return 0
adm.videoCodec("Copy")
if adm.audioTracksCount() > 0:
adm.audioClearTracks()
adm.audioAddTrack(0)
adm.audioCodec(0, "FDK_AAC", "bitrate=192", "afterburner=True", "profile=2", "sbr=False")
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
adm.audioSetNormalize2(0, 2, 90, -30)
adm.setContainer("MKV", "forceAspectRatio=False", "displayWidth=1280", "displayAspectRatio=2", "addColourInfo=False", "colMatrixCoeff=2", "colRange=0", "colTransfer=2", "colPrimaries=2")
filename = (splitext(filein))[0]
filename += ".mp4"
filename = basename(filename)
return adm.save(out + sep + filename)
#
# Main
#
# -------- select extension --------
extensions = ["mp4","avi","m2ts","mkv","mov","mp4","mpg","ts","vob","webm","wmv"]
mx = len(extensions)
menuExt = DFMenu("Select extension:")
for entry in range(0, mx):
menuExt.addItem(extensions[entry])
dia = DialogFactory("Filter directory content")
dia.addControl(menuExt)
if not dia.show():
return
idx = menuExt.index
if idx < 0 or idx >= mx:
ui.displayError("Oops", "Internal error: invalid menu index")
return
ext = extensions[idx]
# -------- select input directory --------
inputFolder = ui.dirSelect("Select source folder")
if inputFolder is None:
ui.displayError("Oops", "No source folder selected")
return
# -------- read content --------
list = get_folder_content(inputFolder, ext)
if list is None:
ui.displayError("Oops", "No " + ext + " files found in \"" + inputFolder + "\"")
return
# -------- select output directory --------
outputFolder = ui.dirSelect("Select output folder")
if outputFolder is None:
ui.displayError("Oops", "No output folder selected")
return
if(inputFolder == outputFolder):
ui.displayError("Error","Output folder cannot be the same as the input one")
return
# -------- process --------
total = 0
counter = 0
for i in list:
total += 1
counter += convert(i, outputFolder)
if not counter:
ui.displayInfo("Warning", "No files converted")
return
if counter == 1:
ui.displayInfo("Finished", "One file out of " + str(total) + " converted")
return
ui.displayInfo("Finished", str(counter) + " files out of " + str(total) + " converted")
Quote from: pulsarstar on January 09, 2022, 12:55:27 PMadm.videoCodec("Copy")
You use copy mode for video, no (real) encoder is faster than stream copy. Only copy mode preserves quality without inflating video stream size.
If the FDK_AAC audio encoder is too slow for you, you could use FAAC at cost of worse quality and spectral band replication (so-called "HE-AAC") being unavailable.
Quote from: pulsarstar on January 09, 2022, 12:55:27 PMadm.setContainer("MKV", "forceAspectRatio=False", "displayWidth=1280", "displayAspectRatio=2", "addColourInfo=False", "colMatrixCoeff=2", "colRange=0", "colTransfer=2", "colPrimaries=2")
filename = (splitext(filein)) filename += ".mp4"
Are you aware that you save an MKV file with ".mp4" as filename extension?
Thank you, eumagga0x2a, for your advice.
If I have the best audio output?
I will stick with that.
Faster output but poorer quality audio is not what I am looking for.
I have multiple custom.py scripts.
I play around with the script to teach myself,
as I am very much a novice in scripting.
Thank you for bringing to my attention that
I had introduced an unwanted
Error into my script.