adm = Avidemux()
ed = Editor()
ui = Gui()
mx = 99999
pad = "00000"
def zeropad(nb):
c = int(nb)
if c < 0 or c > mx:
return "invalid"
if not c:
return pad
a = 0
while c > 0:
a += 1
c = int(c/10)
return pad[a:] + str(nb)
if not ed.nbSegments():
ui.displayError("No video", "Please load a video prior to running this script")
return 0
start = adm.markerA
end = adm.markerB
if start > end:
swap = end
end = start
start = swap
if not adm.setCurrentPts(start):
ui.displayError("Seek error", "Cannot seek to the start of the selection")
return 0
outfile = ui.fileWriteSelectEx("Select output filename", "png")
if outfile is None:
return 0
count = 0
fileNameNoExtension = (splitext(outfile))[0]
while True:
if ed.getCurrentPts() >= end:
break
if not adm.savePng(fileNameNoExtension + "-" + zeropad(count) + ".png"):
break
count += 1
if count > mx:
break
if not adm.seekFrame(1):
break
if not count:
ui.displayError("Error", "No PNG images saved")
return 0
ui.displayInfo("Finished", str(count) + " PNG images saved")
return count
@echo off
if not exist "reverse" mkdir reverse
del /Q "reverse\*"
SETLOCAL EnableDelayedExpansion
set /A var=10000
for /f "tokens=*" %%s in ('dir /b *.png ^| sort') do (
echo f | xcopy /f /y %%s reverse/!var!.png
set /A var-=1
)
del "reverse\10000.png"
pause
def next_file_name():
num = 1
while True:
file_name = '%d' % num
if not os.path.exists(file_name):
return file_name
num += 1
while True:
pts = ed.getCurrentPts()
if pts >= end:
break
if not adm.savePng(next_file_name + ".png"):
break
count += 1
if not adm.seekFrame(1):
break