Warm tip: This article is reproduced from serverfault.com, please click

ffmpeg scale 4k video and add subtitles

发布于 2020-11-28 23:25:01

I am having trouble scaling video from 4k to 1080 while still retaining the video sub titles. These subtitles are PGS based and therefore need to be baked into the output video. In order to scale the video I am using ffmpeg with a filter_complex like so:

'-filter_complex', `[0:v][0:s:randomSubtitleHere]scale=1920:1080[scaled];[scaled][0:s:0]overlay[v]`, 
'-map', '[v]', '-map', 
`0:a:${movieTitle['audioSelect']}`,

This will give me the video at 1080, but it i still am not seeing the subtitles I have selected.

Questioner
goodkid38
Viewed
0
llogan 2020-11-30 04:44:51

PGS are image based subtitles.

Use the scale filter:

ffmpeg -i input.mkv -filter_complex "[0:v]scale=1920:1080[vid];[0:s:0]scale=1920:1080[sub];[vid][sub]overlay[v]" -map "[v]" -map 0:a:0 output.mkv

Or add scale2ref filter to automatically scale the subtitles to match the size of the video.

ffmpeg -i input.mkv -filter_complex "[0:v]scale=1920:1080[ref];[0:s:0][ref]scale2ref[sub][vid];[vid][sub]overlay[v]" -map "[v]" -map 0:a:0 output.mkv