1 /*
2 * SSA/ASS common functions
3 * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.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
28
30 const char *font, int font_size,
31 int color,
int back_color,
32 int bold, int italic, int underline,
33 int alignment)
34 {
36 "[Script Info]\r\n"
37 "ScriptType: v4.00+\r\n"
38 "\r\n"
39 "[V4+ Styles]\r\n"
40 "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding\r\n"
41 "Style: Default,%s,%d,&H%x,&H%x,&H%x,&H%x,%d,%d,%d,1,1,0,%d,10,10,10,0,0\r\n"
42 "\r\n"
43 "[Events]\r\n"
44 "Format: Layer, Start, End, Style, Text\r\n",
45 font, font_size, color, color, back_color, back_color,
46 -bold, -italic, -underline, alignment);
47
51 return 0;
52 }
53
55 {
64 }
65
67 {
68 if (ts == -1) {
70 } else {
72
73 h = ts/360000; ts -= 360000*h;
74 m = ts/ 6000; ts -= 6000*
m;
75 s = ts/ 100; ts -= 100*
s;
76 av_bprintf(buf,
"%d:%02d:%02d.%02d,", h, m, s, ts);
77 }
78 }
79
82 {
86
88 if (!raw || raw == 2) {
89 long int layer = 0;
90
91 if (raw == 2) {
92 /* skip ReadOrder */
93 dialog = strchr(dialog, ',');
94 if (!dialog)
96 dialog++;
97
98 /* extract Layer or Marked */
99 layer = strtol(dialog, (char**)&dialog, 10);
100 if (*dialog != ',')
102 dialog++;
103 }
106 insert_ts(&buf, duration == -1 ? -1 : ts_start + duration);
107 if (raw != 2)
109 }
110
111 dlen = strcspn(dialog, "\n");
112 dlen += dialog[dlen] == '\n';
113
115 if (raw == 2)
119
121 if (!rects)
128 if (ret < 0)
131 return dlen;
132 }