Avidemux Forum

Avidemux => Windows => Topic started by: Rykeer on October 26, 2019, 12:24:24 AM

Title: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 12:24:24 AM
Hi Everyone,

I've been working on a script that will allow me to select the folder with videos that I need to convert from the gui and then save them into that folder with adjusted filenames.  After I select the folder, I get the following error:

Assert failed :ref<_segments.getNbRefVideos() at line 692, file F:\jenkins\workspace\VS2015_2.7.4_support\avidemux\common\ADM_editor\src\ADM_edRender.cpp
The application has encountered a fatal problem
The current editing has been saved and will be reloaded at next start

Here's the script that I'm trying to use:


#
# Load all the files in selected folder with .avi.
# That's it.
#
gui = Gui()
adm = Avidemux()
ext = "avi"
sep = "\\"
#
def convert(filein): 
filename = basename(filein)
dir = dirname(filein)
adm.clearSegments()
adm.addSegment(0, 0, 1230240000)
adm.markerA = 0
adm.markerB = 1230240000
adm.setPostProc(3, 3, 0)
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"unknown")
adm.audioAddTrack(0)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280", "displayAspectRatio=0")
adm.save(dir + sep + "Fixed" + filename)
   
#
# 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")



Also, I'm using Avidemux 2.7.5 - Release
Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 11:31:29 AM
You must loadVideo() before you can addSegment()
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 04:33:17 PM
Thanks for that.  I was following a youtube video and forgot that was there.  I'm just trying to fix .avi files that are all have problems with the .avi index.  Works perfectly when I do files one at a time manually, all I have to do is open the file and then click save using the defaults.  I've adjusted the script, but I'm still having a couple of errors.  The first is:

Question
Cut points could not be checked.  This indicates an issue with a source video, the state of editing or a bug in the program.  Please check the application log file or console output for details.
Try anyway?

(I'm guessing that might have to do with the avi index problem with the files, although, I don't get that when I load the videos manually. )

No matter which option I choose at that point, yes or no, it then crashes with the following error:

Assert failed :0 at line 340, file F:\jenkins\workspace\VS2015_2.7.4_support\avidemux\common\ADM_editor\src\ADM_segment.cpp

The application has encountered a fatal problem
The current editing has been saved and will be reloaded at next start


Here's the edited script file:

#
# Load all the files in selected folder with .avi.
# That's it.
#
gui = Gui()
adm = Avidemux()
ext = "avi"
sep = "\\"
#
def convert(filein): 
filename = basename(filein)
dir = dirname(filein)
adm.setPostProc(3, 3, 0)
adm.videoCodec("Copy")
adm.audioCodec(0, "copy");
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280", "displayAspectRatio=0")
adm.save(dir + sep + "Fixed" + filename)
   
#
# 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")
Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 04:58:36 PM
I don't see where you loadVideo() in your new version of the script. This is the reason for the crash.

Regarding cut points check, is the video stream H.264? If yes, did you allow Avidemux to reconstruct timestamps?

To repair (to rebuild) AVI index, I'd recommend using MPlayer. By the way, Avidemux can't load an AVI with the index missing.
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 05:12:48 PM
I'm attempting to fix all the videos in a folder, so how would I tell it to load all of them?

Also, I'm just attempting to fix the "broken" avi index, as VLC says.  I know I could use mplayer, but I'd just like to keep from installing yet another video player, since I really do like VLC. (Unless of course mplayer would fix it permanently, for vlc, since VLC has to rebuild every time, and if I stop in the middle of the video and come back, I can't jump ahead to where I left off.)

Avidemux has no problem whatsoever when I do each video manually.  I just open, use the defaults of copy, and save.  It's just that I have a lot of videos to fix, and I'd rather not have to do them one at a time

I don't believe the stream is H.264.  Looking at the codec info in VLC and in Avidemux, it's an old divx codec.

Here's the info from Avidemux of one of the video files:


=====================================================
Video
=====================================================
Codec 4CC: DX50
Image Size: 320 x 240
Aspect Ratio: 1:1 (1:1)
Frame Rate: 25.000 fps
Total Duration: 00:20:25.840

=====================================================
Extra Video Properties
=====================================================
ExtraDataSize: 00

=====================================================
Audio
=====================================================
Codec: MP3
Channels: Stereo
Bitrate: 15963 Bps / 127 kbps
Frequency: 44100 Hz
Total Duration: 00:20:24.433
Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 05:27:04 PM
You could use https://avidemux.org/smif/index.php?topic=16840.15 as a starting point.

I'd probably need to look into admlog.txt from the Avidemux session when the "Cut points can't be checked" warning was triggered to understand why.
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 05:41:37 PM
Here's the youtube video that I was basing my script off.  Although he was appending videos, which I don't need of course.

https://www.youtube.com/watch?v=pxMeIU-ghXY (https://www.youtube.com/watch?v=pxMeIU-ghXY)



And I've attached the admlog.

Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 05:53:52 PM
Thank you, but the log contains zero relevant info as it doesn't originate from a session in which the warning was triggered.

Please read the script suggested by Mean and modify it to suit your needs (like replace re-encoding with copy mode etc.).
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 06:30:44 PM
I'll work on that.  In meantime, that is the log that is opened when I go through the Help menu in Avidemux.  However, I found that if Avidemux crashes, when it's reopened and I tell not to load the crash settings, then that's the log I get.  If I tell it to load the crash settings, then the log is different and I've attached that one now.
Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 06:59:27 PM
I wanted just to trace down the origin of the warning "Cut points could not be checked". This means that you should redo the steps necessary to trigger this popup, decline the question, close Avidemux and provide the log from %localappdata%\avidemux\

If Avidemux crashes, the next start of the program overwrites the log.
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 07:41:37 PM
Okay, I didn't realize it was overwriting, and that it was in a different location.  I've attached that log now.
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 07:46:17 PM
Thank you for all your help.  I think I've got it figured out for the most part.  That script in the link you sent helped.  I was missing the if statement after def convert at the beginning.  The last couple of questions I have are:

1. What command do I need to remove the .avi from a file?  I've got it adding .mkv now, and don't need the .avi.
2. What command do I need in order to save the file into a different directory?

I'm adding my current script for reference.

#
# Load all the files in selected folder with .avi.
# That's it.
#
gui = Gui()
adm = Avidemux()
ext = "avi"
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.audioCodec(0, "copy");
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280", "displayAspectRatio=0")
adm.save(filein + ".converted.mkv")
   
#
# 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")
Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 07:59:15 PM
Thank you for the log, now it is clear that this warning is triggered by the absence of (any) video when you try to save.

Regarding editing filename extensions, please look at https://avidemux.org/smif/index.php/topic,18816.msg87098.html#msg87098
Title: Re: Folder Conversion Script
Post by: Rykeer on October 26, 2019, 09:43:06 PM
Thanks.  That last link looks like it's only for a batch file with ffmpeg.  Is it the same for Avidemux in tinypy?
Title: Re: Folder Conversion Script
Post by: eumagga0x2a on October 26, 2019, 09:49:50 PM
I've mixed up things a little. The idea is to remove double filename extensions with a cmd.exe script (batch script), you will find all the necessary examples in dosdan's postings.