Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image-based subtitles are stretched to video aspect ratio #14276

Open
6 tasks done
visibleonlynow opened this issue Jun 1, 2024 · 10 comments
Open
6 tasks done

image-based subtitles are stretched to video aspect ratio #14276

visibleonlynow opened this issue Jun 1, 2024 · 10 comments

Comments

@visibleonlynow
Copy link

mpv Information

mpv v0.38.0-dirty Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
 built on May 23 2024 10:29:03
libplacebo version: v6.338.2
FFmpeg version: n6.1.1
FFmpeg library versions:
   libavutil       58.29.100
   libavcodec      60.31.102
   libavformat     60.16.100
   libswscale      7.5.100
   libavfilter     9.12.100
   libswresample   4.12.100

Important Information

screenshots

2024-06-01-184158_1920x800_scrot

using video-aspect-override=16:9

2024-06-01-184206_1920x1080_scrot

Reproduction Steps

To reproduce this, simply play any non-16:9 video with image-based subtitles (in my case dvd_subtitle) and they will appear stretched. This also happens in VLC and MPC-HC, but not in Infuse. When using video-aspect-override=16:9 the subtitles are displayed correctly.

Expected Behavior

Image-based subtitles should be displayed in 16:9, even when the video is a different aspect ratio.

This is what the same file looks like in Infuse:

IMG_1340

Actual Behavior

The subtitles are stretched to the same aspect ratio as the video. See the screenshots in Important Information

Log File

output.txt

Sample Files

No response

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.
@ruihe774
Copy link
Contributor

ruihe774 commented Jun 1, 2024

You're using a VOBsub subtitle. Please extract it and attach it here (both .idx and .sub). Stretching can happen if size in VOBsub does not match the video. Are they ripped from the same disk?

@visibleonlynow
Copy link
Author

I'm not sure about the legality of uploading the whole .sub file here, but this is the header of the .idx:

# VobSub index file, v7 (do not modify this line!)
size: 1920x1080
org: 0, 0
scale: 100%, 100%
alpha: 100%
smooth: OFF
fadein/out: 0, 0
align: OFF at LEFT TOP
time offset: 0
forced subs: OFF
palette: 000000, f0f0f0, cccccc, 999999, 3333fa, 1111bb, fa3333, bb1111, 33fa33, 11bb11, fafa33, bbbb11, fa33fa, bb11bb, 33fafa, 11bbbb
custom colors: OFF, tridx: 1000, colors: 000000, 444444, 888888, cccccc
langidx: 0

The size is indeed different than the video size, which is 3840x1600. I don't think this is an issue with this file specifically, as I have experienced the same behaviour with many other files. However, as mentioned in the issue, these exact subtitles are displayed correctly in Infuse, so maybe there is a way to make mpv behave in the same way?

@kasper93
Copy link
Contributor

kasper93 commented Jun 1, 2024

This also happens in MPC-HC

Works fine, in older version. There was logic to fit uncropped subtitles onto cropped video.

Image-based subtitles should be displayed in 16:9, even when the video is a different aspect ratio.

This is arguable, because we don't know how much of the video were cropped, we can assume that video should be fitted into subtitle size, but in fairness encoder should crop subtitles the same way as video.

I can add an option for this, I find it useful, there are a lot of encodes that have broken subtitles, because people doesn't care.

@visibleonlynow
Copy link
Author

I changed the size in the extracted subtitle.idx file to 3840x1600, which matches the video track, and merged it back into the source file. Now the subtitles aren't stretched, but appear somwhere in the middle of the video and are bit smaller, so I doubt that size is the issue, but maybe I just did something wrong.

2024-06-01-222216_1920x800_scrot

@kasper93
Copy link
Contributor

kasper93 commented Jun 1, 2024

Set them to 1920x800

@visibleonlynow
Copy link
Author

They look exactly the same with 1920x800.

@cubicibo
Copy link

cubicibo commented Jun 9, 2024

Image subtitles do not work like this. The container only declares the target video dimensions. Changing the width and height fields in the container will not change the coordinates fed to the decoder, nor the transported bitmap data.

Anyway, VobSub should only carry valid DVD resolution subtitles. Why would you ever use this format for HD?

@visibleonlynow
Copy link
Author

VobSub should only carry valid DVD resolution subtitles

I don't see how this is going to help me solve the issue.
Does this mean that stretching the subtitles is the intended behaviour?

I just found these two options in the man page:

       --stretch-image-subs-to-screen=<yes|no>
              Stretch DVD and other image subtitles to the screen, ignoring
              the video margins. This has a similar effect as
              --sub-use-margins for text subtitles, except that the text
              itself will be stretched, not only just repositioned. (At least
              in general it is unavoidable, as an image bitmap can in theory
              consist of a single bitmap covering the whole screen, and the
              player won't know where exactly the text parts are located.)

              This option does not display subtitles correctly. Use with care.

              Disabled by default.

       --image-subs-video-resolution=<yes|no>
              Override the image subtitle resolution with the video resolution
              (default: no). Normally, the subtitle canvas is fit into the
              video canvas (e.g. letterboxed). Setting this option uses the
              video size as subtitle canvas size. Can be useful to test broken
              subtitles, which often happen when the video was trancoded,
              while attempting to keep the old subtitles.

However, using --stretch-image-subs-to-screen=yes makes the subtitles appear in the middle of the video again.
The other flag doesn't help either, but at least there is a mention of image subtitles and stretched in the man page.

Maybe a flag like --image-subs-aspect-override=16:9 could be added to force image-based subtitles to be displayed like they are when using --video-aspect-override=16:9 without affecting the video aspect ratio?

@cubicibo
Copy link

cubicibo commented Jun 11, 2024

I don't see how this is going to help me solve the issue.

Image subtitles (VobSub, DVB-Bitmap, PGS, TTML-PNG) are always generated for a given target video, out of a handful of possible standardized video formats. They can hardly be mixed with arbitrary videos that differs from the one they were supposed to be used on, or files that do not respect the constrained video format.

Does this mean that stretching the subtitles is the intended behaviour?

Not necessarily! The problem is elsewhere: most VobSub subtitles consist of full-screen, and mostly transparent, bitmaps overlaid onto the video. With non-standard video formats, mpv does not know how to manage these gigantic overlays onto a mismatched video format. The only solution is to stretch them. Image subtitles that use proper screen regions (rectangles) are generally correctly handled by mpv.

Hence, the option suggested by @/kasper93 is needed for these "bad" files.

@visibleonlynow
Copy link
Author

VobSub subtitles consist of full-screen, and mostly transparent, bitmaps overlaid onto the video

I see, for some reason I just assumed that all image subtitles would be as small as they could be (i.e. from the top left corner to the bottom right of the subtitle).
If they are a transparent 1920x1080 image, it makes sense that they appear stretched. I guess this also explains why they appear in the middle of the video when changing something.

Thank you for the explanation; I didn't know about this when creating the issue.
Adding a flag as suggested previously would solve this for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants