forked from kokorin/Jaffree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParsingOutputExample.java
40 lines (32 loc) · 1.38 KB
/
ParsingOutputExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package examples;
import com.github.kokorin.jaffree.ffmpeg.FFmpeg;
import com.github.kokorin.jaffree.ffmpeg.FFmpegProgress;
import com.github.kokorin.jaffree.ffmpeg.NullOutput;
import com.github.kokorin.jaffree.ffmpeg.OutputListener;
import com.github.kokorin.jaffree.ffmpeg.ProgressListener;
import com.github.kokorin.jaffree.ffmpeg.UrlInput;
import com.github.kokorin.jaffree.ffmpeg.UrlOutput;
import java.util.concurrent.atomic.AtomicLong;
public class ParsingOutputExample {
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Exactly 1 argument expected: path to media file");
System.exit(1);
}
String pathToVideo = args[0];
// StringBuffer - because it's thread safe
final StringBuffer loudnormReport = new StringBuffer();
FFmpeg.atPath()
.addInput(UrlInput.fromUrl(pathToVideo))
.addArguments("-af", "loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json")
.addOutput(new NullOutput(false))
.setOutputListener(new OutputListener() {
@Override
public void onOutput(String line) {
loudnormReport.append(line);
}
})
.execute();
System.out.println("Loudnorm report:\n" + loudnormReport);
}
}