FrameGrabber grabber = new FFmpegFrameGrabber(new java.io.File("/dev/video0"));grabber.setFormat("video4linux2");
try {grabber.start();}catch (Exception e){grabber.stop();grabber.release();grabber = null;grabber = FrameGrabber.createDefault(0); // Lowest common denominatorgrabber.start();}
libv4l2: error setting pixformat: Device or resource busyHIGHGUI ERROR: libv4l unable to ioctl S_FMTlibv4l2: error setting pixformat: Device or resource busylibv4l1: error setting pixformat: Device or resource busyHIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT*** glibc detected *** /usr/lib/jvm/java-7-oracle/bin/java: double free or corruption (fasttop): 0x00007f68c4199dd0 ***======= Backtrace: =========/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f68cb6d8b96]/tmp/javacpp42478226030754/libopencv_highgui.so.2.4(_ZN20CvCaptureCAM_V4L_CPP4openEi+0x6ca)[0x7f688e52312a]/tmp/javacpp42478226030754/libopencv_highgui.so.2.4(_Z25cvCreateCameraCapture_V4Li+0x3d)[0x7f688e52459d]/tmp/javacpp42478226030754/libopencv_highgui.so.2.4(cvCreateCameraCapture+0x7a)[0x7f688e5125ca]/tmp/javacpp42478226030754/libjniopencv_highgui.so(Java_com_googlecode_javacv_cpp_opencv_1highgui_cvCreateCameraCapture+0x1d)[0x7f688901ce0d][0x7f68c1011f90]======= Memory map: ========
int avformat_open_input ( AVFormatContext ** ps, const char * filename, AVInputFormat * fmt, AVDictionary ** options ) Open an input stream and read the header.
The codecs are not opened. The stream must be closed with av_close_input_file().
- Parameters
ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). May be a pointer to NULL, in which case an AVFormatContext is allocated by this function and written into ps. Note that a user-supplied AVFormatContextwill be freed on failure. filename Name of the stream to open. fmt If non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected. options A dictionary filled with AVFormatContext and demuxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.
- Returns
- 0 on success, a negative AVERROR on failure.
- Note
- If you want to use custom IO, preallocate the format context and set its pb field.
oc = new AVFormatContext(null);
...
avformat_open_input(oc, filename, f, options)
void avformat_close_input ( AVFormatContext ** s ) Close an opened input AVFormatContext.
Free it and all its contents and set *s to NULL.
According to FFmpeg's documentation, there's nothing to do done when
avformat_open_input() fails, but to abort, give up. So I guess there is
a bug in FFmpeg and it fails to release some resources before
deallocating its memory. You should report that to them so they can fix
it :)
Samuel
# A fatal error has been detected by the Java Runtime Environment:## SIGSEGV (0xb) at pc=0x00007f1db5e398a2, pid=25944, tid=139766481565440## JRE version: 7.0_17-b02# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)# Problematic frame:# C [libavformat.so.54.59.106+0xff8a2] avformat_close_input+0x12