From patchwork Thu Feb 21 11:16:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 12129 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0BC7F448C9E for ; Thu, 21 Feb 2019 13:23:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE44F68AD73; Thu, 21 Feb 2019 13:23:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E88768AAE8 for ; Thu, 21 Feb 2019 13:23:25 +0200 (EET) Received: by mail-lj1-f171.google.com with SMTP id w6so18858285ljd.7 for ; Thu, 21 Feb 2019 03:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=rY0Y6+qotiAMnrZue7RAvNZheBFT9q7y/W0xChdq4Wg=; b=VsIyBJ7AuR7Inav/ugOB2FHMjGvWVqZCuLglQ+wK9amHEsp7IFfQ42pEZJXUyfYdpf PSo9d2C7v+1yICNX2snK+BnSVoKiqz7zcD+LBWhEf5hnJu5iAagotNx7kWGl/EQZdSvQ 28l9JPTux7lGHBp2VLsCFiK44T7HwwgB0wW2Wodo+CIKwI9TiYJW7QThduojTDCvypdg O3MMhnBj3M5bBPG3rS27HUwAovfQ7sZzssQgGhrkLi7P/b8t9OEeiEpa7zwO5usVLejU cyMJzldvHsZhVZ51QuXWUIvFQIuHQj6EaJKsSU3ablazKyP45tUp1NwO3s+ga4H1/b30 RzAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rY0Y6+qotiAMnrZue7RAvNZheBFT9q7y/W0xChdq4Wg=; b=lxibC0h3deg2SBqpiYUgEAUhT7TOsSyEgjRp5ThNu60BLMspW44mRHs0NWQmV6AycX 2uDdlMhdwniD4j+IfBUVAgH0TwRsZ0a42ug6f5myKgUcpQ5BMFY4SbPTv0Hwj7DLiTK5 GYMRyj+bRPPcDsyNiqR2hI3D1pgH0gp82HA7rGTM2HUScLx1TRxgPSurysDCwZw1x2xk gz5UkB+8buxiTumImO6g4wjurJKSRPvzFER40f67iLVP/8HinQ61tTnhn+ODHfj/d7B2 hEkcgvDypxpE+8pGLHVvaxeMepGqotuRk9OWrY0SsnaOvukB6EY+ceFCEw+7dkIlrRoV Up8A== X-Gm-Message-State: AHQUAuZWc+0sqyqPrCEB5+sx0Aq/uhNs5wjLtV5Xnk56+ysToThBsnuk F1vDtYe5/H1+HgFEdNW0Wk7n3aPvabOeOvddJoxCrG// X-Google-Smtp-Source: AHgI3Ib5fs+ZKmzlbqa2C31nvwYTdfxSae4jsH/ugRQCAirav7iKbrpKoWxaQF3WJmAyK9o68clHFiAb1DpU/d116oQ= X-Received: by 2002:a2e:890b:: with SMTP id d11mr4301264lji.174.1550747773401; Thu, 21 Feb 2019 03:16:13 -0800 (PST) MIME-Version: 1.0 From: =?UTF-8?B?SmFuIEVrc3Ryw7Zt?= Date: Thu, 21 Feb 2019 13:16:00 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] ffmpeg_filter: initialize sub2video.end_pts together with last_pts X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This fixes buffering of samples which causes sudden ballooning of memory usage in case of no subtitle samples coming in for a while if the filter chain had been re-initialized. You can also see messages a la: "Error while add the frame to buffer source(Invalid argument)." disappearing after filter chain re-initializations. Passes fate-sub2video. Example (memory usage before patch around 700+ MiB, after around 150MiB) : /usr/bin/time -v ffmpeg -v verbose \ -i "https://megumin.fushizen.eu/samples/2019-01-18-audio_reconfig_causes_buffer_growth.ts" \ -filter_complex '[0:v:0]yadif=deint=interlaced[yadif_out];[yadif_out][0:s:0]overlay=eof_action=pass:repeatlast=0[overlay_out];[overlay_out]scale=1024:-2[video_out];[0:a:0]aresample=48000:async=1,aformat=channel_layouts=stereo[filtered_audio]' \ -map "[video_out]" \ -c:v mpeg4 \ -b:v 750k \ -map "[filtered_audio]" \ -c:a aac \ -b:a 192k \ "test.mp4" Best regards, Jan From 9c824c36c972aca19f2747437c8edc71b6c0886c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Thu, 20 Feb 2019 20:54:11 +0200 Subject: [PATCH] ffmpeg_filter: initialize sub2video.end_pts together with last_pts This way re-initializations properly update end_pts, enabling sub2video_heartbeat to call sub2video_update as expected to re-init the sub2video AVFrame's contents and to feed a frame into the filter chain. This then fixes memory usage ballooning due to framesync waiting for secondary input in case of no actual subtitle samples being present for a while in source after a re-init occurs. --- fftools/ffmpeg_filter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 8c0ff99dd9..72838de1e2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -739,6 +739,7 @@ static int sub2video_prepare(InputStream *ist, InputFilter *ifilter) if (!ist->sub2video.frame) return AVERROR(ENOMEM); ist->sub2video.last_pts = INT64_MIN; + ist->sub2video.end_pts = INT64_MIN; return 0; } -- 2.20.1