From 93febe34b031536e61282b1cb2a9e57c95ce4353 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 3 May 2022 00:32:00 +0200 Subject: [PATCH] truncate huge ffmpeg errors --- copyparty/th_srv.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 6d89a277..a84d0bac 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -417,8 +417,15 @@ class ThumbSrv(object): m = "FFmpeg failed because it was compiled without libsox; you must set --th-ff-swr to force swr resampling:\n" c = 1 - m += "\n".join(["ff: {}".format(x) for x in serr.split("\n")]) - self.log(m, c=c) + lines = serr.strip("\n").split("\n") + if len(lines) > 50: + lines = lines[:25] + ["[...]"] + lines[-25:] + + txt = "\n".join(["ff: " + str(x) for x in lines]) + if len(txt) > 5000: + txt = txt[:2500] + "...\nff: [...]\nff: ..." + txt[-2500:] + + self.log(m + txt, c=c) raise sp.CalledProcessError(ret, (cmd[0], b"...", cmd[-1])) def conv_spec(self, abspath, tpath):