private void getVideoTime(String videoUrl, String img) { InputStream inputStream = null; InputStream errorStream = null; OutputStream outputStream = null; try { String str = "ffprobe -select_streams v -show_frames -show_entries frame=pict_type -of csv '" + videoUrl + "' | grep -n I | cut -d ':' -f 1 > " + img + ".txt"; String[] cmd = new String[]{shellPath, "-c", str}; Process process = Runtime.getRuntime().exec(cmd); OutputProcessor error = new OutputProcessor(process.getErrorStream()); OutputProcessor input = new OutputProcessor(process.getInputStream()); error.start(); input.start(); int exitCode = process.waitFor(); if (exitCode == 0) { log.info(exitCode == 0 ? "获取关键帧执行成功" : "获取关键帧执行失败"); } } catch (Exception e) { log.error(e.getMessage()); } }
获取关键帧在视频中的时间节点
最新推荐文章于 2024-05-23 18:31:43 发布