2006-04-03, 08:45 PM
Iâve had trouble converting avi files with aspect ratios other than 4:3 to mpeg for MVP playback. For each file Iâve had to manually figure out what top and bottom padding I need to keep the aspect ratio correct. Thereâs probably an easier way of doing this, but to automate the process Iâve written a wee batch file (below) that first finds the resolution of the source video from ffmpeg and then calculates the top and bottom padding required to maintain the correct aspect ratio while changing to the correct resolution for the MVP (PAL in my case).
This is fine for off-line transcoding, but the only thing I canât figure out is how to integrate it into the real-time MVP transcode feature. And ideas?
This is fine for off-line transcoding, but the only thing I canât figure out is how to integrate it into the real-time MVP transcode feature. And ideas?
Code:
@echo off
set inputfile=%1
set outputfile=%2
set outputxsize=720
set outputysize=576
for /f "eol=; tokens=1,2,3,4,5 delims=:,x" %%a in ('ffmpeg -i %inputfile% 2^>^&1') do (
if "%%b"==" Video" (
set /a inputxsize=%%d
set /a inputysize=%%e
)
)
echo Input video size is %inputxsize% by %inputysize%
set /a newysize=%inputysize%*%outputxsize%/%inputxsize%
echo Resized video is %outputxsize% by %newysize%
set /a padding=(%outputysize%-%newysize%)/2
echo Top and bottom padding needed is %padding%
:: Passing must be a multiple of 2
set /a padding=(%padding%/2)*2
set /a newysize=outputysize-(padding*2)
echo Corrected padding is %padding%
echo Corrected resized height is %newysize%
start "Converting" /low /wait /b ffmpeg -y -i %inputfile% -b 4000 -ac 2 -ab 224 -r 25 -s %outputxsize%x%newysize% -padtop %padding% -padbottom %padding% -f svcd %outputfile%