You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用FFmpeg将4K视频缩至1080P并嵌入PGS字幕时无法显示选中字幕

Fixing PGS Subtitle Visibility When Scaling 4K to 1080P with FFmpeg

Let's break down why your subtitles aren't showing up and fix it step by step.

The Core Issue with Your Current Command

PGS subtitles are graphical subtitle streams (not plain text) that match the original 4K resolution of your video. In your current command:

-filter_complex, `[0:v][0:s:randomSubtitleHere]scale=1920:1080[scaled];[scaled][0:s:0]overlay[v]`
  • The scale filter only processes video streams, so it ignores the subtitle stream you passed in [0:s:randomSubtitleHere] — the [scaled] output is just your scaled 1080P video with no subtitle data.
  • When you overlay [0:s:0] (the original 4K PGS subtitle), it’s rendered at 4K size on top of your 1080P video. Most of the subtitle is outside the visible frame, which is why you can’t see it.

The subtitles filter automatically handles scaling graphical subtitles to match your output video resolution. It reads the subtitle stream directly from your input file and renders it correctly.

Modify your command to this:

ffmpeg -i input.mkv \
-filter_complex "[0:v]scale=1920:1080[v_scaled];[v_scaled]subtitles=input.mkv:si=${selected_subtitle_index}[v_out]" \
-map "[v_out]" \
-map "0:a:${movieTitle['audioSelect']}" \
output.mkv
  • Replace input.mkv with your actual input file path.
  • si=${selected_subtitle_index} specifies which subtitle stream to use (e.g., si=0 for the first subtitle stream). You can verify stream indices with ffmpeg -i input.mkv.

Solution 2: Manually Scale the Subtitle Stream First

If you prefer using overlay, you need to scale the PGS subtitle stream to 1080P before overlaying it on your scaled video:

ffmpeg -i input.mkv \
-filter_complex "[0:v]scale=1920:1080[v_scaled];[0:s:${selected_subtitle_index}]scale=1920:1080[s_scaled];[v_scaled][s_scaled]overlay[v_out]" \
-map "[v_out]" \
-map "0:a:${movieTitle['audioSelect']}" \
output.mkv

This ensures both the video and subtitle are at 1080P, so the subtitle fits perfectly within the output frame.

Extra Tips

  • Always use MKV as your output format when working with PGS subtitles — it natively supports embedding graphical subtitle streams without conversion.
  • Double-check your subtitle stream index with ffmpeg -i input.mkv to make sure you’re targeting the correct one.

内容的提问来源于stack exchange,提问作者goodkid38

火山引擎 最新活动