From 1571934943a89a56afbdbe3d4b45f652f4667d63 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 7 Sep 2025 01:45:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(entity):=20=E4=BF=AE=E5=A4=8D=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E8=A3=81=E5=89=AA=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=20JSON=20=E8=A7=A3=E6=9E=90=20-=20?= =?UTF-8?q?=E5=9C=A8=E8=A7=A3=E6=9E=90=20posJson=20=E6=97=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E6=97=A0=E6=95=88=20JSON=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=B4=A9=E6=BA=83=20-=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E8=A3=81=E5=89=AA=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=B8=AD=E7=9A=84=E5=8F=96=E6=95=B4=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E8=A3=81=E5=89=AA=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/ffmpeg.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/entity/ffmpeg.py b/entity/ffmpeg.py index a229523..51a9c53 100644 --- a/entity/ffmpeg.py +++ b/entity/ffmpeg.py @@ -190,7 +190,10 @@ class FfmpegTask(object): input_args.append(input_file.get_output_file()) if self.center_cut == 1: pos_json_str = self.ext_data.get('posJson', '{}') - pos_json = json.loads(pos_json_str) + try: + pos_json = json.loads(pos_json_str) + except Exception as e: + pos_json = {} _v_w = pos_json.get('imgWidth', 1) _f_x = pos_json.get('ltX', 0) _f_x2 = pos_json.get('rbX', 0) @@ -212,15 +215,18 @@ class FfmpegTask(object): _iw, _ih, _ = probe_video_info(_input) _w, _h = self.resolution.split('x', 1) pos_json_str = self.ext_data.get('posJson', '{}') - pos_json = json.loads(pos_json_str) + try: + pos_json = json.loads(pos_json_str) + except Exception as e: + pos_json = {} _v_w = pos_json.get('imgWidth', 1) _v_h = pos_json.get('imgHeight', 1) _f_x = pos_json.get('ltX', 0) _f_x2 = pos_json.get('rbX', 0) _f_y = pos_json.get('ltY', 0) _f_y2 = pos_json.get('rbY', 0) - _x = min(max(0, (_f_x + _f_x2) / 2 - int(_w) / 2), _iw - int(_w)) - _y = min(max(0, (_f_y + _f_y2) / 2 - int(_h) / 2), _ih - int(_h)) + _x = min(max(0, int((_f_x + _f_x2) / 2 - int(_w) / 2)), _iw - int(_w)) + _y = min(max(0, int((_f_y + _f_y2) / 2 - int(_h) / 2)), _ih - int(_h)) filter_args.append(f"{video_output_str}crop=x={_x}:y={_y}:w={_w}:h={_h}[vz_cut{effect_index}]") video_output_str = f"[vz_cut{effect_index}]" effect_index += 1