I am trying to convert a .bat file to python, almost everything is working fine, only the compression part is not working, I point out the flags and the path to the "rar.exe", but it's not working at all in the python version. What I need to correct to have the same behavior of the ".bat" version?
Thank you
batVersion.bat
@echo off
setlocal EnableDelayedExpansion
set "FolderBaseName=myFolder"
set "DropBoxFolder=D:\Tests\3.asc\MyDropBox"
set "BaseOutputFolder=D:\Tests\3.asc\TEMP"
for %%I in (*.png) do (
set "slaveName=%%~nI"
set "slaveName=!slaveName:~6!
set "OutputFolder=%BaseOutputFolder%_!slaveName!"
echo !slaveName!
md "!OutputFolder!" 2>nul
for %%J in (*.mp4*) do (
ffmpeg -i "%%~fJ" -i "%%~fI" -filter_complex overlay "!OutputFolder!\%%~nJ.mp4"
)
"C:\Program Files\WinRAR\rar.exe" a -cfg- -ep1 -inul -m5 "%DropBoxFolder%\%FolderBaseName%_!slaveName!" "!slaveName:~6!\*"
rd /S /Q "!OutputFolder!"
)
pause
pythonVersion.py
def processVideos():
FolderBaseName = "myFolder"
DropBoxFolder = "D:\\Tests\\3.asc\\MyDropBox"
BaseOutputFolder = "D:\\Tests\\3.asc\\TEMP"
for img in os.listdir("D:\\Tests\\3.asc"):
if img.endswith(".png"):
slaveName = img.split('.')[0]
OutputFolder = BaseOutputFolder+'_'+slaveName + '\\'
#create tmp folder
if not os.path.exists(OutputFolder): os.makedirs(OutputFolder)
for video in os.listdir("D:\\Tests\\3.asc"):
if video.endswith(".mp4"):
command = [ 'ffmpeg',
'-i', "D:\\Tests\\3.asc\\"+video,
'-i', "D:\\Tests\\3.asc\\"+img,
'-filter_complex', 'overlay',
OutputFolder+'\\'+str(video)]
pipe = subprocess.Popen(command, stdout = subprocess.PIPE) #, bufsize=10**8
commandRar = [ 'C:\\Program Files\\WinRAR\\rar.exe',
'a',
'-cfg-',
'-ep1',
'-inul',
'-m5',
DropBoxFolder+'\\'+FolderBaseName+'_'+slaveName]
# this doesnt work, and also I only want it to happen after the conversion above has finished
pipeRar = subprocess.Popen(commandRar, stdout = subprocess.PIPE)
processVideos()