News:

--

Main Menu

How do I batch process

Started by Moe, February 12, 2023, 05:24:53 PM

Previous topic - Next topic

Moe

Hi,

I'm trying to do a very simple batch processing for mp4 files where video output is the same (copy), only audio to be converted to AAC(lav) & output format (mp4 Muxer), the converted files to be saved in a different folder with the same name.I came up with the below script but something is wrong, please help.

#
# Load all the files in c:\tmp with .mp4 extension.
# That's it.
#
ext="mp4"
inputFolder="F:\\Video\\"
#
def convert(filein):   
    if(0 == adm.loadVideo(filein)):
        gui.displayError("oops","cannot load "+filein)
        raise
adm.setHDRConfig(1, 1, 1, 1, 0)
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")
if adm.audioTotalTracksCount() <= 0:
    raise("Cannot add audio track 0, total tracks: " + str(adm.audioTotalTracksCount()))
adm.audioAddTrack(0)
adm.audioCodec(0, "LavAAC")
adm.audioSetDrc2(0, 0, 1, 0.001, 0.2, 1, 2, -12)
adm.audioSetEq(0, 0, 0, 0, 0, 880, 5000)
adm.audioSetChannelGains(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
adm.audioSetChannelDelays(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
adm.audioSetChannelRemap(0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8)
adm.audioSetShift(0, 0, 0)
adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "displayWidth=1280", "rotation=0", "clockfreq=0")
adm.save("F:\\Vid\\")
print("Done")
 
#
# Main
#
gui=Gui()
adm=Avidemux()
#
list=get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
        convert(i)
print("Done")




I don't have much experience with such scripts, it's my first time actually so please make it simple.

Regards.



eumagga0x2a

You use adm which is not defined. You need to set adm to Avidemux():

adm = Avidemux()
I think also that adm.save() needs the full path inkl. output filename as argument, not just the directory.