Reputation: 23
I have created a batch file (.bat) that uses FFmpeg to transcode various videos (with *.mov or *.mp4 file name extension) from an input folder to an output folder (with extension *.mkv) as batch process (Windows 10 environment). File names (without extension) from the input folder should be copied to the newly created output file names (that have the new file extension *.mkv).
@echo off
set CMD=ffmpeg -c:v ffv1 -level 3 -g 1 -coder 1 -context 1 -pix_fmt + -slices 24 -slicecrc 1 -report -c:a pcm_s24le
FOR /R input_folder %%G IN (*.mov,*.mp4) DO (
echo %%G
call set outputfile=%%~nG%.mkv
call set inputfile=%%~nG%%~xG
echo %CMD% -y output_folder/%outputfile% -i %inputfile%
)
But this script does not work as expected, i.e. nothing happens. Do you perhaps have an idea how to fix this? Thanks in advance!
Upvotes: 0
Views: 6305
Reputation: 38718
Here's an example showing my suggestions from the comments, with the addition of the file deletion as requested in the comments too. This assumes that ffmpeg returns an errorlevel of 0
upon success, (you don't want to delete them if the processing failed), and that there is an existing directory named output_folder
, in the current working directory.
@Echo Off
SetLocal EnableExtensions
Set "CMD=ffmpeg.exe -c:v ffv1 -level 3 -g 1 -coder 1 -context 1 -pix_fmt +"
Set "CMD=%CMD% -slices 24 -slicecrc 1 -report -c:a pcm_s24le"
For /R "input_folder" %%G In (*.mov *.mp4) Do (
Echo %%G
%CMD% -y "output_folder\%%~nG.mkv" -i "%%G"
If Not ErrorLevel 1 Del /A /F "%%G"
)
Upvotes: 1