Hi, and i'm a cat
and even though.
I try to do a batch file that concatenate using ffmpeg all the .mp4 in a directory, but first have to analize all the files parsed to verify is all the files have:
the same resolution
the same framerate
the same codec
the rotation flag
At the moment I have build this code that simply concatenate all the .mp4 except for the final concatenated one (using fart.exe to delete the output file from the list of files to be concatenated)
supposing in a folder are present 120.mp4 121.mp4 122.mp4 123.mp4, the batch have to concatenate all in one unique conCAT.MP4.Code:@Echo Off color 6 if exist concatList.txt del concatList.txt setlocal for %%f in (*.mp4) do echo file '%cd%\%mypath%%%f' >> "concatList.txt" fart.exe concatList.txt "file '%cd%\conCAT.MP4'" --remove endlocal ffmpeg64bit_2019.exe -y -threads 12 -y -f concat -safe 0 -i concatList.txt -map 0:? -ignore_unknown -vcodec copy -acodec copy -aspect 16:9 conCAT.MP4 if exist concatList.txt del concatList.txt exit
In this case, for example, concatlist.txt become
But only if they have the same resolution the same framerate the same codec the rotation flag... if they are identical. How can I do thanksCode:file 'C:\Users\Administrator\Desktop\Loris\120.mp4' file 'C:\Users\Administrator\Desktop\Loris\121.mp4' file 'C:\Users\Administrator\Desktop\Loris\122.mp4' file 'C:\Users\Administrator\Desktop\Loris\123.MP4'
+ Reply to Thread
Results 1 to 8 of 8
You can use MediaInfo to get this info:
MediaInfo.exe file.mp4 > file.txt
PS: this can help https://stackoverflow.com/questions/41231998/mediainfo-cli-command-line-interface-synt...e-once-for-all
Last edited by CDK; 31st Jul 2022 at 09:31.
an idea to start would be
@Echo Off color 6 if exist concatList.txt del concatList.txt if exist %cd%\conCAT.MP4 del %cd%\conCAT.MP4 setlocal for %%f in (*.mp4) do echo file '%cd%\%mypath%%%f' >> "concatList.txt" fart.exe concatList.txt "file '%cd%\conCAT.MP4'" --remove for /f "delims=" %%F in ('dir *.MP4 /b /o-n') do set FirstFile="%cd%\%%F" echo 1st file is %FirstFile% pause mediainfo.exe %FirstFile% dumpinfo:unicodefile.txt TYPE unicodefile.txt>mediainfo.txt rem ********* IF exist unicodefile.txt DEL unicodefile.txt IF exist mediainfo.txt DEL mediainfo.txt endlocal ffmpeg64bit_2019.exe -y -threads 12 -y -f concat -safe 0 -i concatList.txt -map 0:? -ignore_unknown -vcodec copy -acodec copy -aspect 16:9 conCAT.MP4 if exist concatList.txt del concatList.txt exit
%FirstFile% assume 120.mp4 as first file.
Mediainfo should parse %FirstFile% and store resolution, framerate, rotation and codec info and compare the info with all other .mp4 to verify if all the .mp4 files are concatenable
If the files do not have the same characteristics, the batch returns an error and exits. If they are similar it continues in the concatenation process.
Really it would be perhaps interesting that if the batch finds a rotated file (for example by 90 °) it is first remuxed as straight and then concatenated, but this is already another question)
#24 input and further there are some subroutines that you can use:
but for all kids out there, if deciding to make some codes to automatize processes, do not do this using microsoft batch code, use python instead
interesting batch, even if at the moment I don't seem to find something that exactly compares the metadata of several files one with the others. In practice it would be a question of comparing if the resolution-framerate-idcodec-rotation of all the files present in a folder are exatly the same. If anyone wants to help the cat
you have a subroutine that gives you w, h, fps (add codec and rotation) of the first file, save them to different variables
then run that subroutine for each file and if file does not have the same values as those in first file, do not add them in the list
thanks but a litte complicated for a cat-brain
however I would like to do another thing, if someone helps me: we still consider the original batch. When I run the batch inside a folder that contains some .mp4 files it generate a final file called concat.txt which contains the names of the individual .mp4 files. But now I need to generate also a concat.txt of the only file drag and dropped to the batch. In this case how should I modify the batch?