We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public static boolean createMp4(String mp4SavePath, Map<Integer, File> imgMap, int width, int height) { // System.loadLibrary(Core.NATIVE_LIBRARY_NAME); try (FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(mp4SavePath, width, height); Java2DFrameConverter converter = new Java2DFrameConverter()) { recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264); // recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4); recorder.setFrameRate(25); recorder.setFrameNumber(250); recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P); recorder.setAudioBitrate(900000000); recorder.setAudioQuality(0); recorder.setVideoOption("crf", "0"); // recorder.setVideoOption("r", "25"); recorder.setVideoOption("s", width + "x" + height); recorder.setVideoOption("b", "16000k"); recorder.setVideoOption("preset", "slow"); recorder.setVideoOption("tune", "zerolatency"); recorder.setVideoOption("qscale", "0.01"); recorder.setFormat("mp4"); recorder.start(); for (int i = 0; i < imgMap.size(); i++) { BufferedImage read = ImageIO.read(imgMap.get(i)); recorder.record(converter.getFrame(read)); } recorder.stop(); recorder.release(); return true; } catch (Exception e) { System.out.println("error:" + e.getMessage()); return false; }
The text was updated successfully, but these errors were encountered:
Please refer to this sample code: https://github.com/bytedeco/javacv/blob/master/samples/JavaFxPlayVideoAndAudio.java
Sorry, something went wrong.
Maybe what I said is not accurate, I am in the image after the synthesis of the video, the result is like this
If you're expecting FFmpeg to create image files, you might need to call recorder.close() before that happens.
No branches or pull requests
public static boolean createMp4(String mp4SavePath, Map<Integer, File> imgMap, int width, int height) {
// System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
try (FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(mp4SavePath, width, height);
Java2DFrameConverter converter = new Java2DFrameConverter()) {
recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
// recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);
recorder.setFrameRate(25);
recorder.setFrameNumber(250);
recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
recorder.setAudioBitrate(900000000);
recorder.setAudioQuality(0);
recorder.setVideoOption("crf", "0");
// recorder.setVideoOption("r", "25");
recorder.setVideoOption("s", width + "x" + height);
recorder.setVideoOption("b", "16000k");
recorder.setVideoOption("preset", "slow");
recorder.setVideoOption("tune", "zerolatency");
recorder.setVideoOption("qscale", "0.01");
recorder.setFormat("mp4");
recorder.start();
for (int i = 0; i < imgMap.size(); i++) {
BufferedImage read = ImageIO.read(imgMap.get(i));
recorder.record(converter.getFrame(read));
}
recorder.stop();
recorder.release();
return true;
} catch (Exception e) {
System.out.println("error:" + e.getMessage());
return false;
}
The text was updated successfully, but these errors were encountered: