Unsurprisingly, if a timing-less subrip decoder is desireable, an
encoder is as well. With this in place, we can move on to remove
the use of the old encoder/decoder with embedded timing and move
all timing handling the (de)muxer where they belong.
Signed-off-by: Philip Langdale <philipl@overt.org>
... | ... |
@@ -409,6 +409,7 @@ OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o |
409 | 409 |
OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o |
410 | 410 |
OBJS-$(CONFIG_SRT_ENCODER) += srtenc.o ass_split.o |
411 | 411 |
OBJS-$(CONFIG_SUBRIP_DECODER) += srtdec.o ass.o |
412 |
+OBJS-$(CONFIG_SUBRIP_ENCODER) += srtenc.o ass_split.o |
|
412 | 413 |
OBJS-$(CONFIG_SUBVIEWER_DECODER) += subviewerdec.o ass.o |
413 | 414 |
OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o |
414 | 415 |
OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o |
... | ... |
@@ -415,7 +415,7 @@ void avcodec_register_all(void) |
415 | 415 |
REGISTER_DECODER (REALTEXT, realtext); |
416 | 416 |
REGISTER_DECODER (SAMI, sami); |
417 | 417 |
REGISTER_ENCDEC (SRT, srt); |
418 |
- REGISTER_DECODER (SUBRIP, subrip); |
|
418 |
+ REGISTER_ENCDEC (SUBRIP, subrip); |
|
419 | 419 |
REGISTER_DECODER (SUBVIEWER, subviewer); |
420 | 420 |
REGISTER_ENCDEC (XSUB, xsub); |
421 | 421 |
|
... | ... |
@@ -252,16 +252,18 @@ static int srt_encode_frame(AVCodecContext *avctx, |
252 | 252 |
|
253 | 253 |
dialog = ff_ass_split_dialog(s->ass_ctx, sub->rects[i]->ass, 0, &num); |
254 | 254 |
for (; dialog && num--; dialog++) { |
255 |
- int sh, sm, ss, sc = 10 * dialog->start; |
|
256 |
- int eh, em, es, ec = 10 * dialog->end; |
|
257 |
- sh = sc/3600000; sc -= 3600000*sh; |
|
258 |
- sm = sc/ 60000; sc -= 60000*sm; |
|
259 |
- ss = sc/ 1000; sc -= 1000*ss; |
|
260 |
- eh = ec/3600000; ec -= 3600000*eh; |
|
261 |
- em = ec/ 60000; ec -= 60000*em; |
|
262 |
- es = ec/ 1000; ec -= 1000*es; |
|
263 |
- srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n", |
|
264 |
- ++s->count, sh, sm, ss, sc, eh, em, es, ec); |
|
255 |
+ if (avctx->codec->id == CODEC_ID_SRT) { |
|
256 |
+ int sh, sm, ss, sc = 10 * dialog->start; |
|
257 |
+ int eh, em, es, ec = 10 * dialog->end; |
|
258 |
+ sh = sc/3600000; sc -= 3600000*sh; |
|
259 |
+ sm = sc/ 60000; sc -= 60000*sm; |
|
260 |
+ ss = sc/ 1000; sc -= 1000*ss; |
|
261 |
+ eh = ec/3600000; ec -= 3600000*eh; |
|
262 |
+ em = ec/ 60000; ec -= 60000*em; |
|
263 |
+ es = ec/ 1000; ec -= 1000*es; |
|
264 |
+ srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n", |
|
265 |
+ ++s->count, sh, sm, ss, sc, eh, em, es, ec); |
|
266 |
+ } |
|
265 | 267 |
s->alignment_applied = 0; |
266 | 268 |
s->dialog_start = s->ptr - 2; |
267 | 269 |
srt_style_apply(s, dialog->style); |
... | ... |
@@ -289,9 +291,10 @@ static int srt_encode_close(AVCodecContext *avctx) |
289 | 289 |
return 0; |
290 | 290 |
} |
291 | 291 |
|
292 |
+#if CONFIG_SRT_ENCODER |
|
292 | 293 |
AVCodec ff_srt_encoder = { |
293 | 294 |
.name = "srt", |
294 |
- .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), |
|
295 |
+ .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle with embedded timing"), |
|
295 | 296 |
.type = AVMEDIA_TYPE_SUBTITLE, |
296 | 297 |
.id = AV_CODEC_ID_SRT, |
297 | 298 |
.priv_data_size = sizeof(SRTContext), |
... | ... |
@@ -299,3 +302,17 @@ AVCodec ff_srt_encoder = { |
299 | 299 |
.encode = srt_encode_frame, |
300 | 300 |
.close = srt_encode_close, |
301 | 301 |
}; |
302 |
+#endif |
|
303 |
+ |
|
304 |
+#if CONFIG_SUBRIP_ENCODER |
|
305 |
+AVCodec ff_subrip_encoder = { |
|
306 |
+ .name = "subrip", |
|
307 |
+ .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), |
|
308 |
+ .type = AVMEDIA_TYPE_SUBTITLE, |
|
309 |
+ .id = AV_CODEC_ID_SUBRIP, |
|
310 |
+ .priv_data_size = sizeof(SRTContext), |
|
311 |
+ .init = srt_encode_init, |
|
312 |
+ .encode = srt_encode_frame, |
|
313 |
+ .close = srt_encode_close, |
|
314 |
+}; |
|
315 |
+#endif |
... | ... |
@@ -42,6 +42,7 @@ static int srt_write_header(AVFormatContext *avf) |
42 | 42 |
return AVERROR(EINVAL); |
43 | 43 |
} |
44 | 44 |
if (avf->streams[0]->codec->codec_id != AV_CODEC_ID_TEXT && |
45 |
+ avf->streams[0]->codec->codec_id != AV_CODEC_ID_SUBRIP && |
|
45 | 46 |
avf->streams[0]->codec->codec_id != AV_CODEC_ID_SRT) { |
46 | 47 |
av_log(avf, AV_LOG_ERROR, |
47 | 48 |
"Unsupported subtitles codec: %s\n", |
... | ... |
@@ -19,6 +19,9 @@ fate-sub-sami: CMD = md5 -i $(SAMPLES)/sub/SAMI_capability_tester.smi -f ass |
19 | 19 |
FATE_SUBTITLES += fate-sub-srt |
20 | 20 |
fate-sub-srt: CMD = md5 -i $(SAMPLES)/sub/SubRip_capability_tester.srt -f ass |
21 | 21 |
|
22 |
+FATE_SUBTITLES += fate-sub-subripenc |
|
23 |
+fate-sub-subripenc: CMD = md5 -i $(SAMPLES)/sub/MovText_capability_tester.mp4 -scodec subrip -f srt |
|
24 |
+ |
|
22 | 25 |
FATE_SUBTITLES += fate-sub-subviewer |
23 | 26 |
fate-sub-subviewer: CMD = md5 -i $(SAMPLES)/sub/SubViewer_capability_tester.sub -f ass |
24 | 27 |
|