FranceBB
5th January 2018, 07:05
Hi,
I made a simple script for my colleagues to encode files using ffmpeg.
They didn't like the idea of learning Avisynth nor the fact that they had to manually insert the name and the path of the file in the .bat.
They asked a drag and drop solution and I made one.
@echo off
setlocal disableDelayedExpansion
::
:: first assume normal call, get args from %*
set args=%*
set "dragDrop="
::
:: Now check if drag&drop situation by looking for %0 in !cmdcmdline!
:: if found then set drag&drop flag and get args from !cmdcmdline!
setlocal enableDelayedExpansion
set "cmd=!cmdcmdline!"
set "cmd2=!cmd:*%~f0=!"
if "!cmd2!" neq "!cmd!" (
set dragDrop=1
set "args=!cmd2:~0,-1! "
set "args=!args:* =!"
)
::
:: Process the first argument only
for %%F in (!args!) do (
if "!!"=="" endlocal & set "dragDrop=%dragDrop%"
rem ------------------------------------------------
rem - Your file processing starts here.
rem
rem Change to drive and directory of input file
%%~dF
cd %%~pF
C:\Encoding\ffmpeg.exe -i "%%~nxF" -pix_fmt yuv422p -vcodec mpeg2video -s 1920:1080 -aspect 16:9 -vf setfield=tff -flags +ildct+ilme -r 25 -b:v 50000k -minrate 50000k -maxrate 50000k -bufsize 36408333 -acodec pcm_s16le -ar 48000 -g 12 -bf 2 -profile:v 0 -level:v 2 -color_range 1 -color_primaries 1 -color_trc 1 -colorspace 1 -f mxf "C:\Encoding\%%~nF encoded.mxf"
rem
rem - Your file processing ends here
rem -------------------------------------------------
)
if defined dragDrop (
pause
exit
)
However, our machines have many cores and thread (we have two Intel Xeon E5 2630 v3 on each machine: 16 core, 32 thread), but the MPEG-2 encoder in ffmpeg is single thread, so I would like to modify the bat above to process multiple files at a time.
I made a simple script for my colleagues to encode files using ffmpeg.
They didn't like the idea of learning Avisynth nor the fact that they had to manually insert the name and the path of the file in the .bat.
They asked a drag and drop solution and I made one.
@echo off
setlocal disableDelayedExpansion
::
:: first assume normal call, get args from %*
set args=%*
set "dragDrop="
::
:: Now check if drag&drop situation by looking for %0 in !cmdcmdline!
:: if found then set drag&drop flag and get args from !cmdcmdline!
setlocal enableDelayedExpansion
set "cmd=!cmdcmdline!"
set "cmd2=!cmd:*%~f0=!"
if "!cmd2!" neq "!cmd!" (
set dragDrop=1
set "args=!cmd2:~0,-1! "
set "args=!args:* =!"
)
::
:: Process the first argument only
for %%F in (!args!) do (
if "!!"=="" endlocal & set "dragDrop=%dragDrop%"
rem ------------------------------------------------
rem - Your file processing starts here.
rem
rem Change to drive and directory of input file
%%~dF
cd %%~pF
C:\Encoding\ffmpeg.exe -i "%%~nxF" -pix_fmt yuv422p -vcodec mpeg2video -s 1920:1080 -aspect 16:9 -vf setfield=tff -flags +ildct+ilme -r 25 -b:v 50000k -minrate 50000k -maxrate 50000k -bufsize 36408333 -acodec pcm_s16le -ar 48000 -g 12 -bf 2 -profile:v 0 -level:v 2 -color_range 1 -color_primaries 1 -color_trc 1 -colorspace 1 -f mxf "C:\Encoding\%%~nF encoded.mxf"
rem
rem - Your file processing ends here
rem -------------------------------------------------
)
if defined dragDrop (
pause
exit
)
However, our machines have many cores and thread (we have two Intel Xeon E5 2630 v3 on each machine: 16 core, 32 thread), but the MPEG-2 encoder in ffmpeg is single thread, so I would like to modify the bat above to process multiple files at a time.