1 /*
2 * SubRip subtitle muxer
3 * Copyright (c) 2012 Nicolas George <nicolas.george@normalesup.org>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
26
27 /* TODO: add options for:
28 - character encoding;
29 - LF / CRLF;
30 - byte order mark.
31 */
32
36
38 {
40
44 "SRT supports only a single subtitles stream.\n");
46 }
51 "Unsupported subtitles codec: %s\n",
54 }
57 return 0;
58 }
59
61 {
64
65 if (write_ts) {
67 int size, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
69
71 if (p && size == 16) {
76 }
77
78 if (d <= 0)
79 /* For backward compatibility, fallback to convergence_duration. */
83 "Insufficient timestamps in event number %d.\n", srt->
index);
84 return 0;
85 }
86 e = s + d;
87 avio_printf(avf->
pb,
"%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d",
89 (int)(s / 3600000), (int)(s / 60000) % 60,
90 (int)(s / 1000) % 60, (int)(s % 1000),
91 (int)(e / 3600000), (int)(e / 60000) % 60,
92 (int)(e / 1000) % 60, (int)(e % 1000));
93 if (p)
95 x1, x2, y1, y2);
97 }
99 if (write_ts)
102 return 0;
103 }
104
108 .mime_type = "application/x-subrip",
109 .extensions = "srt",
115 };