1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/srtenc: don't produce SRT files with mixed line endings

Initially, avcodec/srtenc.c was outputting CRLF [1]. Later, a real SRT
muxer was added [2], which outputs LF. The original srtenc.c was
converted to use the muxer [3], changing its output to LF, except for
newline characters within subtitle text.

Fix this to avoid producing SRT files with mixed line endings.

[1] 8e43b6fed9
[2] 9e63c30daa
[3] 55180b3299

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
Kacper Michajłow
2025-08-01 23:49:50 +02:00
parent 5bd7003e81
commit 5c95e8e3a6
4 changed files with 71 additions and 71 deletions

View File

@ -145,7 +145,7 @@ static void srt_text_cb(void *priv, const char *text, int len)
static void srt_new_line_cb(void *priv, int forced) static void srt_new_line_cb(void *priv, int forced)
{ {
srt_print(priv, "\r\n"); srt_print(priv, "\n");
} }
static void srt_style_cb(void *priv, char style, int close) static void srt_style_cb(void *priv, char style, int close)

View File

@ -20,16 +20,16 @@
6 6
00:00:03,103 --> 00:00:03,303 00:00:03,103 --> 00:00:03,303
<font face="Monospace">{\an7}(<i> inaudible radio chatter</i> ) <font face="Monospace">{\an7}(<i> inaudible radio chatter</i> )
>></font> >></font>
7 7
00:00:03,303 --> 00:00:03,503 00:00:03,303 --> 00:00:03,503
<font face="Monospace">{\an7}(<i> inaudible radio chatter</i> ) <font face="Monospace">{\an7}(<i> inaudible radio chatter</i> )
>> Safety rema</font> >> Safety rema</font>
8 8
00:00:03,504 --> 00:00:03,704 00:00:03,504 --> 00:00:03,704
<font face="Monospace">{\an7}(<i> inaudible radio chatter</i> ) <font face="Monospace">{\an7}(<i> inaudible radio chatter</i> )
>> Safety remains our numb</font> >> Safety remains our numb</font>

View File

@ -1,6 +1,6 @@
1 1
00:00:00,970 --> 00:00:02,540 00:00:00,970 --> 00:00:02,540
<font face="Serif" size="18">- Test 1. <font face="Serif" size="18">- Test 1.
- Test 2.</font> - Test 2.</font>
2 2
@ -9,6 +9,6 @@
3 3
00:00:05,850 --> 00:00:08,140 00:00:05,850 --> 00:00:08,140
<font face="Serif" size="18">- Test 4. <font face="Serif" size="18">- Test 4.
- Test 5.</font> - Test 5.</font>

View File

