View Full Version : merge/join multiple avi from command line?
sebus
9th July 2010, 23:44
I have 1000+ folders with 3 - 20 avi files in each
They are the whole avi, so I can not just copy /b them
And I need to join content of each folder into single avi file (so I lend up with just 1000+ playable files)
mencoder works fine, but does NOT accept path with wildcard input.
This works fine (must be run from the folder where the files are:
mencoder -forceidx -ovc copy -oac copy -o fullfile.avi *.avi
But this will NOT work:
mencoder -forceidx -ovc copy -oac copy -o fullfile.avi c:\video\*.avi
Anybody know a way to do it from a batch file?
Thanks
sebus
mariush
10th July 2010, 03:07
I wrote my own small VB app for that. The app allows me to select a folder and for the avi files in it, it generates a Virtualdub jobs file (basically a script telling virtualdub to do something) . I then open the jobs file in Virtualdub and virtualdub would run the script. It could be easily modified to do the jobs file for all the folders.
By the way, if the avi files inside the folder are named properly.. for example Video 1.avi, Video 2.avi, ... , Video 10.avi, when you open Video 1.avi Virtualdub will automatically append the other videos to it. So you can select Direct Stream Copy for video and audio and save the avi with a different name and you'll get the full video file.
sebus
10th July 2010, 07:47
That is fine for opening 1, 2, 5, 10 folders
But for 1000+ I would just go mad at some point, hence I am hoping for an automated way (batch file)
The files are named with filename-x.avi where x is increasing number
sebus
pc_speak
15th July 2010, 06:42
Edit:.........
Did a quick test and changed the code.
Perhaps something like this.
for /F "delims=" %%a in ('dir /b/ad') do cd "%%a" && call :start_process
goto end
:start_process
c:\prog\mencoder -forceidx -ovc copy -oac copy -o fullfile.avi *.avi
cd..
goto :eof
:end
Directory structure like this:-
c:\video\
batch.cmd
c:\video\avi files\
vid-1.avi
vid-2.avi
vid-3.avi
c:\video\more avi\
vid-1.avi
vid-2.avi
vid-3.avi
vid-4.avi
c:\video\yet more avis\
vid-1.avi
vid-2.avi
etc.
vid-20.avi
:)
sebus
17th July 2010, 09:44
In fact what mencoder needs is (batch file join.cmd below copied to each folder "avi files", "more avi" "yet more avis"
with following command:
FOR /R g:\ %A IN (join.cmd) DO copy G:\join.cmd "%A" :
@echo off
echo This is join.cmd
PUSHD %~dp0
@echo off&setlocal enableextensions
:: retrieving name of current directory
for %%* in (.) do set MyDir=%%~n*
:: adding safety factor for no directory, i.e a drive
if not defined MyDir set MyDir=%CD:\=%
:: telling you what it is
echo/ the current directory is %MyDir%
::endlocal&goto :eof
##The name of the output files comes from the folder in which the split files existed
c:\windows\mencoder.exe -forceidx -oac copy -ovc copy -o "l:\outputfolder\%MyDir%.avi" *.avi
Then just run from command prompt (hence the single %):
g:\FOR /R %a IN (join.cmd) DO %a
The only problem is that when mencoder encounters a file that is somehow different & can not join, it just quits without giving any indication what file it was
sebus
pc_speak
19th July 2010, 20:12
I see.
My way: One batch file - run once.
cd to avi folder, run mencoder, cd back to parent folder.
cd to next avi folder, run mencoder, cd back to parent folder.
etc.
etc.
We get the same result. :D
Maybe you could do:
c:\windows\mencoder.exe -forceidx -oac copy -ovc copy -o "l:\outputfolder\%MyDir%.avi" *.avi && if not errorlevel 0 echo Failed %MyDir% >> l:\outputfolder\mencoder.log
Won't tell you what went wrong, but at least you'll know which.
Cheers.
sebus
23rd July 2010, 20:33
Yes, but you have hardcoded fullfile.avi (where would it get the correct name from?)
But I will add the errorlevel check, thanks
sebus
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.