News:

--

Main Menu

TinyPy Script help

Started by Nukkels, October 15, 2025, 10:01:10 AM

Previous topic - Next topic

Nukkels

Unfortunately, the wiki is woefully out of date, so I could use some help for a current script to batch remux mkv files to mp4. I've managed to find one script that works as is, but it just concatenates the new file extension, leaving the files all named .mkv.mp4

None of the usual python methods to remove characters works (apparently I can't give examples because it gets blocked by the anti-spam) because I assume most of the these libraries are not included in TinyPy. Is there any way to do this, and if so, how?

eumagga0x2a

You can either work with Python string slicing or use the built-in scripting function splitext(str infile) as following:

fullPathFilenameWithoutExtension = (splitext(infile))[0]
For example, when using slicing:

adm = Avidemux()
ui = Gui()
ext = "mkv"
sep = "\\"

def remux(filein, outdir):
    if len(filein) < 4:
        return 0
    if filein[-4] != ".":
        return 0
    if not adm.loadVideo(filein):
        ui.displayError("Oops","Cannot load " + filein)
        return 0

    adm.videoCodec("Copy")
    adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0", "clockfreq=0")

    filename = filein[:-3]
    filename += "mp4"
    filename = basename(filename)
    return adm.save(outdir + sep + filename)

# select input directory
inputFolder = ui.dirSelect("Select source folder")
if inputFolder is None:
    ui.displayError("Oops", "No source folder selected")
    return

# read content
vlist = get_folder_content(inputFolder, ext)
if vlist 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

total = 0
counter = 0

for vid in vlist:
    total += 1
    counter += remux(vid, outputFolder)

if not counter:
    ui.displayInfo("Warning", "No files remuxed")
    return

if counter == 1:
    ui.displayInfo("Finished", "One file out of " + str(total) + " remuxed")
    return

ui.displayInfo("Finished", str(counter) + " files out of " + str(total) + " remuxed")