@ -4,11 +4,11 @@ Don't show this text it may be used to insert hidden data
2 2
00:00:01,500 --> 00:00:04,500 00:00:01,500 --> 00:00:04,500
SubRip subtitles capability tester 1.3o by ale5000 SubRip subtitles capability tester 1.3o by ale5000
Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others
This text should be blue This text should be blue
This text should be red This text should be red
This text should be black This text should be black
If you see this with the normal font, the player don't (fully) support font face If you see this with the normal font, the player don't (fully) support font face
3 3
@ -17,43 +17,43 @@ Hidden
4 4
00:00:04,501 --> 00:00:07,500 00:00:04,501 --> 00:00:07,500
This text should be small This text should be small
This text should be normal This text should be normal
This text should be big This text should be big
5 5
00:00:07,501 --> 00:00:11,500 00:00:07,501 --> 00:00:11,500
This should be an E with an accent: È This should be an E with an accent: È
日本語 日本語
This text should be bold, italics and underline This text should be bold, italics and underline
This text should be small and green This text should be small and green
This text should be small and red This text should be small and red
This text should be big and brown This text should be big and brown
6 6
00:00:11,501 --> 00:00:14,500 00:00:11,501 --> 00:00:14,500
This line should be bold This line should be bold
This line should be italics This line should be italics
This line should be underline This line should be underline
This line should be strikethrough This line should be strikethrough
Both lines Both lines
should be underline should be underline
7 7
00:00:14,501 --> 00:00:17,500 00:00:14,501 --> 00:00:17,500
> >
It would be a good thing to It would be a good thing to
hide invalid html tags that are closed and show the text in them hide invalid html tags that are closed and show the text in them
but show un-closed invalid html tags but show un-closed invalid html tags
Show not opened tags Show not opened tags
< <
8 8
00:00:17,501 --> 00:00:20,500 00:00:17,501 --> 00:00:20,500
and also and also
hide invalid html tags with parameters that are closed and show the text in them hide invalid html tags with parameters that are closed and show the text in them
but show un-closed invalid html tags but show un-closed invalid html tags
This text should be showed underlined without problems also: 2<3,5>1,4<6 This text should be showed underlined without problems also: 2<3,5>1,4<6
This shouldn't be underlined This shouldn't be underlined
9 9
@ -66,49 +66,49 @@ This text should NOT be in the normal position
11 11
00:00:22,501 --> 00:00:24,500 00:00:22,501 --> 00:00:24,500
Implementation is the same of the ASS tag Implementation is the same of the ASS tag
This text should be at the This text should be at the
top and horizontally centered top and horizontally centered
12 12
00:00:22,501 --> 00:00:24,500 00:00:22,501 --> 00:00:24,500
This text should be at the This text should be at the
middle and horizontally centered middle and horizontally centered
13 13
00:00:22,501 --> 00:00:24,500 00:00:22,501 --> 00:00:24,500
This text should be at the This text should be at the
bottom and horizontally centered bottom and horizontally centered
14 14
00:00:24,501 --> 00:00:26,500 00:00:24,501 --> 00:00:26,500
This text should be at the This text should be at the
top and horizontally at the left top and horizontally at the left
15 15
00:00:24,501 --> 00:00:26,500 00:00:24,501 --> 00:00:26,500
This text should be at the This text should be at the
middle and horizontally at the left middle and horizontally at the left
(The second position must be ignored) (The second position must be ignored)
16 16
00:00:24,501 --> 00:00:26,500 00:00:24,501 --> 00:00:26,500
This text should be at the This text should be at the
bottom and horizontally at the left bottom and horizontally at the left
17 17
00:00:26,501 --> 00:00:28,500 00:00:26,501 --> 00:00:28,500
This text should be at the This text should be at the
top and horizontally at the right top and horizontally at the right
18 18
00:00:26,501 --> 00:00:28,500 00:00:26,501 --> 00:00:28,500
This text should be at the This text should be at the
middle and horizontally at the right middle and horizontally at the right
19 19
00:00:26,501 --> 00:00:28,500 00:00:26,501 --> 00:00:28,500
This text should be at the This text should be at the
bottom and horizontally at the right bottom and horizontally at the right
20 20
@ -137,7 +137,7 @@ Fifth, it should replace third
26 26
00:00:45,501 --> 00:00:50,500 00:00:45,501 --> 00:00:50,500
Sixth, it shouldn't be Sixth, it shouldn't be
showed overlapped showed overlapped
27 27
@ -150,64 +150,64 @@ text 2
29 29
00:00:52,501 --> 00:00:54,500 00:00:52,501 --> 00:00:54,500
Hide these tags: Hide these tags:
also hide these tags: also hide these tags:
but show this: {normal text} but show this: {normal text}
30 30
00:00:54,501 --> 00:01:00,500 00:00:54,501 --> 00:01:00,500
\ N is a forced line break \ N is a forced line break
\ h is a hard space \ h is a hard space
Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed. Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.
The\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D The\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D
31 31
00:00:54,501 --> 00:00:56,500 00:00:54,501 --> 00:00:56,500
\h\h\h\h\hA (05 hard spaces followed by a letter) \h\h\h\h\hA (05 hard spaces followed by a letter)
A (Normal spaces followed by a letter) A (Normal spaces followed by a letter)
A (No hard spaces followed by a letter) A (No hard spaces followed by a letter)
32 32
00:00:56,501 --> 00:00:58,500 00:00:56,501 --> 00:00:58,500
\h\h\h\h\hA (05 hard spaces followed by a letter) \h\h\h\h\hA (05 hard spaces followed by a letter)
A (Normal spaces followed by a letter) A (Normal spaces followed by a letter)
A (No hard spaces followed by a letter) A (No hard spaces followed by a letter)
Show this: \TEST and this: \-) Show this: \TEST and this: \-)
33 33
00:00:58,501 --> 00:01:00,500 00:00:58,501 --> 00:01:00,500
A letter followed by 05 hard spaces: A\h\h\h\h\h A letter followed by 05 hard spaces: A\h\h\h\h\h
A letter followed by normal spaces: A A letter followed by normal spaces: A
A letter followed by no hard spaces: A A letter followed by no hard spaces: A
05 hard spaces between letters: A\h\h\h\h\hA 05 hard spaces between letters: A\h\h\h\h\hA
5 normal spaces between letters: A A 5 normal spaces between letters: A A
^--Forced line break ^--Forced line break
34 34
00:01:00,501 --> 00:01:02,500 00:01:00,501 --> 00:01:02,500
Both line should be strikethrough, Both line should be strikethrough,
yes. yes.
Correctly closed tags Correctly closed tags
should be hidden. should be hidden.
35 35
00:01:02,501 --> 00:01:04,500 00:01:02,501 --> 00:01:04,500
It shouldn't be strikethrough, It shouldn't be strikethrough,
not opened tag showed as text. not opened tag showed as text.
Not opened tag showed as text. Not opened tag showed as text.
36 36
00:01:04,501 --> 00:01:06,500 00:01:04,501 --> 00:01:06,500
Three lines should be strikethrough, Three lines should be strikethrough,
yes. yes.
Not closed tags showed as text Not closed tags showed as text
37 37
00:01:06,501 --> 00:01:08,500 00:01:06,501 --> 00:01:08,500
Both line should be strikethrough but Both line should be strikethrough but
the wrong closing tag should be showed the wrong closing tag should be showed