1

I am trying to create a batch file with 2 passes. Pass 1 scales the video. Pass 2 pads a border around it. They both work separately but will not work together.

Pass 1:

@echo off
REM Scale video to 1216x684
for %%a in (*.mp4) do ( ffmpeg -i "%%a" -vf scale=1216:684 -preset faster "output\%%~na.mp4"
)
pause

Pass 2:

@echo off
REM Pad video to 1280x720
for %%a in (*.mp4) do ( ffmpeg -i "%%a" -vf pad="1280:720:32:0" -preset faster "output\%%~na.mp4"
)
pause

Combined:

@echo off
REM Scale video to 1216x684 and pad to 1280x720
for %%a in (*.mp4) do ( ffmpeg -i "%%a" -vf scale=1216:684 -preset faster -pass 1 -f mp4 NUL && \
ffmpeg -i "%%a" -vf pad="1280:720:32:0" -preset faster -pass 2 "output\%%~na.mp4
)
pause

Error:

CRF/CQP is incompatible with 2pass. Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!

What am I missing?

0

2-pass is for video encoding when using an average bitrate target. When saving to MP4, default encoder is x264 whose default encoding mode is CRF where 2-pass is not applicable. The pass system also no connection with the use of filters, which is what scale and pad are.

In any case, you can carry out scaling and padding in one command.

for %%a in (*.mp4) do ( ffmpeg -i "%%a" -vf "scale=1216:684,pad=1280:720:32:0" -preset faster "output\%%~na.mp4"
)
| improve this answer | |
  • Thank you Gyan. That is exactly what I needed. – JHandin Apr 20 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.