forked from kokorin/Jaffree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CutAndScaleExample.java
38 lines (32 loc) · 1.3 KB
/
CutAndScaleExample.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
package examples;
import com.github.kokorin.jaffree.StreamType;
import com.github.kokorin.jaffree.ffmpeg.FFmpeg;
import com.github.kokorin.jaffree.ffmpeg.NullOutput;
import com.github.kokorin.jaffree.ffmpeg.OutputListener;
import com.github.kokorin.jaffree.ffmpeg.UrlInput;
import com.github.kokorin.jaffree.ffmpeg.UrlOutput;
import java.util.concurrent.TimeUnit;
public class CutAndScaleExample {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Exactly 2 arguments expected: path to source and destination media files");
System.exit(1);
}
String pathToSrc = args[0];
String pathToDst = args[1];
FFmpeg.atPath()
.addInput(
UrlInput.fromUrl(pathToSrc)
.setPosition(10, TimeUnit.SECONDS)
.setDuration(42, TimeUnit.SECONDS)
)
.setFilter(StreamType.VIDEO, "scale=160:-2")
.setOverwriteOutput(true)
.addArguments("-movflags", "faststart")
.addOutput(
UrlOutput.toUrl(pathToDst)
.setPosition(10, TimeUnit.SECONDS)
)
.execute();
}
}