forked from kokorin/Jaffree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UsingStreamsExample.java
39 lines (34 loc) · 1.32 KB
/
UsingStreamsExample.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
package examples;
import com.github.kokorin.jaffree.ffmpeg.FFmpeg;
import com.github.kokorin.jaffree.ffmpeg.PipeInput;
import com.github.kokorin.jaffree.ffmpeg.PipeOutput;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
public class UsingStreamsExample {
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);
}
Path pathToSrc = Paths.get(args[0]);
Path pathToDst = Paths.get(args[1]);
try (InputStream inputStream =
Files.newInputStream(pathToSrc);
OutputStream outputStream =
Files.newOutputStream(pathToDst, StandardOpenOption.CREATE,
StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING)
) {
FFmpeg.atPath()
.addInput(PipeInput.pumpFrom(inputStream))
.addOutput(
PipeOutput.pumpTo(outputStream)
.setFormat("flv")
)
.execute();
}
}
}