]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/srtenc.c
Merge commit '1098f5c0495c61a98d4ff6b8e24c17974d4bace5'
[ffmpeg] / libavcodec / srtenc.c
index 0a6875a51abe88c8a1c95481619f536e5b70dac5..51439843b9c8f790dd891b4f5a976d46ca8b3645 100644 (file)
@@ -232,23 +232,39 @@ static int encode_frame(AVCodecContext *avctx,
 {
     SRTContext *s = avctx->priv_data;
     ASSDialog *dialog;
-    int i, num;
+    int i;
 
     av_bprint_clear(&s->buffer);
 
     for (i=0; i<sub->num_rects; i++) {
+        const char *ass = sub->rects[i]->ass;
 
         if (sub->rects[i]->type != SUBTITLE_ASS) {
             av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
             return AVERROR(ENOSYS);
         }
 
-        dialog = ff_ass_split_dialog(s->ass_ctx, sub->rects[i]->ass, 0, &num);
-        for (; dialog && num--; dialog++) {
+#if FF_API_ASS_TIMING
+        if (!strncmp(ass, "Dialogue: ", 10)) {
+            int num;
+            dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num);
+            for (; dialog && num--; dialog++) {
+                s->alignment_applied = 0;
+                srt_style_apply(s, dialog->style);
+                ff_ass_split_override_codes(cb, s, dialog->text);
+            }
+        } else {
+#endif
+            dialog = ff_ass_split_dialog2(s->ass_ctx, ass);
+            if (!dialog)
+                return AVERROR(ENOMEM);
             s->alignment_applied = 0;
             srt_style_apply(s, dialog->style);
             ff_ass_split_override_codes(cb, s, dialog->text);
+            ff_ass_free_dialog(&dialog);
+#if FF_API_ASS_TIMING
         }
+#endif
     }
 
     if (!av_bprint_is_complete(&s->buffer))