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
hs_err_pid1.log
public static int yuvToWebm(String sourcePath, String targetPath, int width, int height) { int duration = 0; if (StringUtils.isEmpty(sourcePath) || StringUtils.isEmpty(targetPath)) { return duration; } Frame frame; try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(sourcePath); FFmpegFrameRecorder frameRecorder = new FFmpegFrameRecorder(targetPath, 640, 360)) { //设置yuv420p参数 frameGrabber.setImageWidth(width); frameGrabber.setImageHeight(height); frameGrabber.setPixelFormat(8); //设置webm参数 frameRecorder.setFormat("webm"); //压缩成视频, 2帧压缩成一帧 frameRecorder.setFrameRate(1); frameRecorder.setVideoCodec(avcodec.AV_CODEC_ID_VP9); frameRecorder.setVideoOption("preset", "superfast"); frameGrabber.start(); frameRecorder.start(); while ((frame = frameGrabber.grabFrame()) != null) { try { frameRecorder.record(frame); } catch (Exception e) { log.error("convert h264 to webm failed:", e); } } duration = (int) Math.ceil(frameRecorder.getTimestamp() / 1000000d); } catch (Exception e) { log.debug("catch e:", e); return duration; }
return duration; }
The text was updated successfully, but these errors were encountered:
Duplicate of #2244
Sorry, something went wrong.
No branches or pull requests
hs_err_pid1.log
public static int yuvToWebm(String sourcePath, String targetPath, int width, int height) {
int duration = 0;
if (StringUtils.isEmpty(sourcePath) || StringUtils.isEmpty(targetPath)) {
return duration;
}
Frame frame;
try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(sourcePath);
FFmpegFrameRecorder frameRecorder = new FFmpegFrameRecorder(targetPath, 640, 360)) {
//设置yuv420p参数
frameGrabber.setImageWidth(width);
frameGrabber.setImageHeight(height);
frameGrabber.setPixelFormat(8);
//设置webm参数
frameRecorder.setFormat("webm");
//压缩成视频, 2帧压缩成一帧
frameRecorder.setFrameRate(1);
frameRecorder.setVideoCodec(avcodec.AV_CODEC_ID_VP9);
frameRecorder.setVideoOption("preset", "superfast");
frameGrabber.start();
frameRecorder.start();
while ((frame = frameGrabber.grabFrame()) != null) {
try {
frameRecorder.record(frame);
} catch (Exception e) {
log.error("convert h264 to webm failed:", e);
}
}
duration = (int) Math.ceil(frameRecorder.getTimestamp() / 1000000d);
} catch (Exception e) {
log.debug("catch e:", e);
return duration;
}
The text was updated successfully, but these errors were encountered: