-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
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
Ubuntu 18.04 System FFmpegFrameGrabber.grab() Out of memory #1366
Comments
Please try with JavaCV 1.5.2.
|
Isn't it JavaCV 1.5.2? org.bytedeco javacv-platform 1.5.2 |
-- |
It might be related to "CameraPush". Have you tried without? |
I just call grabber.grab() and the memory grows |
Ok, please simplify your code! Thanks
|
Ok Each time I create a thread to execute the following method, the memory grows public void saveMp4(String savePath) throws org.bytedeco.javacv.FrameGrabber.Exception, org.bytedeco.javacv.FrameRecorder.Exception {
FFmpegFrameGrabber grabber = FFmpegFrameGrabber.createDefault("rtsp://admin:123456@192.168.6.64:554/id=1&type=0");
grabber.setTimeout(5000);
grabber.setOption("rtsp_transport", "tcp");
grabber.setOption("stimeout", "5000000");
FFmpegFrameRecorder record = new FFmpegFrameRecorder(savePath, 1920, 1080, 0);
record.setVideoCodec(avcodec.AV_CODEC_ID_H264);
record.setGopSize(12);
record.setFormat("mp4");
record.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
record.setFrameRate(25);
grabber.start();
record.start();
long err_index = 0;
int allFrameSize = 250; //save frame size
int indexFrame = 0;
for (int no_frame_index = 0; no_frame_index < 5 && err_index < 5 && indexFrame < allFrameSize; ) {
try {
Frame captured_frame = null;
if ((captured_frame = grabber.grab()) != null) {
record.setTimestamp(grabber.getTimestamp());
record.record(captured_frame);
indexFrame += 1;
err_index = 0;
} else {
err_index++;
}
} catch (org.bytedeco.javacv.FrameGrabber.Exception e) {
err_index++;
} catch (org.bytedeco.javacv.FrameRecorder.Exception e) {
err_index++;
}
}
record.stop();
record.close();
grabber.stop();
grabber.close();
System.gc();
} |
Thank you! Does it only happen with RTSP or does it also happen with files?
|
I tested it,Ubuntu System running this program ".MP4" and ".FLV" also "out of memory" |
Could you post here the whole stack trace that you get with the exception? |
BTW, it looks like you're only converting files. It's probably easier to just use the |
I've added PointerScope inside the methods of FFmpegFrameGrabber and FFmpegFrameRecorder in commit 28b90ef. Please give it a try with the snapshots: http://bytedeco.org/builds/ |
I think I'm facing an issue related to this one. When trying to transcode an audio file from AMR (Narrow Band) to WAV in G711 codec I got an OOM error. Following a snipped of my code (in my case it is embedded in a WebApp):
Anyway I was able to reproduce the issue by repeatedly submitting the same transcoding request in a while(true) cycle, something like this:
Let me know if you need anything else. Thank you. |
…abber` and `FFmpegFrameRecorder` (issue #1366)
I think I've fixed all the memory leaks occurring in I'm not noticing anything suspicious anymore when running these lines for over an hour: while (true) {
saveMp4("somevideo.mp4");
transcodeAMR2WAV(new File("someaudio.mp3"));
System.gc();
System.out.println(Pointer.formatBytes(Pointer.physicalBytes()));
} Physical memory usage does appear to rise a bit still, but I haven't been able to find a cause, so it might be happening because of memory fragmentation from FFmpeg itself... In any case, please let me know if it still throws OutOfMemoryError. Thanks! |
I think you hit the point Samuel! |
Fixes included in JavaCV 1.5.4. Enjoy! Thanks for reporting and testing this out |
I get the video stream for "Rtsp" and save it as an MP4 file.
After my test:
ubuntu System memory has been rising,but windows System memory normal
My code:
Test Code:
my pom:
The text was updated successfully, but these errors were encountered: