javacv
javacv copied to clipboard
libavformat.so.59+0x1a1400 jvm crash
hi , I have a lot of videos that need to extract audio, the service often crashes, I try to add synchronized, but it still appears, there is no error message in the log, and I reprocess the last video, it is normal, you Can you take a look at it for me?
# A fatal error has been detected by the Java Runtime Environment:
# SIGSEGV (0xb) at pc=0x00007f2d1fcee400, pid=117652, tid=0x00007f2d2b3eb700
# JRE version: Java(TM) SE Runtime Environment (8.0_162-b12) (build 1.8.0_162-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.162-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libavformat.so.59+0x1a1400] av_write_frame+0x140
tack: [0x00007f2d2b36b000,0x00007f2d2b3ec000], sp=0x00007f2d2b3ea370, free space=508k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libavformat.so.59+0x1a1400] av_write_frame+0x140
J 26171 C1 org.bytedeco.javacv.FFmpegFrameRecorder.flush()V (124 bytes) @ 0x00007f2f3deea624 [0x00007f2f3deea060+0x5c4]
C 0x00000000e6ad2d40
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.bytedeco.ffmpeg.global.avformat.av_write_frame(Lorg/bytedeco/ffmpeg/avformat/AVFormatContext;Lorg/bytedeco/ffmpeg/avcodec/AVPacket;)I+0
J 26171 C1 org.bytedeco.javacv.FFmpegFrameRecorder.flush()V (124 bytes) @ 0x00007f2f3deea624 [0x00007f2f3deea060+0x5c4]
J 26169 C1 com.iflytek.digital.util.FfmpegUtils2.stop(Lorg/bytedeco/javacv/FFmpegFrameRecorder;)V (40 bytes) @ 0x00007f2f3deeb07c [0x00007f2f3deeaf40+0x13c]
J 16751 C2 com.iflytek.digital.util.FfmpegUtils2.videoPickAudio(Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;)V (332 bytes) @ 0x00007f2f3c574880 [0x00007f2f3c573880+0x1000]
J 26641 C1 com.iflytek.digital.service.ClawerDataService.doVideoAudio(Ljava/lang/String;Ljava/io/File;Ljava/lang/String;Lcom/iflytek/digital/domain/DownloadFileAnalysis;)Ljava/io/File; (227 bytes) @ 0x00007f2f3d09d124 [0x00007f2f3d09b140+0x1fe4]
public static synchronized void videoPickAudio(String videoFile, Integer rate, String audioFile) {
videoFile = videoFile.replaceAll("\\\\", "/");
audioFile = audioFile.replaceAll("\\\\", "/");
FFmpegFrameRecorder recorder = null;
FFmpegLogCallback.set();
FFmpegFrameGrabber grabber = null;
TimeInterval timer = DateUtil.timer();
// 分组1
timer.start("videoPickAudio");
log.info("videoPickAudio start, 文件:{}", videoFile);
try {
recorder = new FFmpegFrameRecorder(audioFile, 1);
recorder.setAudioOption("crf", "0");
recorder.setAudioQuality(0);
recorder.setAudioChannels(1);
recorder.setAudioBitrate(16000);
recorder.setSampleRate(rate);
recorder.setFormat("wav");
recorder.setAudioCodec(avcodec.AV_CODEC_ID_PCM_S16LE);
recorder.start();
//读取视频信息
grabber = new FFmpegFrameGrabber(videoFile);
grabber.start();
Frame f = null;
while ((f = grabber.grabSamples()) != null) {
recorder.record(f);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
try {
if (null != grabber){
grabber.flush();
grabber.stop();
}
} catch (Exception e) {
log.error("关闭grabber失败, inputFile:{}", videoFile, e);
}
try {
if (null != recorder){
recorder.stop();
recorder.release();
}
} catch (FFmpegFrameRecorder.Exception e) {
log.error("关闭recorder失败, inputFile:{}", videoFile, e);
}
}
log.info("videoPickAudio end, 文件:{}, took:{} ms", videoFile, timer.intervalMs("videoPickAudio"));
}
<!-- javacv ffmpeg 开始 -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.5.7</version>
</dependency>
<!-- classifier:windows-x86_64,linux-x86_64,macosx-x86_64, android, ios -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.5.7</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.5.7</version>
<classifier>windows-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>5.0-1.5.7</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>5.0-1.5.7</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>5.0-1.5.7</version>
<classifier>windows-x86_64</classifier>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>1.5.7</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
```
What happens if you don't call flush()?
What is written in hs_err_pid117652.log is FFmpegFrameRecorder.flush() . I didn't call FFmpegFrameRecorder.flush()
Your crash log says that you're calling flush(). Please try without calling flush().
BTW, it's probably easier to use the ffmpeg program: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html When that crashes, it doesn't bring down the JVM, so we can recover.
Your crash log says that you're calling flush(). Please try without calling flush().
BTW, it's probably easier to use the ffmpeg program: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html When that crashes, it doesn't bring down the JVM, so we can recover.
1.the log says FFmpegFrameRecorder.flush() .But I didn't call FFmpegFrameRecorder.flush() explicitly, there is a call to flush() in the source code FFmpegFrameRecorder.close().
public void stop() throws Exception {
if (oc != null) {
try {
flush();
/* write the trailer, if any */
av_write_trailer(oc);
} finally {
release();
}
}
}
2.http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html 。 Error in linux system, Could not initialize class org.bytedeco.ffmpeg.global.avdevice
1.the log says FFmpegFrameRecorder.flush() .But I didn't call FFmpegFrameRecorder.flush() explicitly, there is a call to flush() in the source code FFmpegFrameRecorder.close().
I don't see where you're calling close(). You'll need to call that or it might not work well, that's normal.
2.http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html 。 Error in linux system, Could not initialize class org.bytedeco.ffmpeg.global.avdevice
Please try with the snapshots: http://bytedeco.org/builds/
1.the log says FFmpegFrameRecorder.flush() .But I didn't call FFmpegFrameRecorder.flush() explicitly, there is a call to flush() in the source code FFmpegFrameRecorder.close().
I don't see where you're calling close(). You'll need to call that or it might not work well, that's normal.
2.http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html 。 Error in linux system, Could not initialize class org.bytedeco.ffmpeg.global.avdevice
Please try with the snapshots: http://bytedeco.org/builds/
sorry misspelled, , i call .stop(), there is a call to flush() in the source code FFmpegFrameRecorder.stop().
try {
if (null != recorder){
recorder.stop();
recorder.release();
}
} catch (FFmpegFrameRecorder.Exception e) {
log.error("关闭recorder失败, inputFile:{}", videoFile, e);
}
Does it crash with other formats than wav?