Avidemux Forum

Avidemux => Windows => Topic started by: leedog99 on October 16, 2019, 10:14:37 AM

Title: windows v2.7.5 tinypy - muxer cannot open
Post by: leedog99 on October 16, 2019, 10:14:37 AM
When I run a PY script to convert an MVK to MP4, it opens the local MKV file fine, but then get MUXER CANNOT OPEN error. Clicking SAVE works fine.
I have attached my log and script. Im guessing something to do with the error, "...Video has extradata and muxer requires globalHeader, assuming it is done so."
WIN 10 Home
Title: Re: windows v2.7.5 tinypy - muxer cannot open
Post by: eumagga0x2a on October 16, 2019, 08:25:08 PM
Quote from: leedog99 on October 16, 2019, 10:14:37 AM
Im guessing something to do with the error, "...Video has extradata and muxer requires globalHeader, assuming it is done so."

This is not an error but a general purely informational message, completely unrelated to the problem.

Your script tries to save output to the source file, which obviously can't work. On a non-Windows platform, this would destroy the source file, but file locking on Windows prevents dataloss and the fatal flaw in the script results just in a failure due to inability to write to the specified output (which is here identical with the input).
Title: Re: windows v2.7.5 tinypy - muxer cannot open
Post by: leedog99 on October 16, 2019, 08:44:24 PM
I had this before for the save line:
adm.save(filename)
same MUXER CANNOT OPEN error.
Title: Re: windows v2.7.5 tinypy - muxer cannot open
Post by: eumagga0x2a on October 17, 2019, 12:25:07 AM
adm.save(filename) would have been wrong too as the basename of $filein needs a directory for save() to succeed, a directory different from $dir (I denote variables here with "$" like in bash scripts for legibility).

It should work with


#PY  <- Needed to identify #

ext = "mkv"
gui = Gui()
adm = Avidemux()

def convert(filein):
    if (0 == adm.loadVideo(filein)):
        gui.displayerror("oops, cannot load " + filein)
        raise
    adm.videoCodec("Copy")
    adm.audioClearTracks()
    adm.setSourceTrackLanguage(0,"eng")
    adm.audioAddTrack(0)
    adm.audioCodec(0, "copy");
    adm.audioSetDrc(0, 0)
    adm.audioSetShift(0, 0, 0)
    adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0")
    adm.save(filein + ".mp4")
    print("Done")

# Main
InputFolder = gui.dirSelect("Select the Source Folder")
list = get_folder_content(InputFolder,ext)
if(list is None):
    raise
for i in list:
    convert(i)
print("Done")


but, of course, the double extension "mkv.mp4" is not pretty and should be treated as well.
Title: Re: windows v2.7.5 tinypy - muxer cannot open
Post by: leedog99 on October 17, 2019, 10:34:21 AM
I have searched for hours, no luck. Any suggestion on how to remove the .MKV from the file name so the saved name is clean?
Title: Re: windows v2.7.5 tinypy - muxer cannot open
Post by: eumagga0x2a on October 17, 2019, 11:14:20 AM
You should browse posts by the user "dosdan" here.

A brief internet search points to https://superuser.com/questions/1120795/how-to-batch-remove-a-duplicate-file-extension-in-os as a possible solution.