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 }
50 "Unsupported subtitles codec: %s\n",
53 }
56 return 0;
57 }
58
60 {
62
64 int size, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
66
68 if (p && size == 16) {
73 }
74
75 #if FF_API_CONVERGENCE_DURATION
77 if (d <= 0)
78 /* For backward compatibility, fallback to convergence_duration. */
81 #endif
84 "Insufficient timestamps in event number %d.\n", srt->
index);
85 return 0;
86 }
87 e = s + d;
88 avio_printf(avf->
pb,
"%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d",
90 (int)(s / 3600000), (int)(s / 60000) % 60,
91 (int)(s / 1000) % 60, (int)(s % 1000),
92 (int)(e / 3600000), (int)(e / 60000) % 60,
93 (int)(e / 1000) % 60, (int)(e % 1000));
94 if (p)
96 x1, x2, y1, y2);
98
102 return 0;
103 }
104
108 .mime_type = "application/x-subrip",
109 .extensions = "srt",
115 };
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream ** streams
A list of all streams in the file.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVCodecContext * codec
Codec context associated with this stream.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
enum AVMediaType codec_type
AVIOContext * pb
I/O context.
attribute_deprecated int64_t convergence_duration
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2