Opened 9 months ago

Last modified 4 months ago

#9669 new defect

Subtitles video filter does not correctly rotate/position some Japanese punctuation characters in vertical ASS subtitles

Reported by: y3kcjd5 Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Certain Japanese punctuation characters have to be oriented a certain way for vertical display of subtitles to look correct. The "subtitles" video filter gets it wrong with some characters. I'm attaching some demo files to demonstrate the characters I've found, but there are probably more I've missed.

How to reproduce:
Run a command such as

ffmpeg -i "5-sec-blank.mp4" -map 0:0 -report -loglevel verbose -map_chapters -1 -map_metadata -1 -vsync "passthrough" -aspect 16:9 -c:v libx264 -movflags faststart -preset slower -x264-params partitions=all:ref=6:me=umh:subme=10:merange=64:trellis=2:fast-pskip=0:bframes=6:b_adapt=2:direct=auto:rc_lookahead=60:crf=20:qcomp=0.80:qpmax=30:qpstep=4 -sws_flags spline+full_chroma_int+full_chroma_inp+accurate_rnd -filter:v subtitles="misrotationdemosubs.ass":original_size=1920x1080:alpha=1,format=yuv420p "subtitlehardcode.mp4"

and observe the orientation of the characters hardcoded into the video, then either open the .ass file directly with subtitling software such as Aegisub, or run something like

ffmpeg -i "5-sec-blank.mp4" -i "misrotationdemosubs.ass" -map 0:0 -map 1:0 -c copy subtitlesoftcode.mkv

and play the resulting file in a media player with ASS subtitle support (mine uses DirectVobSub).

I am running ffmpeg-2022-02-28-git-7a4840a8ca-full_build from gyan.dev in a Windows environment. If you can't get your hands on the "MS UI Gothic" font, just text edit the entry in the .ass file to something on your system (but keep the '@' mark at the beginning that denotes vertical orientation).

Attachments (5)

misrotationdemosubs.ass (1.0 KB ) - added by y3kcjd5 9 months ago.
.ass subtitle file demonstrating vertical Japanese subtitles
5-sec-blank.mp4 (25.4 KB ) - added by y3kcjd5 9 months ago.
A blank 1920x1080 video to use as a template
verticalhardsubsbad.png (86.6 KB ) - added by y3kcjd5 9 months ago.
What happens when the "subtitles" filter hardcodes the subtitles
verticalsoftsubsgood.png (56.7 KB ) - added by y3kcjd5 9 months ago.
What subtitles should look like (through DirectVobSub)
asscode.png (82.0 KB ) - added by y3kcjd5 9 months ago.
What happens when the ass filter (libass) hardcodes the subs

Download all attachments as: .zip

Change History (14)

by y3kcjd5, 9 months ago

Attachment: misrotationdemosubs.ass added

.ass subtitle file demonstrating vertical Japanese subtitles

by y3kcjd5, 9 months ago

Attachment: 5-sec-blank.mp4 added

A blank 1920x1080 video to use as a template

by y3kcjd5, 9 months ago

Attachment: verticalhardsubsbad.png added

What happens when the "subtitles" filter hardcodes the subtitles

by y3kcjd5, 9 months ago

Attachment: verticalsoftsubsgood.png added

What subtitles should look like (through DirectVobSub)

comment:1 by Elon Musk, 9 months ago

Please check with mpv player.

If it does not display correctly that it is not ffmpeg issue but libass issue which ffmpeg use. Unable to reproduce due to missing font.

comment:2 by y3kcjd5, 9 months ago

I'm running into trouble getting mpv player set up.
Did you try changing the font in the .ass file to a font you do have as I described above?
Alternatively, does the "ass" video filter also use libass? Running the first command with that filter instead gives more broken but more correctly rotated results, so if they share libass, that's not the problem.

Edit: I think I got mpv working, and it looks identical to the "ass" filter output, so I'm assuming that's libass's work. That suggests that whatever the "subtitles" filter did to fix the broken positioning from libass also messed up some of the rotation.

Last edited 9 months ago by y3kcjd5 (previous) (diff)

comment:3 by Elon Musk, 9 months ago

Yea report bug to libass project.

in reply to:  3 comment:4 by y3kcjd5, 9 months ago

Replying to Elon Musk:

Yea report bug to libass project.

Uh, what? The subtitles filter broke rotation. That's not libass.

comment:5 by Elon Musk, 9 months ago

subtitle filter code use same logic for drawing subtitles like ass filter.

in reply to:  5 ; comment:6 by y3kcjd5, 9 months ago

Replying to Elon Musk:

subtitle filter code use same logic for drawing subtitles like ass filter.

Apparently not, because the results look different. The one thing the ass filter (and mpv player) mostly got right is the rotation.

by y3kcjd5, 9 months ago

Attachment: asscode.png added

What happens when the ass filter (libass) hardcodes the subs

in reply to:  6 ; comment:7 by Elon Musk, 9 months ago

Replying to y3kcjd5:

Replying to Elon Musk:

subtitle filter code use same logic for drawing subtitles like ass filter.

Apparently not, because the results look different. The one thing the ass filter (and mpv player) mostly got right is the rotation.

Look at source code, your statement is contradiction with reality.

Anyway it is highly unlikely, definitely impossible this will ever get fixed here and not in libass.

in reply to:  7 comment:8 by y3kcjd5, 9 months ago

Replying to Elon Musk:

Look at source code, your statement is contradiction with reality.

I don't see how you can call it a contradiction with reality when I've posted screenshots demonstrating the discrepancies. Have you at least tried changing the font and running the commands yourself?

comment:9 by y3kcjd5, 4 months ago

I've finally figured out why the "subtitles" and "ass" filters were returning different results, despite both using libass for rendering; it turns out that the "subtitles" filter only uses the "simple" renderer in libass for some reason (and there's no option to change it). The "ass" filter can be forced to reproduce the same output by including "shaping=simple" in its options (the default is "auto"). I've already reported the underlying spacing/positioning issues on the libass github, so this ticket has effectively boiled down to changing the "subtitles" filter to use libass's "auto" rendering setting like the "ass" filter does by default.

Note: See TracTickets for help on using tickets.