Emulgator
23rd January 2022, 03:41
I thought I could help some good souls searching for a batch muxing function and here comes the first .bat:
In-place folder batchmuxing of .mp4 and .ac3 files into .m2ts
set tsmuxerpath="C:\_PROG\! Multiplexers\w64-nightly-2022-01-15--02-09-45\tsMuxeR.exe"
for /f %%a in ('dir /b *.mp4') do call :make_ts "%%a"
echo FOLDER MUXING FINISHED ! & pause
goto :eof
:make_ts
set metaFile=".\00.meta"
set tsCommand1=MUXOPT --no-pcr-on-video-pid --new-audio-pes --hdmv-descriptors --vbr --vbv-len=500 --fps=50
set tsCommand2=V_MPEG4/ISO/AVC
set tsCommand3=insertSEI, contSPS, track=1, lang=und
set tsCommand4=A_AC3, "%~dpn1.ac3"
echo %tsCommand1%> %metaFile%
echo %tsCommand2%, "%~dpn1.mp4", %tsCommand3%>> %metaFile%
echo %tsCommand4%>> %metaFile%
%tsmuxerpath% "%metaFile%" new_%~n1.m2ts
goto :eof
exit
REM Emulgator's tsMuxeR .m2ts batch muxing script 2022 01 23
REM This script is made for folder batch muxing of paired & matching .mp4 files with their accompanying .ac3 files into .m2ts files
REM This script assumes input naming convention in typical 5 figure-pairs 00000.mp4 + 00000.ac3, 00001.mp4 + 00001.ac3...
REM Rename your files accordingly using ReNamer or Flexible Renamer or whatever you may prefer.
REM Pull these pairs of .mp4 and .ac3 files to be muxed into one working folder.
REM Put this batch file into that working folder, because /b assumes the batch file's directory !
REM Set variable "tsmuxerpath" to the path to your system's tsmuxer.exe
REM Edit the other parameters to fit your needs.
REM It helps to pull your source files onto tsMuxeRGUI and see what .meta will be generated, my .mp4 worked with track=1
REM new_%~n1.m2ts will generate muxfilenames with the prefix new_, so new_00000.m2ts, new_00001.m2ts...
REM Overwrites any colliding files with same names without asking !
REM Doubleclick .bat file (or mark .bat file and press "Enter")
REM A progress window pops up and tsMuxeR batchmuxes 150 files (60GB worth) within 120s on a SSD.
REM After batch muxing has finished the last instance of that 00.meta file will stay in the working folder, this can be inspected, then deleted.
REM The mask *.mp4 will search for all .mp4 files and make a temporary .meta file for each mux from .mp4
REM metaFile "00.meta" will be the variable meta file where muxing parameters stay constant, only input files and output files are incremented per mux.
REM make_ts is a function definition
REM The single > populates the following variable metafile (overwriting), the double >> appends
REM meta-peculiar: new_%~n1.m2ts makes a file, "new_%~n1.m2ts" makes a folder and demuxes !
REM filenameWithoutExtension=%~dpn1 (dpn=drivepathname)
REM filename.extension=%~nxf
REM originalfilename=%a | nameoffileonly=%~na | extensiononly=%~xa
REM Two colons mark that line to be interpreted as comment, but that has limitations: some forbidden symbols.
REM REM works too to mark a comment line, but that has limitations: some forbidden symbols.
REM Comments after EXIT are safe ! These comments here broke the script and I was searching why...
REM Me too ! I have to learn batch scripting from scratch. X-}
Copy, paste & modify, (description inside), rename extension to .bat and run.
Partner script (In-place folder batch-demuxing of AVC-containing .mp4 files) here:
https://forum.doom9.org/showthread.php?p=1965047
In-place folder batchmuxing of .mp4 and .ac3 files into .m2ts
set tsmuxerpath="C:\_PROG\! Multiplexers\w64-nightly-2022-01-15--02-09-45\tsMuxeR.exe"
for /f %%a in ('dir /b *.mp4') do call :make_ts "%%a"
echo FOLDER MUXING FINISHED ! & pause
goto :eof
:make_ts
set metaFile=".\00.meta"
set tsCommand1=MUXOPT --no-pcr-on-video-pid --new-audio-pes --hdmv-descriptors --vbr --vbv-len=500 --fps=50
set tsCommand2=V_MPEG4/ISO/AVC
set tsCommand3=insertSEI, contSPS, track=1, lang=und
set tsCommand4=A_AC3, "%~dpn1.ac3"
echo %tsCommand1%> %metaFile%
echo %tsCommand2%, "%~dpn1.mp4", %tsCommand3%>> %metaFile%
echo %tsCommand4%>> %metaFile%
%tsmuxerpath% "%metaFile%" new_%~n1.m2ts
goto :eof
exit
REM Emulgator's tsMuxeR .m2ts batch muxing script 2022 01 23
REM This script is made for folder batch muxing of paired & matching .mp4 files with their accompanying .ac3 files into .m2ts files
REM This script assumes input naming convention in typical 5 figure-pairs 00000.mp4 + 00000.ac3, 00001.mp4 + 00001.ac3...
REM Rename your files accordingly using ReNamer or Flexible Renamer or whatever you may prefer.
REM Pull these pairs of .mp4 and .ac3 files to be muxed into one working folder.
REM Put this batch file into that working folder, because /b assumes the batch file's directory !
REM Set variable "tsmuxerpath" to the path to your system's tsmuxer.exe
REM Edit the other parameters to fit your needs.
REM It helps to pull your source files onto tsMuxeRGUI and see what .meta will be generated, my .mp4 worked with track=1
REM new_%~n1.m2ts will generate muxfilenames with the prefix new_, so new_00000.m2ts, new_00001.m2ts...
REM Overwrites any colliding files with same names without asking !
REM Doubleclick .bat file (or mark .bat file and press "Enter")
REM A progress window pops up and tsMuxeR batchmuxes 150 files (60GB worth) within 120s on a SSD.
REM After batch muxing has finished the last instance of that 00.meta file will stay in the working folder, this can be inspected, then deleted.
REM The mask *.mp4 will search for all .mp4 files and make a temporary .meta file for each mux from .mp4
REM metaFile "00.meta" will be the variable meta file where muxing parameters stay constant, only input files and output files are incremented per mux.
REM make_ts is a function definition
REM The single > populates the following variable metafile (overwriting), the double >> appends
REM meta-peculiar: new_%~n1.m2ts makes a file, "new_%~n1.m2ts" makes a folder and demuxes !
REM filenameWithoutExtension=%~dpn1 (dpn=drivepathname)
REM filename.extension=%~nxf
REM originalfilename=%a | nameoffileonly=%~na | extensiononly=%~xa
REM Two colons mark that line to be interpreted as comment, but that has limitations: some forbidden symbols.
REM REM works too to mark a comment line, but that has limitations: some forbidden symbols.
REM Comments after EXIT are safe ! These comments here broke the script and I was searching why...
REM Me too ! I have to learn batch scripting from scratch. X-}
Copy, paste & modify, (description inside), rename extension to .bat and run.
Partner script (In-place folder batch-demuxing of AVC-containing .mp4 files) here:
https://forum.doom9.org/showthread.php?p=1965047