| | |
| | | //判断是否有人像 |
| | | ProcessBuilder builder = null; |
| | | if("1".equals(scene.getHasPerson())){ |
| | | // 当有需要添加人像时 |
| | | builder = new ProcessBuilder( |
| | | "ffmpeg", |
| | | "-i", cover1, |
| | | "-i", cover, |
| | | "-i", substring1, |
| | | "-i", cover1, // 背景图 |
| | | "-i", cover, // PPT内容 |
| | | "-i", substring1, // 人像视频 |
| | | "-filter_complex", |
| | | "[0:v]scale=" + Math.round(scene.getBackground().getWidth()) + ":" + Math.round(scene.getBackground().getHeight()) + "[bg];" + |
| | | "[1:v]scale=" + Math.round(scene.getComponents().get(1).getWidth()) + ":" + Math.round(scene.getComponents().get(1).getHeight()) + "[v1];" + |
| | | "[bg][v1]overlay=x=" + Math.round(scene.getComponents().get(1).getMarginLeft()) + ":y=" + Math.round(scene.getComponents().get(1).getTop()) + "[img];" + |
| | | "[2:v]scale=" + Math.round(scene.getComponents().get(0).getWidth()) + ":" + Math.round(scene.getComponents().get(0).getHeight()) + "[v2];" + |
| | | "[img][v2]overlay=x=" + Math.round(scene.getComponents().get(0).getMarginLeft()) + ":y=" + Math.round(scene.getComponents().get(0).getTop()), |
| | | newFileName2 |
| | | newFileName2 // 输出文件名 |
| | | ); |
| | | } else if ("2".equals(scene.getHasPerson())) { |
| | | // 当没有人像时,视频放在 cover 的下层 |
| | |
| | | "ffmpeg", |
| | | "-i", cover1, // 背景图 |
| | | "-i", substring1, // 视频 |
| | | "-i", cover, // PPT内容 |
| | | "-filter_complex", |
| | | "[0:v]scale=" + Math.round(scene.getBackground().getWidth()) + ":" + Math.round(scene.getBackground().getHeight()) + "[bg];" + |
| | | "[1:v]scale=" + Math.round(scene.getComponents().get(0).getWidth()) + ":" + Math.round(scene.getComponents().get(0).getHeight()) + "[v1];" + |
| | | "[bg][v1]overlay=x=" + Math.round(scene.getComponents().get(0).getMarginLeft()) + ":y=" + Math.round(scene.getComponents().get(0).getTop()), |
| | | "[bg][v1]overlay=x=" + Math.round(scene.getComponents().get(0).getMarginLeft()) + ":y=" + Math.round(scene.getComponents().get(0).getTop()) + "[img];" + |
| | | "[2:v]scale=" + Math.round(scene.getComponents().get(1).getWidth()) + ":" + Math.round(scene.getComponents().get(1).getHeight()) + "[v2];" + |
| | | "[img][v2]overlay=x=" + Math.round(scene.getComponents().get(1).getMarginLeft()) + ":y=" + Math.round(scene.getComponents().get(1).getTop()), |
| | | newFileName2 // 输出文件名 |
| | | ); |
| | | } |