Mpv: Put subtitles just under movie

Created on 19 Nov 2013  路  20Comments  路  Source: mpv-player/mpv

I ma not sure if this can be accomplished already but I have not found a way. I have a widescreen laptop (16:10. I use

vf=expand=:::0:16/10:

To put the image on top of the screen. With 2.35:1 films, this results in a huge black streak in the lower half of the screen. The subtitles get loaded to the gottom of the screen. I would like them to load under the bottom (with some margin given by --sub-text-margin-y) of the film. I cannot do it now with sub-pos because the aspect ratios of different films differ and so the value of sub-pos would have to differ too.

Now, I could make a script that would get a resolution of the film and computed that value, but that would be kind of ugly. Much better if mpv allowed this somehow. As far as I know, it has all the information it needs - i.e. the size of my screen and the aspect ratio of the film.

This is mainly valid for full-screen use. I will open an issue about different options for fullscreen as an separate issue and reference it.

feature-request low

All 20 comments

Isn't --ass-use-margins what you want?

I did not know about this one, but it seems to put the subtitles to the bottom.of the screen and bottom of the balck band(I just tried). I would like it to put the subtitles to the top of the black band.

Yeah, that is a bit of a problem. libass (the subtitle renderer) can't do this kind of top alignment.

I see. --sub-pos is able to put the subtitles to the correct place, but only with --no-ass. If you were to implement what I want just for --no-ass, it would still made me happy, but I understand if you won't.

Strangely, by using r and t, I can lift the subtitles to the position I want even with libass.

-no-ass uses libass too (just slightly differently).

libass _can_ move subtitle position (at least with newer libass releases), but what doesn't work is alignment of text to the top. (Text is always aligned to the bottom.)

So the solution is to open a bug for libass, right:-)?

Uh well, I tried to implement it once in libass, but it turned out that this is way too complicated. (You'd have to change the whole logic for stacking multiple lines...) Also, I'm not exactly sure if that would really do what you want.

I want this:
Let's say coordinate 0,0 is uper left corner and my subtitles are 100 pixels high and --sub-text-margin-x is 10 pixels.
Let's imagine I have a screen 1000x1000 and I have a movie 1000x600 so 400 pixels in the bottom are black (assume I am using --video-align-y). I would want the subtitles to be rendered between position 610 and 710. Now they are rendered in position 900 and 1000 (or 890 and 990, I am not sure).

Basically, if mpv could calculate this and move the subtitles up to that position, that would be what I want. i.e. it would just do multiple times what r does until the subtitles were just under the picture. I know this would break real .ass subtitles that put text to precise coordinates on the screen, but for .srt and the like, it would be great and it would not be default. One would need to scan the subtitle file and get a number of maximum lines per subtitle to be able to do this (or one could suppose that any solid subtitles will have at maximum two lines).

Even better would be to do this for every subtitle, so that one-line subtitles would get put higher then two line subtitles. I however understand if this is not possible with libass.

But both mplayer and mplayer2 have an alignment option. The "a" key let's you align the subtitles to top, centre or bottom. Perhaps it works because they don't use libass with ass = "no"...

I find it very usefull. The bottom aligned subtitles with 2 lines or more obstruct quite a lot of the film space. So I usually top align the subs and shift them down to have 2nd and 3rd line displayed in the black space under the film (it takes 2s to do that with r/t keys). I don't quite understand @felagund need for a full automation here, I would be happy with just the top alignment option.

As for the libass implementation, I don't know the details, but if bottom alignment is implemented with stacking lines on top of each other, then by reversing the order of lines and negating the shift (to stack them below each other) one could get the top alignment.

Of course it takes 2-3 seconds, but computers are there to be automated, that is why I asked.

But both mplayer and mplayer2 have an alignment option. The "a" key let's you align the subtitles to top, centre or bottom. Perhaps it works because they don't use libass with ass = "no"...

Yes, they have custom (and bad) text rendering code. mpv removed that, and just uses libass.

As for the libass implementation, I don't know the details, but if bottom alignment is implemented with stacking lines on top of each other, then by reversing the order of lines and negating the shift (to stack them below each other) one could get the top alignment.

Probably, but the code for this is already messy.

neither --ass-use-margins; --sub-text-margin-y; r,t or --sub-pos (with or without --no-ass) works for me.
The only thing I could achieve was to get subtitles first row to appear on top of the movie, and second row to appear on top of the black bottom band with -vf expand=1680:1050

mpv git-59d44ec win64
ffmpeg library versions:
   libavutil       54.30.100
   libavcodec      56.57.100
   libavformat     56.40.101
   libswscale      3.1.101
   libavfilter     5.32.100
   libswresample   1.2.101
ffmpeg version: N-74264-gfb21d32

--sub-use-margins for non-ass text subtitles, --stretch-image-subs-to-screen for image subtitles. Enjoy your ugly and broken subtitles.

@wm4 weirdo response.

Looking back at it, I must agree that the original issue never get resolved.

Yeah, that is a bit of a problem. libass (the subtitle renderer) can't do this kind of top alignment.

What I said 5 years ago is still true.

Yeah, that is a bit of a problem. libass (the subtitle renderer) can't do this kind of top alignment.

What I said 5 years ago is still true.

Enjoy your ugly and broken true statement, bro.

Always these entitled dumb fuck users...

Always these entitled dumb fuck users...

I guess it's all matter of perspective lol. Like mpv is super good, but if users wanna make it even better, it's super weird to tell them to go "Enjoy your ugly and broken subtitles."

So yeah.

Peace.

ugly and broken subtitles

But that's what you get when using -vf=expand (in mplayer or when it still existed in mpv).

Anyway, enough of this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

laichiaheng picture laichiaheng  路  3Comments

olivergondza picture olivergondza  路  3Comments

jcowgill picture jcowgill  路  3Comments

532910 picture 532910  路  3Comments

fitipe picture fitipe  路  3Comments