如果您想使用 FFmpeg 计算 PSNR,请使用替代命令
ffmpeg -i [Input1] -i [Input2] -lavfi psnr -f null -
ffmpeg -i [Input1] -i [Input2] -filter_complex psnr -f null -
异常输出
ffmpeg version git-2019-11-22-27c6c92 Copyright (c) 2000-2019 the FFmpeg developers
...
[Parsed_psnr_0 @ 000001e47a2bee40] PSNR y:9.145728 u:22.375364 v:23.917491 average:10.819717 min:9.523630 max:14.456108
如果您使用 Java 的 JAVE2 库来处理视频
function void calculatePSNR(String in1, String in2){
FFMPEGExecutor ffmpeg = new DefaultFFMPEGLocator().createExecutor()
ffmpeg.addArgument("-i");
ffmpeg.addArgument(in1);
ffmpeg.addArgument("-i");
ffmpeg.addArgument(in2);
ffmpeg.addArgument("-lavfi");
ffmpeg.addArgument("psnr");
ffmpeg.addArgument("-f");
ffmpeg.addArgument("null");
ffmpeg.addArgument("-");
try {
ffmpeg.execute();
} catch (IOException e) {
e.printStackTrace();
ffmpeg.destroy();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(ffmpeg.getErrorStream()));
int lineNR = 0;
String line;
while((line = reader.readLine()) != null) {
if (line.contains("PSNR")){
System.out.println(line);
}
lineNR++;
}
} catch (IOException e) {
e.printStackTrace();
ffmpeg.destroy();
}
ffmpeg.destroy();
}