我使用https://github.com/bytedeco/javacpp-presets/tree/master/ffmpeg
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>ffmpeg</artifactId>
<version>3.1.2-1.2</version>
</dependency>
当我随机调用avformat_open_input / avformat_close_input时(从不在第一次调用时)获取这些错误:
Error in `/usr/lib/jvm/java-8-oracle/bin/java': double free or corruption (out): 0x00007fe79c194aa0
或
Error in `/usr/lib/jvm/java-8-oracle/bin/java': double free or corruption (!prev): 0x00007fe51c3ffb60
或
Error in `/usr/lib/jvm/java-8-oracle/bin/java': double free or corruption (fasttop): 0x00007fcdc40fe4a0
我无法找到解决方法,请帮助。
有我的实施:
private static void registerComponents() {
if (!componentsRegistered) {
componentsRegistered = true;
av_register_all();
}
}
public static void decodeFrame(ByteBuffer frameData) {
registerComponents();
AVFormatContext pFormatCtx = avformat_alloc_context();
int i, videoStream;
AVCodecContext pCodecCtx = null;
AVCodec pCodec = null;
AVFrame pFrame = null;
AVFrame pFrameRGB = null;
int[] frameFinished = new int[1];
int numBytes;
BytePointer buffer = null;
AVDictionary optionsDict = null;
SwsContext sws_ctx = null;
AVIOContext ioContext = avio_alloc_context(new BytePointer(frameData), frameData.capacity(), 0, null, null, null, null);
pFormatCtx.pb(ioContext);
if (avformat_open_input(pFormatCtx, "", null, null) < 0) {
logger.error(MarkerFactory.getMarker("ffmpeg"), "Problem with load video from memory.");
return;
}
avformat_close_input(pFormatCtx);
}