Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Traian Coza <traian.coza@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Traian Coza <traian.coza@gmail.com>
Subject: [FFmpeg-devel] [PATCH 11/12] Added logging
Date: Tue,  3 May 2022 12:13:27 -0400
Message-ID: <20220503161328.842587-12-traian.coza@gmail.com> (raw)
In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com>

---
 fftools/ffmpeg.c         |  4 +++-
 fftools/text_to_bitmap.c | 27 ++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 251a3ce427..b4d3d491de 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3244,7 +3244,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
             if (input_props && output_props && input_props != output_props) {
                 snprintf(error, error_len,
                          "Subtitle encoding currently only possible from text to text "
-                         "or bitmap to bitmap");
+                         "or bitmap to bitmap (configure with --enable-libass for text to bitmap support)");
                 return AVERROR_INVALIDDATA;
             }
 #endif
@@ -4514,8 +4514,10 @@ static int transcode(void)
         ist = input_streams[i];
         if (ist->decoding_needed) {
             avcodec_close(ist->dec_ctx);
+#if CONFIG_LIBASS
             if (ist->dec_ctx->ass_context != NULL)     // This really has to be done here, sorry
                 free_ass_context(ist->dec_ctx->ass_context);
+#endif
             if (ist->hwaccel_uninit)
                 ist->hwaccel_uninit(ist->dec_ctx);
         }
diff --git a/fftools/text_to_bitmap.c b/fftools/text_to_bitmap.c
index b4a0157174..0f165e7722 100644
--- a/fftools/text_to_bitmap.c
+++ b/fftools/text_to_bitmap.c
@@ -40,6 +40,30 @@ struct ASS_Context {
     ASSSplitContext *ass_split_context;
 };
 
+// Copied from vf_subtitles.c
+/* libass supports a log level ranging from 0 to 7 */
+static const int ass_libavfilter_log_level_map[] = {
+        [0] = AV_LOG_FATAL,     /* MSGL_FATAL */
+        [1] = AV_LOG_ERROR,     /* MSGL_ERR */
+        [2] = AV_LOG_WARNING,   /* MSGL_WARN */
+        [3] = AV_LOG_WARNING,   /* <undefined> */
+        [4] = AV_LOG_INFO,      /* MSGL_INFO */
+        [5] = AV_LOG_INFO,      /* <undefined> */
+        [6] = AV_LOG_VERBOSE,   /* MSGL_V */
+        [7] = AV_LOG_DEBUG,     /* MSGL_DBG2 */
+};
+
+// Also copied
+static void ass_log(int ass_level, const char *fmt, va_list args, void *ctx)
+{
+    const int ass_level_clip = av_clip(ass_level, 0,
+        FF_ARRAY_ELEMS(ass_libavfilter_log_level_map) - 1);
+    const int level = ass_libavfilter_log_level_map[ass_level_clip];
+
+    av_vlog(NULL, level, fmt, args);
+    av_log(NULL, level, "\n");
+}
+
 /**
  * Initiates the ASS_Context structure and adds it to the input stream decoder context.
  * Does nothing if ist->dec_ctx->ass_context is already set.
@@ -57,6 +81,7 @@ void init_ass_context(InputStream *ist, OutputStream *ost)
 
     ASS_Context *context = (ASS_Context *)malloc(sizeof(ASS_Context));
     context->library = ass_library_init();
+    ass_set_message_cb(context->library, ass_log, NULL);
     ass_set_extract_fonts(context->library, 1);
     // TODO: ass_add_font(context->library, ...);
 
@@ -172,7 +197,7 @@ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub)
 
         ASS_Image *image = ass_render_frame(context->renderer, track,
             track->events[0].Start + track->events[0].Duration / 2, NULL);
-        if (image == NULL) printf("WARNING: failed to render ass\n");
+        if (image == NULL) av_log(NULL, AV_LOG_WARNING, "failed to render ass\n");
 
         rect->x = image ? image->dst_x : 0; rect->w = 0;
         rect->y = image ? image->dst_y : 0; rect->h = 0;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-05-03 16:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 16:13 [FFmpeg-devel] [PATCH 00/12] I added text to bitmap subtitle conversion functionality! Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 01/12] Implemented text to bitmap subtitles! Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 02/12] Render only when necessary Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 03/12] Retreive width and height from video stream! Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 04/12] Initialize ass library only once! Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 05/12] Cleaned up Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 06/12] Wrote proper headers Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 07/12] Close libass after using Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 08/12] Added standard headers Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 09/12] Rearranged files, all tests are passing! Traian Coza
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 10/12] " Traian Coza
2022-05-03 16:13 ` Traian Coza [this message]
2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 12/12] Added more logging Traian Coza
2022-05-03 16:20 ` [FFmpeg-devel] [PATCH 00/12] I added text to bitmap subtitle conversion functionality! Paul B Mahol
2022-05-03 16:51   ` Nicolas George
2022-05-03 17:01     ` Traian Coza
2022-05-03 17:05       ` Leo Izen
2022-05-03 17:09         ` Traian Coza
2022-05-03 16:27 ` Soft Works
2022-05-04  0:16   ` Soft Works

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220503161328.842587-12-traian.coza@gmail.com \
    --to=traian.coza@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git