I am trying to record RTSP stream and store it into hls so that I can stream it to UI as and when it is required. But the stream is having a variable frame rate and as per requirement I have to record it into constant frame rate, so using -fps_mode option in following ffmpeg command I was able to achieve that:
Now I am trying to implement the same in JavaCV. I am using following dependencies \
javacv version: 1.5.9 \
javacpp version: 1.5.9 \
ffmpeg version: 6.0-1.5.9
// FrameGrabber creation
FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(streamURL);
frameGrabber.setOption("timeout", timeout);
frameGrabber.setOption("rtsp_transport", rtspTransportProtocol);
frameGrabber.setOption("loglevel", "debug");
frameGrabber.setOption("fflags", "nobuffer");
frameGrabber.setOption("use_wallclock_as_timestamps", "1");
frameGrabber.setOption("fps_mode", "cfr");
// frameGrabber.setOption("vsync", "1");
frameGrabber.setFormat("rtsp");
frameGrabber.setTimeout(3 * 1000000);
frameGrabber.start();
//FrameRecorder creation
FFmpegFrameRecorder hlsRecorder = new FFmpegFrameRecorder(outputFile, frameWidth, frameHeight, audioChannel);
hlsRecorder.setInterleaved(true);
hlsRecorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
hlsRecorder.setFrameRate(frameGrabber.getFrameRate());
hlsRecorder.setFormat("hls");
hlsRecorder.setGopSize(gopSize);
hlsRecorder.setOption("hls_flags", "program_date_time+split_by_time+append_list");
hlsRecorder.setOption("hls_list_size", "0"); // This option sets the playlist to an infinite size
hlsRecorder.setOption("hls_time", "5"); // This option sets the duration of each segment
// hlsRecorder.setVideoOption("fps_mode", "cfr");
// hlsRecorder.setVideoOption("vsync", "1");
hlsRecorder.start();
I have tried setting fps_mode to cfr in grabber as well as recorder it did not work. Can someone please guide me\
on how to correctly set this option?
I am trying to record RTSP stream and store it into hls so that I can stream it to UI as and when it is required. But the stream is having a variable frame rate and as per requirement I have to record it into constant frame rate, so using
-fps_mode
option in following ffmpeg command I was able to achieve that:Now I am trying to implement the same in JavaCV. I am using following dependencies \
javacv version: 1.5.9
\javacpp version: 1.5.9
\ffmpeg version: 6.0-1.5.9
I have tried setting
fps_mode
tocfr
in grabber as well as recorder it did not work. Can someone please guide me\ on how to correctly set this option?