Opened 12 months ago

#10356 new defect

Incorrect escaping text from srt subtitles

Reported by: Ashark Owned by:
Priority: normal Component: undetermined
Version: 6.0 Keywords:
Cc: Ashark Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I want to literally place "\n" string (not actually a line break) to the video. I created an srt file and hardsubbed it with subtitle video vilter:

$ ffmpeg -hide_banner -loglevel error -y -f lavfi -i color=size=1280x720:rate=10:color=black -vf "subtitles=subtitle_with_n.srt:force_style='Alignment=10,Fontsize=12'" -frames:v 1 output.png
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.1 (GCC) 20230201

But the escaping is done wrong. To hardsub the "\n" string, I escape backslash in srt: "
n". But instead of escaping the backslash, it escapes the n, and the first '\' is written as is.

I created this file subtitle_with_n.srt:

1
00:00:00,000 --> 10:00:00,000
line 1 \ \ \ backslash ampersand entity (also tried N letter entity) neither work in vlc nor in ffmpeg.
line 2 \\n escapes n instead backslash. On vlc it makes backslash and breaks line. On ffmpeg it is backslash and space.
line 3 \⁠n used wordjoiner (U+2060), works
line 4 \​n zero width space, works in vlc, works in ffmpeg.
line 5 \n breaks line in vlc, make space in ffmpeg. <b>Bold</b> tag works in both.
line 6 \<i></i>n works for vlc, but in ffmpeg it is wrong.

This is self commenting. See screenshot for result.
The expected non-crutch way is escaping work as normal: going from left to right of the string.

Additional info:
#9058 - bug about possibility to encode ampersand entities.
#9808 - similar bug about escaping in another type of subtitles
https://github.com/libass/libass/issues/194#issuecomment-351902555 - workaround by using word joiner symbol.

Attachments (2)

output.png (68.3 KB ) - added by Ashark 12 months ago.
Shows the result of burning subtitle
subtitle_with_n.srt (520 bytes ) - added by Ashark 12 months ago.
The srt file with special characters (wordjoiner and zero width space)

Download all attachments as: .zip

Change History (2)

by Ashark, 12 months ago

Attachment: output.png added

Shows the result of burning subtitle

by Ashark, 12 months ago

Attachment: subtitle_with_n.srt added

The srt file with special characters (wordjoiner and zero width space)

Note: See TracTickets for help on using tickets.