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 35FCF47234 for ; Fri, 1 Sep 2023 23:15:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0AFCF68C7C0; Sat, 2 Sep 2023 02:15:03 +0300 (EEST) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE76968C79E for ; Sat, 2 Sep 2023 02:14:55 +0300 (EEST) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-401187f8071so2912555e9.0 for ; Fri, 01 Sep 2023 16:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693610094; x=1694214894; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v1mTUUmGSygattHd4A6+Srb0MFWpuiqm9Ihydzy/Zrc=; b=gUAXiiYLlttkaDDrHbIkcJSTxG+ZutAxszJl7nN0/NQv9OC/cBtOd8mhol+eNGmfIa 1S0UYb+i4HVNBsxvoyC7zTnSl4zoTr8WK/L2H4qTMc/zkslJni46wyIMHbDcELlhvPMm 3mh6wOvf+riqLl4HBo9Sjn6tAibBQEnIxy4BGdNXn+SrFclf4OSHn6BnuCLSXZEhKe/U qehVtfCl6Ctz5BwFkURnVtDmm2pnFDVlY7W3QwJBi877h8Gntyyxcfp+j9HEXTTEtV0f uOppLcKuzgBBs4/QWq4BZ755Xde/fbY6Uoa9AogutUoXy9+f+T572zfhLzcS6Ks0u+e2 PrAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693610094; x=1694214894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v1mTUUmGSygattHd4A6+Srb0MFWpuiqm9Ihydzy/Zrc=; b=K1lLxFWn8TOaU9pgSBabAXM3wi0AvViUDFsxMiDjZtsZ70OQUD4OQZvNo7knJRPGFr VAkPStROIR+z6uE9h2jUyAUvSaMb8UfXi/Mfnb/Qng+umhS0NAE43yp7k/gW+wGIBFJ4 uZPj3pai2uxRajBDkryj07imwFFAhq3k1k2ULwpPhJoQUKuC512tYPtOx+dD7R9g6D4S uiY2hoEffOGGiudUbxYjd9om+TTc/jSBHDfhupIU2VzAQlnMQ/4ovCL2GFbuxlQDmL/K bjti6UcpECZH7H7TOyzmS5/GLGFgRPwz+b/k17ou9m0uQT29RYPqc2BNr3tAGdmoJOZ2 DpSQ== X-Gm-Message-State: AOJu0Yx7+ETKvwu8e34Ldw3DP31+FS0bR/+5LOBUnf0q2EAQsQp8caiy k3NtibP1XMvzq1nNxvfZ6uTol7xHPMU= X-Google-Smtp-Source: AGHT+IFla5oPOcXGRigV2xZgrSaTIKTHJFQWwUgENjrOmuKZ57vxLwVGupV13sjw+uh2S8hGFK8YAA== X-Received: by 2002:a05:600c:4709:b0:401:bd94:f45b with SMTP id v9-20020a05600c470900b00401bd94f45bmr4922794wmo.4.1693610094317; Fri, 01 Sep 2023 16:14:54 -0700 (PDT) Received: from mariano ([82.84.194.139]) by smtp.gmail.com with ESMTPSA id n17-20020a7bcbd1000000b003fee777fd84sm6120515wmi.41.2023.09.01.16.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:14:52 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 79DA1BFCE4; Sat, 2 Sep 2023 01:14:47 +0200 (CEST) From: Stefano Sabatini To: FFmpeg development discussions and patches Date: Sat, 2 Sep 2023 01:14:47 +0200 Message-Id: <20230901231447.1486347-6-stefasab@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901231447.1486347-1-stefasab@gmail.com> References: <20230901231447.1486347-1-stefasab@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] doc/examples/transcode: introduce timestamp 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: Stefano Sabatini 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: Aid timestamp debugging. --- doc/examples/transcode.c | 45 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c index b4b2d3c4c9..983a8f2845 100644 --- a/doc/examples/transcode.c +++ b/doc/examples/transcode.c @@ -37,6 +37,7 @@ #include #include #include +#include static AVFormatContext *ifmt_ctx; static AVFormatContext *ofmt_ctx; @@ -435,6 +436,28 @@ static int init_filters(void) return 0; } +static void log_packet(AVPacket *pkt, const AVFormatContext *fmt_ctx, const char *tag) +{ + AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base; + + av_log(NULL, AV_LOG_INFO, + "%s [pkt] stream:%d tb:%d/%d pts_time:%s dts_time:%s\n", + tag, pkt->stream_index, time_base->num, time_base->den, + av_ts2timestr(pkt->pts, time_base), + av_ts2timestr(pkt->dts, time_base)); +} + +static void log_frame(AVFrame *frame, int stream_index, const char *tag) +{ + AVRational *time_base = &frame->time_base; + + av_log(NULL, AV_LOG_INFO, + "%s [frame] stream:%d tb:%d/%d pts_time:%s dts_time:%s\n", + tag, stream_index, time_base->num, time_base->den, + av_ts2timestr(frame->pts, time_base), + av_ts2timestr(frame->pkt_dts, time_base)); +} + static int encode_write_frame(unsigned int stream_index, int flush) { StreamContext *stream = &stream_ctx[stream_index]; @@ -443,16 +466,16 @@ static int encode_write_frame(unsigned int stream_index, int flush) AVPacket *enc_pkt = filter->enc_pkt; int ret; - av_log(NULL, AV_LOG_INFO, "Encoding frame\n"); /* encode filtered frame */ av_packet_unref(enc_pkt); - if (filt_frame && filt_frame->pts != AV_NOPTS_VALUE) + if (filt_frame && filt_frame->pts != AV_NOPTS_VALUE) { filt_frame->pts = av_rescale_q(filt_frame->pts, filt_frame->time_base, stream->enc_ctx->time_base); + log_frame(filt_frame, stream_index, "encoder <-"); + } ret = avcodec_send_frame(stream->enc_ctx, filt_frame); - if (ret < 0) return ret; @@ -468,8 +491,8 @@ static int encode_write_frame(unsigned int stream_index, int flush) stream->enc_ctx->time_base, ofmt_ctx->streams[stream_index]->time_base); - av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n"); /* mux encoded frame */ + log_packet(enc_pkt, ofmt_ctx, "muxer <-"); ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt); } @@ -481,8 +504,11 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index) FilteringContext *filter = &filter_ctx[stream_index]; int ret; - av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n"); /* push the decoded frame into the filtergraph */ + if (frame) { + log_frame(frame, stream_index, "filters <-"); + } + ret = av_buffersrc_add_frame(filter->buffersrc_ctx, frame); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n"); @@ -491,7 +517,6 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index) /* pull filtered frames from the filtergraph */ while (1) { - av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n"); ret = av_buffersink_get_frame(filter->buffersink_ctx, filter->filtered_frame); if (ret < 0) { /* if no more frames for output - returns AVERROR(EAGAIN) @@ -505,6 +530,8 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index) filter->filtered_frame->time_base = av_buffersink_get_time_base(filter->buffersink_ctx);; filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE; + + log_frame(filter->filtered_frame, stream_index, "filters ->"); ret = encode_write_frame(stream_index, 0); av_frame_unref(filter->filtered_frame); if (ret < 0) @@ -549,13 +576,11 @@ int main(int argc, char **argv) if ((ret = av_read_frame(ifmt_ctx, packet)) < 0) break; stream_index = packet->stream_index; - av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n", stream_index); + log_packet(packet, ifmt_ctx, "demuxer ->"); if (filter_ctx[stream_index].filter_graph) { StreamContext *stream = &stream_ctx[stream_index]; - av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n"); - ret = avcodec_send_packet(stream->dec_ctx, packet); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Decoding failed\n"); @@ -569,6 +594,7 @@ int main(int argc, char **argv) else if (ret < 0) goto end; + log_frame(stream->dec_frame, stream_index, "decoder ->"); stream->dec_frame->pts = stream->dec_frame->best_effort_timestamp; ret = filter_encode_write_frame(stream->dec_frame, stream_index); if (ret < 0) @@ -580,6 +606,7 @@ int main(int argc, char **argv) ifmt_ctx->streams[stream_index]->time_base, ofmt_ctx->streams[stream_index]->time_base); + log_packet(packet, ofmt_ctx, "muxer <-"); ret = av_interleaved_write_frame(ofmt_ctx, packet); if (ret < 0) goto end; -- 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".