Browser view only. Use the download link if you want to save the file.
Back to Toolbox@echo off
goto afterdocs
:: Revision History
::
:: 03/25/22 - added help screens at each prompt, and made it loop back to question if chosen
:: 04/03/22 - beefed up file stats to show stats for all files passed in, not just first. Gotta catch awful sets from West Texas shooters...
:: 04/05/22 - added prompt for aspect, mostly to have a quick crop sides option that I don't have in other tools
:: 04/22/22 - Added "-select_streams v:0" to all FFprobe checks to not catch subtitles with 1920 width throwing off comparisons (and in videoinfo.bat too)
:: 04/28/22 - Fixed the oops of no jump label when aspect NONE passed in for automated use
:: 04/29/22 - Unhid the countdown for the 9sec delay before starting
:: 05/12/22 - Added CLS to front of help screens
:: 06/03/22 - Added support for makemp4.copyaudio to copy source audio as-is with no re-encode (internet movies)
:: - added jump to Q0 to allow aspect choice and not force 16x9
:: 06/05/22 - Added support for 2.21 aspect passed in from batch in auto mode, and a prompt choice for it too
:: 08/29/22 - Added crf08 choice (keystroke only) for my own silly uses
:: 01/28/23 - Added support for timecode on screen with %timecode% and %datecode% variables
:: Reference line : -vf "drawtext=fontfile=/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: text='%{localtime\:%T}': fontcolor=white@0.8: x=7: y=700"
:: 06/18/23 - Added buffix variable to get around weird failures converting West Texas videos
:: 11/14/23 - Added a brightfix variable to apply curve brightening for a Nora fix. To enable, use "set makeMP4.brightfix=Yes" in the calling batch file
:: 04/24/24 - Expanded brightfix to use 1,2 (1=curves, 2=custom) and a warning and B1 in filename. Added text file w/ settings
:: 06/25/24 - Added depink to brightfix choices, alongside previously undocumented desat one added not long ago
::
:afterdocs
:: First check to see if tools are here
if x%1x == xx goto error1
if not exist ffprobe.exe goto error2
if not exist ffmpeg.exe goto error3
:: check for environment variables to automate
set aspect=
if /i [%makeMP4.aspect%] == [NONE] goto aspectnone
if /i [%makeMP4.aspect%] == [16x9] goto aspect16x9
if /i [%makeMP4.aspect%] == [2.21] goto aspect21
:: not doing 4x3 since it's unlikely we'd ever force that one
goto Q0
:aspect16x9
set aspect=16x9
goto Q0
:aspect21
set aspect=2.21
goto Q0
:aspectnone
set aspect=none
goto Q0
:Q0
set timecode=
set datecode=
rem set timecode=10:05pm
rem set datecode=10/05/2023
rem **** Bright fix for Nora ****
set bext=B0
if /i x%makeMP4.brightfix%x == xNox goto nobright
if /i x%makeMP4.brightfix%x == x0x goto nobright
if /i x%makeMP4.brightfix%x == xx goto nobright
set bext=B%makeMP4.brightfix%
rem Try1 if /i x%makeMP4.brightfix%x == xYesx set brightfix=-vf "curves=preset=lighter, yadif"
rem Hack for Kelly : if bright num is 'U', apply unsharp with all default brightness values
if /i x%makeMP4.brightfix%x == xUx set brightfix=-vf "eq=brightness=0.0:contrast=1.0:saturation=1.0, unsharp"
if /i x%makeMP4.brightfix%x == x1x set brightfix=-vf "curves=preset=lighter, yadif"
if /i x%makeMP4.brightfix%x == x2x set brightfix=-vf "eq=brightness=0.18:contrast=1.20:saturation=1.2, unsharp"
if /i x%makeMP4.brightfix%x == x3x set brightfix=-vf "eq=brightness=0.22:contrast=1.25:saturation=1.2, unsharp"
if /i x%makeMP4.brightfix%x == xdesatx set brightfix=-vf "eq=brightness=0.05:contrast=1.0:saturation=0.75"
if /i x%makeMP4.brightfix%x == xdepinkx set brightfix=-vf "hue=h=020:s=0.98"
if /i x%makeMP4.brightfix%x == xkh1x set brightfix=-vf "hue=h=015:s=0.98, eq=brightness=0.05:contrast=1.0:saturation=0.65"
if /i x%makeMP4.brightfix%x == xUx set bext=U0
echo *** BRIGHTEN %makeMP4.brightfix% IS ON ***
echo Settings written to text file
echo Brightness settings used: %brightfix%
timeout /t 4 >nul
echo Brightness settings used: %brightfix% >"Brightness settings used.txt"
:nobright
cls
echo.%~n0 : Let's convert some videos!
set filename[1]=%~nx1
set filename[2]=%~nx2
set filename[3]=%~nx3
set filename[4]=%~nx4
set filename[5]=%~nx5
set filename[6]=%~nx6
set filename[7]=%~nx7
set filename[8]=%~nx8
set filename[9]=%~nx9
echo.
echo.Hang on a sec while I examine those files...
echo.
:: Sorry this section is so big. Everything I tried to do for looping failed so I just hardcoded it
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "width[1]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "height[1]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "DAR[1]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "samplerate[1]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "duration[1]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "framerate[1]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[1]%" 2^>^&1') do set "codecs[1]=%%I"
if not defined filename[2] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "width[2]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "height[2]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "DAR[2]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "samplerate[2]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "duration[2]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "framerate[2]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[2]%" 2^>^&1') do set "codecs[2]=%%I"
if not defined filename[3] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "width[3]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "height[3]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "DAR[3]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "samplerate[3]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "duration[3]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "framerate[3]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[3]%" 2^>^&1') do set "codecs[3]=%%I"
if not defined filename[4] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "width[4]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "height[4]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "DAR[4]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "samplerate[4]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "duration[4]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "framerate[4]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[4]%" 2^>^&1') do set "codecs[4]=%%I"
if not defined filename[5] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "width[5]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "height[5]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "DAR[5]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "samplerate[5]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "duration[5]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "framerate[5]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[5]%" 2^>^&1') do set "codecs[5]=%%I"
if not defined filename[6] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "width[6]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "height[6]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "DAR[6]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "samplerate[6]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "duration[6]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "framerate[6]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[6]%" 2^>^&1') do set "codecs[6]=%%I"
if not defined filename[7] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "width[7]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "height[7]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "DAR[7]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "samplerate[7]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "duration[7]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "framerate[7]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[7]%" 2^>^&1') do set "codecs[7]=%%I"
if not defined filename[8] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "width[8]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "height[8]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "DAR[8]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "samplerate[8]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "duration[8]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "framerate[8]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[8]%" 2^>^&1') do set "codecs[8]=%%I"
if not defined filename[9] goto afterDARload
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "width[9]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "height[9]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=display_aspect_ratio -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "DAR[9]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "samplerate[9]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries format^=duration -sexagesimal -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "duration[9]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=avg_frame_rate -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "framerate[9]=%%I"
for /F "delims=" %%I in ('ffprobe.exe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%filename[9]%" 2^>^&1') do set "codecs[9]=%%I"
:afterDARload
echo Files to convert :
echo. %~nx1 ( %width[1]%x%height[1]%, %framerate[1]% fps, %DAR[1]% aspect, %samplerate[1]% audio, %duration[1]% )
if x%2x == xx goto endfiles
echo. %~nx2 ( %width[2]%x%height[2]%, %framerate[2]% fps, %DAR[2]% aspect, %samplerate[2]% audio, %duration[2]% )
if x%3x == xx goto endfiles
echo. %~nx3 ( %width[2]%x%height[3]%, %framerate[3]% fps, %DAR[3]% aspect, %samplerate[3]% audio, %duration[3]% )
if x%4x == xx goto endfiles
echo. %~nx4 ( %width[2]%x%height[4]%, %framerate[4]% fps, %DAR[4]% aspect, %samplerate[4]% audio, %duration[4]% )
if x%5x == xx goto endfiles
echo. %~nx5 ( %width[2]%x%height[5]%, %framerate[5]% fps, %DAR[5]% aspect, %samplerate[5]% audio, %duration[5]% )
if x%6x == xx goto endfiles
echo. %~nx6 ( %width[2]%x%height[6]%, %framerate[6]% fps, %DAR[6]% aspect, %samplerate[6]% audio, %duration[6]% )
if x%7x == xx goto endfiles
echo. %~nx7 ( %width[2]%x%height[7]%, %framerate[7]% fps, %DAR[7]% aspect, %samplerate[7]% audio, %duration[7]% )
if x%8x == xx goto endfiles
echo. %~nx8 ( %width[2]%x%height[8]%, %framerate[8]% fps, %DAR[8]% aspect, %samplerate[8]% audio, %duration[8]% )
if x%9x == xx goto endfiles
echo. %~nx9 ( %width[2]%x%height[9]%, %framerate[9]% fps, %DAR[9]% aspect, %samplerate[9]% audio, %duration[9]% )
:endfiles
echo.
:Q1
echo.
:nostats
:: set outpath if used by AutoMP4 before branching by encoding type
set outfolder=.
if /i x%makeMP4.useSourceFolder%x == xYesx goto setfolder
goto Autocheck
:setfolder
set outfolder=%~p1
echo USING OUTPUT FOLDER %outfolder%
timeout /t 3
:Autocheck
:: check for environment variables to automate
if /i x%makeMP4.encoding%x == xAVCx goto avc
if /i x%makeMP4.encoding%x == xHEVCx goto hevc
if /i x%makeMP4.encoding%x == x265x goto hevc
if /i x%makeMP4.encoding%x == x264x goto avc
if /i x%makeMP4.encoding%x == xMP3x goto mp3
if /i x%makeMP4.encoding%x == xMPGx goto mpg
:choice1
echo.
echo.
echo.WHICH ENCODING SETTING?
echo. (A)=AVC/264 ^<-- best for attorneys
echo. (B)=HEVC/265 ^<-- good for archives (MKV file)
echo. (M)=MPEG-1 ^<-- for people stuck in 1994 (480p 1.8mbps)
echo. (3)=MP3 ^<-- audio MP3 for reporters
echo. (H)=Help ^<-- more details
echo. (Q)=Quit
echo.
choice /c qabhm3 /n
if errorlevel 6 goto mp3
if errorlevel 5 goto mpg
if errorlevel 4 goto Help1
if errorlevel 3 goto hevc
if errorlevel 2 goto avc
if errorlevel 1 goto end2
goto end2
:mp3
set encode=MP3
set outfiletype=MP3
goto Result1
:mpg
set encode=MPG
set outfiletype=MPG
goto Result1
:avc
set encode=AVC
set outfiletype=mp4
goto Result1
:hevc
set encode=HEVC
set outfiletype=MKV
goto Result1
:Help1
cls
echo.
echo.
echo This setting controls the type of Mpeg encoding.
echo.
echo.(A)=AVC h.264 The "regular" MP4 encoding. This is what I send out to attorneys and also to other video firms
echo when I'm not sure what they want. This is what most video editing software expects.
echo.
echo.(B)=HEVC h.265 The newer 265 encoding used by some camcorders and sites like Vimeo and Youtube when HTML5 is
echo active. Files are about half the size of AVC with the same quality, but it takes more CPU to decode these and
echo some older CPUs and video cards don't support hardware decoding of HEVC. Playing one of these on an old system
echo could result in very slow playback -- like a couple of frames per second. Each year that matters less.
echo.
echo However, HEVC is an excellent way to store archives, due to the smaller size of the files. It also doesn't
echo matter whether the computer can hardware decode them, because conversions are done as files, not as video
echo playback. So if it goes 3 frames per second, that's fine -- it will just take longer, but it will work.
echo.
echo IMPORTANT NOTE:
echo Since MP4 and MKV containers both can hold either type of CODEC, and attorneys don't generally know what an MKV
echo file is, I decided for my own tools, that I would dedicate the MKV container to only hold HEVC/x265 encoded video,
echo and I only put AVC/x264 video in MP4 containers. That way, I know JUST BY LOOKING AT THE FILENAME whether a video
echo is AVC or HEVC. So in this tool, if you pick x265/HEVC, you will get an MKV file. If you pick x264/AVC, you will
echo get an MP4 container.
echo.
goto choice1
:Result1
echo.Encoding will be %encode%.
:Q2
set scale=
:: skip resolution if it's mpeg1 cuz we know that already
if /i x%encode%x == xMPGx goto 480p
:: skip resolution if it's mp3 cuz doesn't apply
if /i x%encode%x == xMP3x goto noresolution
:: check for environment variables to automate
if /i x%makeMP4.resolution%x == x1080px goto 1080p
if /i x%makeMP4.resolution%x == x720px goto 720p
if /i x%makeMP4.resolution%x == x480px goto 480p
if /i x%makeMP4.resolution%x == xNOSCALEx goto Noscale
:choice2
echo.
echo.
echo.
echo.RESOLUTION SETTING
choice /c qn741h /n /m "Output size? (1)=1080p (7)=720p (4)=480p (N)=noscale (H)=Help (Q)=Quit ? "
if errorlevel 6 goto Help2
if errorlevel 5 goto 1080p
if errorlevel 4 goto 480p
if errorlevel 3 goto 720p
if errorlevel 2 goto Noscale
if errorlevel 1 goto end2
goto end2
:480p
set scale=-s 720:480
set sizestring=480p
goto Result2
:720p
set scale=-s 1280x720
set sizestring=720p
goto Result2
:1080p
set scale=-s 1920x1080
set sizestring=1080p
goto Result2
:Noscale
set scale=
set sizestring=noscale
goto Result2
:Help2
cls
echo.
echo.
echo This is the output resolution you want to convert to.
echo.
echo Values represent popular HD choices.
echo. 1080p = 1920x1080
echo. 720p = 1280x720
echo. 480p = 720x480, etc.
echo Noscale = leave the resolution the same as the source.
echo.
echo I recommend 1080p or bigger for videos with document sharing or Elmo. If you're converting
echo files from Ninjas or Camcorders at 1080p, and you want 1080p output files, you shouldn't pick
echo the 1080p choice. Use noscale to guarantee FFMPEG doesn't try to resize the video needlessly
echo to the same resolution. It's probably smart enough to spot this condition and ignore the request
echo to resize, but I've never tested it to make sure, so use Noscale if you don't want it to be resized.
echo.
echo Keep in mind that FFMPEG will scale down OR UP. If your source is a Zoom video
echo that starts out in 360p, choosing something other than Noscale will UPSCALE the
echo video. Sometimes this is exactly what you want, but I wouldn't upscale more than one step up.
echo (ie, 360p-^>480p is ok, but 360p-^>720p might look a little blocky). I could be wrong though.
echo.
goto choice2
:Result2
echo.Output will be %sizestring%.
:noresolution
:Q3
:: skip quality prompt if it's mpeg1 cuz we know that already
if /i x%encode%x == xMPGx goto qmpg18k
if /i x%encode%x == xMP3x goto noquality
if /i x%makeMP4.quality%x == xSameQx goto sameq
if /i x%makeMP4.quality%x == xCrf18x goto qcrf18
if /i x%makeMP4.quality%x == xCrf20x goto qcrf20
if /i x%makeMP4.quality%x == xCrf22x goto qcrf22
if /i x%makeMP4.quality%x == xCrf24x goto qcrf24
if /i x%makeMP4.quality%x == xCrf26x goto qcrf26
:choice3
echo.
echo.
echo.
echo.QUALITY SETTING
choice /c qcsh284 /n /m "Quality setting? (S)=SameQ (C)=CRF18 (2)=CRF20 (4)=CRF24 (H)=Help (8)=CRF08 (Q)=Quit ? "
if errorlevel 7 goto qcrf24
if errorlevel 6 goto qcrf08
if errorlevel 5 goto qcrf20
if errorlevel 4 goto Help3
if errorlevel 3 goto sameq
if errorlevel 2 goto qcrf18
if errorlevel 1 goto end2
goto end2
:sameq
set qparam=-q:v 0
set qstring=sameq
goto Result3
:qcrf20
set qparam=-crf 20
set qstring=crf20
goto Result3
:qcrf26
set qparam=-crf 26
set qstring=crf26
goto Result3
:qcrf24
set qparam=-crf 24
set qstring=crf24
goto Result3
:qcrf22
set qparam=-crf 22
set qstring=crf22
goto Result3
:qcrf18
set qparam=-crf 18
set qstring=crf18
goto Result3
:qcrf08
set qparam=-crf 8
set qstring=crf8
goto Result3
:qmpg18k
set qstring=1800k
goto Result3
:Help3
cls
echo.
echo.
echo This setting controls the bitrate.
echo.
echo.(S)=SameQ Same visual quality as the original, with every optimization to get smallest possible files
echo.(C)=CRF18 Constant Quality of 18 - visually lossless, regardless of scene content (larger file than SameQ)
echo.(2)=CRF20 Constant Quality of 20 - files a little smaller than CRF18, but not as small as SameQ
echo.
echo I've never seen a difference between SameQ and CRF18 when I've inspected for it. I usually go to a document
echo share and make sure it's as readable in both. I've always come to the conclusion that SameQ is indiscernable
echo from CRF18, but if you want to be sure without looking, and don't mind larger file sizes, then CRF18 is safer.
echo.
goto choice3
:Result3
echo.Quality will be %qstring%.
:noquality
:Q4
:choice4
:: if aspect already set by automated way up top, use that and don't ask
:: if it's not set, aspect will be empty
if /i [%aspect%] == [16x9] goto asp16x9
if /i [%aspect%] == [2.21] goto asp2.21
if /i [%aspect%] == [none] goto aspnone
if /i x%encode%x == xMP3x goto noaspect
if /i x%encode%x == xMPGx goto asp16x9
echo.
echo.
echo.
echo.ASPECT SETTING
set aspstring=
set amode=
choice /c qcshf2 /n /m "Aspect ratio? (S)=Same as Source (F)=Force 16x9 (2)=Force 2.21 (C)=Crop off extra sides (H)=Help (Q)=Quit ? "
if errorlevel 6 goto asp2.21
if errorlevel 5 goto asp16x9
if errorlevel 4 goto Help4
if errorlevel 3 goto aspsame
if errorlevel 2 goto aspcropsides
if errorlevel 1 goto end2
goto end2
:aspnone
set aspstring=
set amode=same as source (passed in)
goto Result4
:asp16x9
set aspstring=-aspect 16:9
set amode=forced to 16x9
goto Result4
:asp2.21
set aspstring=-aspect 2.21
set amode=forced to 2.21
goto Result4
:aspsame
set amode=same as source
goto Result4
:aspcropsides
set aspstring=-vf "crop=iw/4*3:ih" -aspect 16:9
set amode=cropsides but make 16x9
goto Result4
:Help4
cls
echo.
echo.
echo This setting controls the aspect ratio. If you aren't sure, just use (S) for Same as source.
echo.
echo.(S)=Same as Source Same aspect ratio as the source video. This should work most of the time.
echo.(F)=Force 16x9 Use to force 16x9
echo.(C)=Crop off sides Use to fix extra wide videos that look squished when viewed in 16x9
echo.
echo.
goto choice4
:Result4
echo.Aspect will be %amode%.
:noaspect
:startit
:: ===============
:: FFMPEG PARAMS
:: ===============
:: pick the encoding params based on %encode%
set buffix=-max_muxing_queue_size 9999
set x264params=-f mp4 -vcodec libx264 -preset faster -pix_fmt yuv420p %scale% %brightfix% %buffix% -r 29.97 %qparam% -tune film %aspstring% -ar 48000 -c:a aac -b:a 256k
set x265params=-c:v libx265 -preset superfast %scale% %aspstring% %brightfix% %buffix% -r 29.97 %qparam% -ar 48000 -c:a aac -b:a 256k
if /i x%makeMP4.copyaudio%x == x1x set x265params=-c:v libx265 -preset superfast %scale% %aspstring% %buffix% -r 29.97 %qparam% -c:a copy
set mpgparams=-f mpeg -r 29.97 -write_tmcd 0 -pix_fmt yuv420p -s 720:480 %aspstring% -b:v 1800k -maxrate 1800k -minrate 1800k -bufsize 1000k -sws_flags lanczos -g 15 -ab 128k
set mp3params=-f mp3 -vn -ar 48000 -ac 2 -ab 96k
if /i x%encode%x == xHEVCx set ffparams=%x265params%
if /i x%encode%x == xAVCx set ffparams=%x264params%
if /i x%encode%x == xMPGx set ffparams=%mpgparams%
if /i x%encode%x == xMP3x set ffparams=%mp3params%
:: now unset the problem params for mp3 not needed
if /i x%encode%x == xMP3x goto mp3adjust
goto do_convert
:mp3adjust
set qstring=96k
set sizestring=48k
goto do_convert
:do_convert
echo.
echo.
echo.
echo.
echo The Conversions :
if not x%1x == xx echo %~nx1 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%2x == xx echo %~nx2 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%3x == xx echo %~nx3 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%4x == xx echo %~nx4 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%5x == xx echo %~nx5 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%6x == xx echo %~nx6 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%7x == xx echo %~nx7 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%8x == xx echo %~nx8 ^> %encode% %qstring% %sizestring% %outfiletype%
if not x%9x == xx echo %~nx9 ^> %encode% %qstring% %sizestring% %outfiletype%
echo.
timeout /t 9
:: Set all the test variables for easy checking
set test2=%~n2
set test3=%~n3
set test4=%~n4
set test5=%~n5
set test6=%~n6
set test7=%~n7
set test8=%~n8
set test9=%~n9
set qlen=(last one)
if defined test2 set qlen=(1 in queue)
if defined test3 set qlen=(2 in queue)
if defined test4 set qlen=(3 in queue)
if defined test5 set qlen=(4 in queue)
if defined test6 set qlen=(5 in queue)
if defined test7 set qlen=(6 in queue)
if defined test8 set qlen=(7 in queue)
if defined test9 set qlen=(8 in queue)
title Converting %~nx1 to %sizestring% %qstring% %outfiletype% %duration[1]% %qlen%
::echo FFparams = "%ffparams%" >settings.log
ffmpeg -i %1 %ffparams% "%outfolder%\%~n1.%sizestring%.%qstring%.%bext%.%outfiletype%"
if x%2x == xx goto end1
set qlen=(last one)
if defined test3 set qlen=(1 in queue)
if defined test4 set qlen=(2 in queue)
if defined test5 set qlen=(3 in queue)
if defined test6 set qlen=(4 in queue)
if defined test7 set qlen=(5 in queue)
if defined test8 set qlen=(6 in queue)
if defined test9 set qlen=(7 in queue)
timeout /t 2 >nul
title Converting %~nx2 to %sizestring% %qstring% %outfiletype% %duration[2]% %qlen%
ffmpeg -i %2 %ffparams% "%outfolder%\%~n2.%sizestring%.%qstring%.%outfiletype%"
if x%3x == xx goto end1
set qlen=(last one)
if defined test4 set qlen=(1 in queue)
if defined test5 set qlen=(2 in queue)
if defined test6 set qlen=(3 in queue)
if defined test7 set qlen=(4 in queue)
if defined test8 set qlen=(5 in queue)
if defined test9 set qlen=(6 in queue)
timeout /t 2 >nul
title Converting %~nx3 to %sizestring% %qstring% %outfiletype% %duration[3]% %qlen%
ffmpeg -i %3 %ffparams% "%outfolder%\%~n3.%sizestring%.%qstring%.%outfiletype%"
if x%4x == xx goto end1
set qlen=(last one)
if defined test5 set qlen=(1 in queue)
if defined test6 set qlen=(2 in queue)
if defined test7 set qlen=(3 in queue)
if defined test8 set qlen=(4 in queue)
if defined test9 set qlen=(5 in queue)
timeout /t 2 >nul
title Converting %~nx4 to %sizestring% %qstring% %outfiletype% %duration[4]% %qlen%
ffmpeg -i %4 %ffparams% "%outfolder%\%~n4.%sizestring%.%qstring%.%outfiletype%"
if x%5x == xx goto end1
set qlen=(last one)
if defined test6 set qlen=(1 in queue)
if defined test7 set qlen=(2 in queue)
if defined test8 set qlen=(3 in queue)
if defined test9 set qlen=(4 in queue)
timeout /t 2 >nul
title Converting %~nx5 to %sizestring% %qstring% %outfiletype% %duration[5]% %qlen%
ffmpeg -i %5 %ffparams% "%outfolder%\%~n5.%sizestring%.%qstring%.%outfiletype%"
if x%6x == xx goto end1
set qlen=(last one)
if defined test7 set qlen=(1 in queue)
if defined test8 set qlen=(2 in queue)
if defined test9 set qlen=(3 in queue)
timeout /t 2 >nul
title Converting %~nx6 to %sizestring% %qstring% %outfiletype% %duration[6]% %qlen%
ffmpeg -i %6 %ffparams% "%outfolder%\%~n6.%sizestring%.%qstring%.%outfiletype%"
if x%7x == xx goto end1
set qlen=(last one)
if defined test8 set qlen=(1 in queue)
if defined test9 set qlen=(2 in queue)
timeout /t 2 >nul
title Converting %~nx7 to %sizestring% %qstring% %outfiletype% %duration[7]% %qlen%
ffmpeg -i %7 %ffparams% "%outfolder%\%~n7.%sizestring%.%qstring%.%outfiletype%"
if x%8x == xx goto end1
set qlen=(last one)
if defined test9 set qlen=(1 in queue)
timeout /t 2 >nul
title Converting %~nx8 to %sizestring% %qstring% %outfiletype% %duration[8]% %qlen%
ffmpeg -i %8 %ffparams% "%outfolder%\%~n8.%sizestring%.%qstring%.%outfiletype%"
if x%9x == xx goto end1
set qlen=(last one)
timeout /t 2 >nul
title Converting %~nx9 to %sizestring% %qstring% %outfiletype% %duration[9]% %qlen%
ffmpeg -i %9 %ffparams% "%outfolder%\%~n9.%sizestring%.%qstring%.%outfiletype%"
goto end1
:error1
echo %~n0 usage:
echo.
echo This tool will convert dropped files using FFMPEG.exe.
echo.
echo Up to 9 files may be dropped onto the batch file in an Explorer window.
echo Order of the files dropped won't matter, since they won't be joined
echo (concatted) in this tool anyway.
echo.
echo This tool is intended to be a "brute force" encoder, in that it doesn't
echo check for any potential problems beforehand, since it's going to convert
echo them all to the same settings -- resolution, audio bitrate, framerate,
echo video CODEC, aspect ratio, etc.
echo.
echo This is the tool to use when AutoMTS5 tells you it hit a FATAL error due
echo to file resolutions or aspect ratios being different across the files.
echo.
echo Settings for conversions are chosen on the fly, but less commonly changed
echo settings might require you to edit the batch file. Examples of settings
echo you COULD change this way are audio bitrate, disabling forced aspect ratio.
echo.
echo Spaces in filenames are allowed, using quotes! Windows will provide the
echo proper quotes if you use drag and drop in Explorer, or if you use TAB KEY
echo filename completion at the command line.
echo.
pause
goto end2
:error2
echo.
echo %~n0 requires FFprobe.exe to show file stats.
echo.
timeout /t 10
goto end2
:error3
echo.
echo %~n0 requires FFmpeg.exe to do file conversions.
echo.
timeout /t 10
goto end2
:end1
title %~n1 %sizestring%.%qstring% done!
:: in case its used from expolorer, this lets the window stay open till they press a key
timeout /t 5
:end2