微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ffmepg 为什么错误:无法写入核心转储

如何解决ffmepg 为什么错误:无法写入核心转储

我想实现一项功能,允许我将 RTSP 流另存为文件, 使用 javacv 实现一个演示,但是有一个错误。 我调试演示,执行'recorder.record(frame);'错误,“ulimit -c unlimited”没用,程序还是报错。 查看源代码确实注意到了问题的原理。请帮帮我。

import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.bytedeco.javacv.Frame;

import java.io.File;
import java.io.IOException;

/**
 * @ClassName video
 * @Description Todo
 * @Author mouse
 * @Date 2021/7/9 11:13
 * @Version 1.0
 **/
public class Video {
    public static void main(String[] args) {
        String streamUrl = "rtsp://admin:12345678.@192.168.20.180:554/h265/ch1/main/av_stream";
        String filePath = "./video/hello.mp3";
        File outFile = new File(filePath);
        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(streamUrl);
        if (!outFile.getParentFile().exists()) {
            outFile.getParentFile().mkdirs();
        }
        FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(filePath,1080,1440,1);
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_H265);
        recorder.setFormat("flv");
        recorder.setVideoBitrate(4000);
        try {
            grabber.start();
            recorder.start();
            Frame frame = grabber.grabFrame();
            while (frame!=null){
                recorder.record(frame);
                frame = grabber.grabFrame();
            }
            recorder.record(frame);
            recorder.stop();
            grabber.stop();

        } catch (FFmpegFrameGrabber.Exception e) {
            e.printstacktrace();
        } catch (IOException e) {
            e.printstacktrace();
        } finally {
            try {
                if (recorder != null) {
                    recorder.stop();
                }
                if (grabber != null) {
                    grabber.stop();
                }
            } catch (FFmpegFrameRecorder.Exception | FFmpegFrameGrabber.Exception e) {
                e.printstacktrace();
            }
        }
    }
}

记录错误

#
# A Fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000131fef233,pid=50498,tid=0x0000000000001003
#
# JRE version: Java(TM) SE Runtime Environment (8.0_281-b09) (build 1.8.0_281-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.281-b09 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libavformat.57.dylib+0xbf233]  av_write_frame+0x993
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping,try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report,please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

pom:

        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>javacv</artifactId>
            <version>1.4.3</version>
        </dependency>
        <dependency>
            <groupId>org.bytedeco.javacpp-presets</groupId>
            <artifactId>ffmpeg-platform</artifactId>
            <version>4.0.2-1.4.3</version>
        </dependency>

我的操作系统:macOS Bgi Sur 11.4;
JDK:1.8.0_281
执行 'recorder.record(frame);'错误, “ulimit -c unlimited”没用,程序还是报错。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。