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