javacv
javacv copied to clipboard
Convert org.bytedeco.javacv.Frame to base64
Hi,
Can you please tell me how to convert org.bytedeco.javacv.Frame to base64 ? I am sorry i am asking here this but i have been searching this for weeks.
frame grabbed at 240000
loop end with frame: org.bytedeco.javacv.Frame@76ad8565
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000667b6cbf, pid=7996, tid=0x0000000000005010
#
# JRE version: Java(TM) SE Runtime Environment (8.0_161-b12) (build 1.8.0_161-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.161-b12 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V [jvm.dll+0x1e6cbf]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Admin\Desktop\war\hs_err_pid7996.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
[udp @ 0000000023da4f80] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0000000023da5080] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
Input #0, rtsp, from 'rtsp://admin:[email protected]:554/Streaming/Channels/101':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.240000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
public static String grab(String SOURCE_RTSP)
{
try {
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(SOURCE_RTSP);
/**
* "timeout" - IS IGNORED when a network cable have been unplugged
* before a connection and sometimes when connection is lost.
*
* "rw_timeout" - IS IGNORED when a network cable have been
* unplugged before a connection but the option takes effect after a
* connection was established.
*
* "stimeout" - works fine.
*/
grabber.setOption(
TimeoutOption.STIMEOUT.getKey(),
String.valueOf(TIMEOUT * 1000000)
); // In microseconds.
grabber.start();
Frame frame = null;
/**
* When network is disabled (before brabber was started) grabber
* throws exception: "org.bytedeco.javacv.FrameGrabber$Exception:
* avformat_open_input() error -138: Could not open input...".
*
* When connections is lost (after a few grabbed frames)
* grabber.grab() returns null without exception.
*/
while ((frame = grabber.grab()) != null) {
System.out.println("frame grabbed at " + grabber.getTimestamp());
break;
}
grabber.close();
System.out.println("loop end with frame: " + frame);
Java2DFrameConverter converter = new Java2DFrameConverter();
BufferedImage buf = converter.getBufferedImage(frame);
return BufToBase64(buf);
} catch (FrameGrabber.Exception ex) {
System.out.println("exception: " + ex);
}
return null;
}
Thanks..