From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 16A3842CC3 for ; Tue, 3 May 2022 16:15:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13DB268B3D5; Tue, 3 May 2022 19:14:05 +0300 (EEST) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 818E568B3AB for ; Tue, 3 May 2022 19:14:00 +0300 (EEST) Received: by mail-qt1-f179.google.com with SMTP id o11so13835302qtp.13 for ; Tue, 03 May 2022 09:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FNWBREmPOz00ix4ARQtcFegK/3Fr0l/77E1bgQgJhmI=; b=WpWHLCjqT8BFlx/iD1ZII29zQProS0DZuKa6A1eiC3YqqnRMhmrtH6vDfmNWZN1X78 JsoBC5Ab6ibf51/ILrIXSu7+MmSGxovAJurn3jG4QcGGJZXNE1pyXTLPeCwo1isiVldd 2INT1nkKzXM0IBSoejir32JvCZlGpGYPp2ZXGz4DfSA5tRscxb8wUM2mmDKmp/jRky0i lH776Jgv7OLE9odLB1Sjw0+7w/30il8pDdtgT5k6aNUSup6EPRMeeCIqNfgBo99IloA5 ocMctxqpfOe9K9kLeL5Ie2ZSHtTErXqo3/dmKzM991FRP8hgCGM6L4Om4dGpPQ1I7Tin Zp3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FNWBREmPOz00ix4ARQtcFegK/3Fr0l/77E1bgQgJhmI=; b=uQp9+jRSQC/6q35Lu6ublehEbqMStmxR4omlMNnDHPALpeQutUIa/rFo5N4KHkqbAS oNkgXTBq2ueOj9tWF6WXxx92zMn1K5utty4BRuAQawCPbIRV6FXHJDjKPD24qOlq0V74 +4Zu7/BerywS0CXiTAq4HJYMslnpkbas8K7FFhBI7H2A6iXS0qGH5CKqgAsXaBTEaBt2 AAnEKF6bDnF2RuWrNZnOBmJT6eTZR8PJInV0SxMONTVsshUffh/K1eDbAKn8kHEdyeIo fah9ZpTawPg+jj5pirSmfO6G4B/crhgyCkoJCZf9B9NOOdrzWp/UeYx9hdnoGmlNHCRa ouAw== X-Gm-Message-State: AOAM533X1ZWpqQbECKHnyQ3V7WuiogvwvWaJosd3qD1AtNRHuG72Tfue HxaRRUoVTFsN/Nb9IO84+p+JjxbSInjh X-Google-Smtp-Source: ABdhPJxqhbxUZhZND5glwggKvId+nYS23T+kwk4ovZE8IZL6xS5yDo+eiiGm/dJbDO0sZ+3Jb64yzg== X-Received: by 2002:ac8:5c07:0:b0:2f1:fe44:e72b with SMTP id i7-20020ac85c07000000b002f1fe44e72bmr15608144qti.319.1651594438932; Tue, 03 May 2022 09:13:58 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:58 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:27 -0400 Message-Id: <20220503161328.842587-12-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/12] Added logging X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Traian Coza Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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, /* */ + [4] = AV_LOG_INFO, /* MSGL_INFO */ + [5] = AV_LOG_INFO, /* */ + [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".