August 14, 2020, 01:40:46 pm

News:

--


Folder Conversion Python Script Issue

Started by dramedev, July 10, 2020, 05:02:48 am

Previous topic - Next topic

dramedev

Hi,

I am trying to write a Python script for folder conversion from .mkv to .mp4. Using the examples in Youtube and wiki, I have come up with the following. However when I actually run it the video does not get loaded and I get an exception. I seem to be missing something really basic here. Any suggestions? 
 
#
# Load all the files in selected folder with .mkv.
#
gui = Gui()
adm = Avidemux()
ext = "mkv"
sep = "\\"


#
def convert(filein):

if(0 == adm.loadVideo(filein)):
ui.displayError("oops","cannot load "+filein)
raise
filename = basename(filein)
dir = dirname(filein)
adm.setPostProc(3, 3, 0)
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"")
adm.audioAddTrack(0)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True", "forceAspectRatio=False", "aspectRatio=1", "rotation=0")
adm.save(filein + "-conv.mp4")
print("Done")


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")

eumagga0x2a

The script works for me as-is with a .mkv video which I know that it can be successfully loaded.

If the folder doesn't contain a .mkv file or if loading fails, the script tells Avidemux to trigger an exception (it could do something less rude instead). So the first thing to clarify is the question whether the list comes back empty or loading the video fails.

dramedev

Oops. I think there was a folder security issue.  :-[  The script does work as is. Woohoo!  8)

dramedev

Scrap that too! The real issue was that the files I was using it on could not be opened by Avidemux for some weird reason (although I can open them using VLC).  >:(
When I tried on a different set of files, the script worked.  ???

eumagga0x2a

Assuming you use Windows: please start Avidemux afresh, load one of these files which fail to load, close Avidemux, compress (zip or 7z) and attach the admlog.txt from %localappdata%\avidemux\ to your reply.

Obviously, using the latest version of Avidemux is required.

dramedev

Quote from: eumagga0x2a on July 10, 2020, 09:39:23 am
Assuming you use Windows: please start Avidemux afresh, load one of these files which fail to load, close Avidemux, compress (zip or 7z) and attach the admlog.txt from %localappdata%\avidemux\ to your reply.

Obviously, using the latest version of Avidemux is required.


Attached.

eumagga0x2a

You use 2.7.3, current is 2.7.6. Please update and re-test.

dramedev