hydra3333
13th January 2015, 17:45
Hello. Seeking a bit of advice on an ffmpeg commandline to downscale/upscale/bar-ize/convert a bunch of generally low-res arbitrary-sized old mp4's (free stuff) into mpeg2 files for burning to a PAL DVD, for an elderly relative's DVD player ...
The .bat file (code below) produces mpeg2 files.
The ffmpeg settings were "borrowed" from googling (I originally used -target pal-dvd however that over-rode some of the other ffmpeg settings so I had to desist and code the equivalent ffmpeg switches manually after finding out what they were) .
However,
- I'm not sure the output files are fully PAL DVD compatible... any advice ?
- I have not specified interlacing so is that going to be an issue ? If so, I guess I'll have to find the switches to convert it to TFF interlaced
(I will try to burn them tomorrow and see what happens)
- Are there any ffmpeg filters you would recommend to, say, sharpen and maybe denoise a bit ?
I could easily do it and a lot of other things in avisynth, but I'm not sure how to open an .mp4 (sheepish sigh).
@echo on
REM set width=720
REM set height=480
REM set fps=29.97
set width=720
set height=576
set fps=25
del ".\mi.txt"
for %%y in ("*.mp4") do (
call :fred "%%y"
)
del ".\mi.txt"
exit
:fred
SETLOCAL ENABLEDELAYEDEXPANSION
"c:\software\mediainfo\mediainfo.exe" --Inform=Video;%%AspectRatio/String%% "%~1" > ".\mi.txt"
set /p ar= < ".\mi.txt"
REM echo ar=!ar!
REM do a straight 16:9 conversion to %width%x%height%
if "!ar!" == "16:9" "C:\SOFTWARE\ffmpeg\bin\ffmpeg.exe" -i "%~1" -c:v mpeg2video -pix_fmt yuv420p -g 15 -bufsize 1835008 -maxrate 8000000 -packetsize 2048 -muxrate 10080000 -q:v 0 -vf scale="%width%:%height%" -aspect 16:9 -sws_flags lanczos+full_chroma_int -r %fps% -c:a mp2 -ac 2 -ab 224k -ar 44100 -y "%~1.mpg"
REM else do a preserve-aspect-ratio scale and pad
if NOT "!ar!" == "16:9" "C:\SOFTWARE\ffmpeg\bin\ffmpeg.exe" -i "%~1" -c:v mpeg2video -pix_fmt yuv420p -g 15 -bufsize 1835008 -maxrate 8000000 -packetsize 2048 -muxrate 10080000 -q:v 0 -vf scale="'if(gte(a,4/3),%width%,-1)':'if(gt(a,4/3),-1,%height%)'",pad="%width%:%height%:(%width%-iw)/2:(%height%-ih)/2" -aspect 4:3 -sws_flags lanczos+full_chroma_int -r %fps% -c:a mp2 -ac 2 -ab 224k -ar 44100 -y "%~1.mpg"
goto :eof
The .bat file (code below) produces mpeg2 files.
The ffmpeg settings were "borrowed" from googling (I originally used -target pal-dvd however that over-rode some of the other ffmpeg settings so I had to desist and code the equivalent ffmpeg switches manually after finding out what they were) .
However,
- I'm not sure the output files are fully PAL DVD compatible... any advice ?
- I have not specified interlacing so is that going to be an issue ? If so, I guess I'll have to find the switches to convert it to TFF interlaced
(I will try to burn them tomorrow and see what happens)
- Are there any ffmpeg filters you would recommend to, say, sharpen and maybe denoise a bit ?
I could easily do it and a lot of other things in avisynth, but I'm not sure how to open an .mp4 (sheepish sigh).
@echo on
REM set width=720
REM set height=480
REM set fps=29.97
set width=720
set height=576
set fps=25
del ".\mi.txt"
for %%y in ("*.mp4") do (
call :fred "%%y"
)
del ".\mi.txt"
exit
:fred
SETLOCAL ENABLEDELAYEDEXPANSION
"c:\software\mediainfo\mediainfo.exe" --Inform=Video;%%AspectRatio/String%% "%~1" > ".\mi.txt"
set /p ar= < ".\mi.txt"
REM echo ar=!ar!
REM do a straight 16:9 conversion to %width%x%height%
if "!ar!" == "16:9" "C:\SOFTWARE\ffmpeg\bin\ffmpeg.exe" -i "%~1" -c:v mpeg2video -pix_fmt yuv420p -g 15 -bufsize 1835008 -maxrate 8000000 -packetsize 2048 -muxrate 10080000 -q:v 0 -vf scale="%width%:%height%" -aspect 16:9 -sws_flags lanczos+full_chroma_int -r %fps% -c:a mp2 -ac 2 -ab 224k -ar 44100 -y "%~1.mpg"
REM else do a preserve-aspect-ratio scale and pad
if NOT "!ar!" == "16:9" "C:\SOFTWARE\ffmpeg\bin\ffmpeg.exe" -i "%~1" -c:v mpeg2video -pix_fmt yuv420p -g 15 -bufsize 1835008 -maxrate 8000000 -packetsize 2048 -muxrate 10080000 -q:v 0 -vf scale="'if(gte(a,4/3),%width%,-1)':'if(gt(a,4/3),-1,%height%)'",pad="%width%:%height%:(%width%-iw)/2:(%height%-ih)/2" -aspect 4:3 -sws_flags lanczos+full_chroma_int -r %fps% -c:a mp2 -ac 2 -ab 224k -ar 44100 -y "%~1.mpg"
goto :eof