首选需要在本机安装ffmpeg
package com.isstech.tools;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.UUID;
public class GetFrameFormVideo {
public static void main(String[] args) {
// 如果是 rtmp 可以在后面增加 参数 live=1 exp: rtmp://202.69.69.180:443/webcast/bshdlive-pc live=1
GetFrameFormVideo.transfer("rtmp://202.69.69.180:443/webcast/bshdlive-pc", "D:\\tmp\\" + UUID.randomUUID().toString() + ".jpg");
}
public static String transfer(String inFile, String outFile) {
String size = "2014x768"; // 600x480
String ffmpeg = "D:\\soft\\ffmpeg-20190815-3aeb681-win64-static\\bin\\ffmpeg.exe"; // ffmpeg
String command = ffmpeg + " -i "+ inFile +" -vframes 1 -y -f image2 -t 1 -s " + size + " " + outFile;
try {
Process process = Runtime.g