Created
December 26, 2021 04:20
-
-
Save chocotan/17bacad11878f8abce41574f9f502c44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JafTest { | |
public static void main(String[] args) throws InterruptedException { | |
FFmpeg.atPath() | |
.addInput(UrlInput.fromUrl("这里是flv地址")) | |
.setLogLevel(LogLevel.INFO) | |
.setOverwriteOutput(true) | |
.addOutput(UrlOutput.toUrl("/tmp/test.flv")) | |
.addOutput(FrameOutput | |
.withConsumer( | |
new FrameConsumer() { | |
private long num = 1; | |
@Override | |
public void consumeStreams(List<Stream> streams) { | |
// All stream type except video are disabled. just ignore | |
} | |
@Override | |
public void consume(Frame frame) { | |
// End of Stream | |
if (frame == null) { | |
return; | |
} | |
try { | |
String filename = "/tmp/"+new SimpleDateFormat("HH:mm:ss").format(new Date())+".png"; | |
ImageIO.write(frame.getImage(), "png", new File(filename)); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
) | |
// 1 frame every 10 seconds | |
.setFrameRate(0.1) | |
// Disable all streams except video | |
.disableStream(StreamType.AUDIO) | |
.disableStream(StreamType.SUBTITLE) | |
.disableStream(StreamType.DATA) | |
) | |
.execute(); | |
Thread.sleep(1000000L); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment