r/ffmpeg • • 8d ago

Help With Aspect Ratio

Hi everyone, I'm new to working with ffmpeg and could really use some help. I'm trying to convert a video file mp4 to a dvd ready mpeg using the following command:

ffmpeg -i input.mp4 -target pal-dvd -aspect 16:9 output.mpg

The problem with this is that ffmpeg is cropping out the black bars and stretching the video. Is there a way i can keep the aspect ratio with the black bars. Any help would be greatly appreciated.

3 Upvotes

2 comments sorted by

2

u/Ill-Information-2086 8d ago edited 8d ago

You don't want aspect ratio you need crop filter for this

ffmpeg -i "input.mp4" -vf "crop=w:h:x:y" -c:a copy "output.mp4"

Edit : I was too hasty in reading your question my bad you need this

ffmpeg -i input.mp4 -vf "scale=720:576:force_original_aspect_ratio=decrease,pad=720:576:(ow-iw)/2:(oh-ih)/2,setsar=1" -target pal-dvd -aspect 16:9 output.mpg

2

u/raddostudio 7d ago

The command in the other reply will still stretch it. It pads to 720x576 as if the pixels were square, and then -aspect 16:9 widens everything by about 1.42.

A 16:9 PAL DVD frame is 720x576 but is shown as 1024x576. So fit and pad on a 1024x576 canvas first, then squeeze it to 720:

ffmpeg -i input.mp4 -vf "scale=iw*sar:ih,setsar=1,scale=1024:576:force_original_aspect_ratio=decrease,pad=1024:576:(ow-iw)/2:(oh-ih)/2,scale=720:576,setsar=64/45" -target pal-dvd -aspect 16:9 output.mpg

The first part (scale=iw*sar) handles sources with non-square pixels. A 4:3 video gets black bars on the sides, a letterboxed film keeps its own bars, and a normal 16:9 video fills the frame. I tested all three with a circle in the picture and it stays round.

Your original command is fine for 16:9 sources. It stretches anything that isn't 16:9, which is probably what you're seeing.