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.

User007

#2
Sorry if i hijack your thread, i need to do exactly the same convert bunch of .mts files (H264 - MPEG-4 AVC (part 10) (h264)) to .mp4 container using command line.

Right now i am using following code i found online, it works.

avidemux_cli.exe --video-codec "copy" --audio-codec "copy" --force-alt-h264 --load "myfile.mts" --save "myfile.mp4" --quit
How can tell Avidemux to not create (useless?) .idx2 files when batch processing?

What is "--force-alt-h264" i know its "Force use of alternate safe read mode for h264 video.", but what does it mean exactly?

eumagga0x2a

"--force-alt-h264" is an invalid option, removed over a decade ago from Avidemux, ignored.

Creation of index files for MPEG-TS files cannot be suppressed. If they bother you, add a command (unrelated to Avidemux) to your cmd.exe script to delete them all in one go or just those created by Avidemux during processing.

User007

#4
0. FYI "--force-alt-h264" still listed in Wiki, perhaps its outdated.

1. Do i need to specify --output-format "MP4" to save as this container type or simply using file extension mp4 --save "myfile.mp4" will set the correct container?


2. Another problem i run into when converting from MKV to AVI i am getting warning in command line.

Question
 Bad Idea
 Using H264/H265 in AVI is a bad idea, MKV is better for that.
 Do you want to continue anyway ?

Yes or No (Y/y or N/n)

Is there way to suppress this warning, this ruins whole point of batch processing if i have to press "Y" for every file.

3. Right now i am using FOR loop in .bat file with command i showed in post above, however this loads and unloads AviDemux for every file, is there way to load one time and then just pass many video files to it before it AviDemux close or specify more than one file in command line?

User007


eumagga0x2a

0: Yes, please ignore the Wiki.

1: The former. No format guessing based on output filename extension is performed.

2: Please try option --nogui. Putting H.264 or HEVC in AVI is indeed an awful idea. Don't do it except of when on gun point.

3: Just use a project script like the thread opener.