A creator on Video Production Stack Exchange wanted to fit a 1920 × 816 video into a 16:9 canvas without stretching the picture. Another editor reported that a portrait iPhone video gained side borders after export. Both situations call for inspecting the actual frame and deciding which picture area the delivery file should retain.
Inspect dimensions and pixel shape
ffprobe -v error -select_streams v:0 -show_entries stream=width,height,sample_aspect_ratio,display_aspect_ratio:stream_side_data=rotation -of json input.mp4
Width and height count stored pixels. Sample aspect ratio (SAR) describes their shape; display aspect ratio (DAR) describes the displayed rectangle. A rotation tag can change its orientation on playback. If the source already contains black bars as pixels, changing metadata will not remove them. Check the picture as well as the stream information.
Fit the whole picture inside 1920 × 1080
Use a recent FFmpeg build whose scale filter supports reset_sar (check ffmpeg -h filter=scale). This command uses square output pixels and even scaled dimensions, then adds black space around the fitted picture. Choose a new filename.
ffmpeg -n -i input.mp4 -map 0:v:0 -map "0:a:0?" -vf "scale=1920:1080:force_original_aspect_ratio=decrease:force_divisible_by=2:reset_sar=1,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -pix_fmt yuv420p -crf 18 -c:a aac fitted.mp4
For a square-pixel, unrotated 1920 × 816 source, the picture remains 1920 × 816 within a 1920 × 1080 canvas, leaving 132 pixels of black above and below. A player receives a 16:9 output without widening or thinning the subjects.
Fill a portrait canvas for vertical delivery
For an unrotated landscape source, decide whether losing the sides is acceptable. Filling a 1080 × 1920 portrait canvas requires scaling up and cropping. Review faces, captions and other essential content after the crop.
ffmpeg -n -i input.mp4 -map 0:v:0 -map "0:a:0?" -vf "scale=1080:1920:force_original_aspect_ratio=increase:force_divisible_by=2:reset_sar=1,crop=1080:1920:(iw-ow)/2:(ih-oh)/2" -c:v libx264 -pix_fmt yuv420p -crf 18 -c:a aac vertical.mp4
To keep all of a landscape picture in a portrait canvas instead, use decrease and pad=1080:1920:(ow-iw)/2:(oh-ih)/2. With a 1920 × 1080 source, the fitted image is approximately 1080 × 608 pixels; most of the canvas is empty above and below. If an already-portrait video is embedded inside a landscape canvas, inspect or crop the baked-in bars first. Center cropping can also cut off an off-center subject, so adjust the framing for each shot.
Verify the actual delivery
In our FFmpeg 9.0.2 test with unrotated square-pixel synthetic video, ffprobe confirmed 1920 × 1080 with 16:9 DAR for the fit command and 1080 × 1920 with 9:16 DAR for both portrait variants. Reading the rendered frames located the landscape picture at rows 132–947 of the fitted file, the whole landscape picture at rows 656–1263 of the portrait fit, and picture content on every row of the portrait crop. These were synthetic sources. Check the result with your actual footage, particularly rotation, existing bars and caption placement. The commands select only the first video stream and optional first audio stream, so inspect multi-track masters before delivery.