help wantedquestion
Repository metrics
- Stars
- (6,985 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
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>
```