Live broadcast Poor recording
202774025 opened this issue · 1 comments
202774025 commented
Hello, why can't I use this to record the live broadcast I recorded from the Internet? It feels a little fuzzy, the original live broadcast picture is not like this, if the VideoBitrate setting is smaller, the Mosaic will be more obvious. I have tried to record many live broadcasts, and this is the code example. When I made the VideoBitrate smaller, it was more obvious. "ffmpeg.exe" record does not have this problem, I want to know how to optimize the configuration
try (FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(URL.of(URI.create(url), null))) {
grabber.setOption("rtsp_transport", "tcp");
grabber.setOption("rtsp_flags", "prefer_tcp");
grabber.start();
try (FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputPath, grabber.getAudioChannels())) {
recorder.setImageWidth(grabber.getImageWidth());
recorder.setImageHeight(grabber.getImageHeight());
recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
recorder.setVideoBitrate(grabber.getVideoBitrate());
recorder.setAudioBitrate(grabber.getAudioBitrate());
recorder.setFrameRate(grabber.getFrameRate());
recorder.setGopSize(4);
recorder.start();
long lastFrameTime = System.currentTimeMillis();
while (true) {
Frame capturedFrame = grabber.grabFrame();
if (capturedFrame != null) {
lastFrameTime = System.currentTimeMillis();
recorder.record(capturedFrame);
} else if (System.currentTimeMillis() - lastFrameTime > 30000) {
break;
}
}
} catch (Exception e) {
log.error(e.getMessage());
}
}
saudet commented
Please make sure you're using libx264