两次调用ffmpeg.c的主程序导致应用崩溃

两次调用ffmpeg.c的主程序导致应用崩溃,第1张

概述使用FFmpeg4.0.2并两次调用其ffmpeg.c的主要功能会导致Android应用崩溃(使用FFmpeg共享库和JNI)A/libc:Fatalsignal11(SIGSEGV),code1,faultaddr0x0intid20153虽然对于FFmpeg3.2.5可以正常工作FFmpeg4.0.2主要intmain(intargc,char**argv){inti,

使用FFmpeg 4.0.2并两次调用其ffmpeg.c的主要功能会导致Android应用崩溃(使用FFmpeg共享库和JNI)

A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tID 20153

虽然对于FFmpeg 3.2.5可以正常工作

FFmpeg 4.0.2主要

int main(int argc, char **argv) {    int i, ret;    int64_t ti;    init_dynload();    register_exit(ffmpeg_cleanup);    setvbuf(stderr,NulL,_IONBF,0); /* win32 runtime needs this */    av_log_set_flags(AV_LOG_SKIP_REPEATED);    parse_loglevel(argc, argv, options);    if(argc>1 && !strcmp(argv[1], "-d")){        run_as_daemon=1;        av_log_set_callback(log_callback_null);        argc--;        argv++;    }#if CONfig_AVDEVICE    avdevice_register_all();#endif    avformat_network_init();    show_banner(argc, argv, options);    /* parse options and open all input/output files */    ret = ffmpeg_parse_options(argc, argv);    if (ret < 0)        exit_program(1);    if (nb_output_files <= 0 && nb_input_files == 0) {        show_usage();        av_log(NulL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name);        exit_program(1);    }    /* file converter / grab */    if (nb_output_files <= 0) {        av_log(NulL, AV_LOG_FATAL, "At least one output file must be specifIEd\n");        exit_program(1);    }//     if (nb_input_files == 0) {//         av_log(NulL, AV_LOG_FATAL, "At least one input file must be specifIEd\n");//         exit_program(1);//     }    for (i = 0; i < nb_output_files; i++) {        if (strcmp(output_files[i]->ctx->oformat->name, "rtp"))            want_sdp = 0;    }    current_time = ti = getutime();    if (transcode() < 0)        exit_program(1);    ti = getutime() - ti;    if (do_benchmark) {        av_log(NulL, AV_LOG_INFO, "bench: utime=%0.3fs\n", ti / 1000000.0);    }    av_log(NulL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" deCoding errors\n",           decode_error_stat[0], decode_error_stat[1]);    if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1])        exit_program(69);    ffmpeg_cleanup(received_nb_signals ? 255 : main_return_code);    return main_return_code;}

FFmpeg 3.2.5主要

int main(int argc, char **argv) {    av_log(NulL, AV_LOG_WARNING, " Command start");    int i, ret;    int64_t ti;    init_dynload();    register_exit(ffmpeg_cleanup);    setvbuf(stderr, NulL, _IONBF, 0); /* win32 runtime needs this */    av_log_set_flags(AV_LOG_SKIP_REPEATED);    parse_loglevel(argc, argv, options);    if (argc > 1 && !strcmp(argv[1], "-d")) {        run_as_daemon = 1;        av_log_set_callback(log_callback_null);        argc--;        argv++;    }    avcodec_register_all();#if CONfig_AVDEVICE    avdevice_register_all();#endif    avfilter_register_all();    av_register_all();    avformat_network_init();    av_log(NulL, AV_LOG_WARNING, " Register to complete the codec");    show_banner(argc, argv, options);    /* parse options and open all input/output files */    ret = ffmpeg_parse_options(argc, argv);    if (ret < 0)        exit_program(1);    if (nb_output_files <= 0 && nb_input_files == 0) {        show_usage();        av_log(NulL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n",               program_name);        exit_program(1);    }    /* file converter / grab */    if (nb_output_files <= 0) {        av_log(NulL, AV_LOG_FATAL, "At least one output file must be specifIEd\n");        exit_program(1);    }//     if (nb_input_files == 0) {//         av_log(NulL, AV_LOG_FATAL, "At least one input file must be specifIEd\n");//         exit_program(1);//     }    for (i = 0; i < nb_output_files; i++) {        if (strcmp(output_files[i]->ctx->oformat->name, "rtp"))            want_sdp = 0;    }    current_time = ti = getutime();    if (transcode() < 0)        exit_program(1);    ti = getutime() - ti;    if (do_benchmark) {        av_log(NulL, AV_LOG_INFO, "bench: utime=%0.3fs\n", ti / 1000000.0);    }    av_log(NulL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" deCoding errors\n",           decode_error_stat[0], decode_error_stat[1]);    if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1])        exit_program(69);    exit_program(received_nb_signals ? 255 : main_return_code);    nb_filtergraphs = 0;    nb_input_streams = 0;    nb_input_files = 0;    progress_avio = NulL;    input_streams = NulL;    nb_input_streams = 0;    input_files = NulL;    nb_input_files = 0;    output_streams = NulL;    nb_output_streams = 0;    output_files = NulL;    nb_output_files = 0;    return main_return_code;}

那么可能是什么问题?似乎FFmpeg 4.0.2不会释放任何内容(在第一个命令后,资源或其静态变量为初始值)

解决方法:

将FFmpeg 3.2.5的下一行添加到FFmpeg 4.0.2的主要功能末尾解决了该问题(我将FFmpeg 3.2.5下载为某人的AndroID项目,以便用户添加了这些行)

nb_filtergraphs = 0;nb_input_streams = 0;nb_input_files = 0;progress_avio = NulL;input_streams = NulL;nb_input_streams = 0;input_files = NulL;nb_input_files = 0;output_streams = NulL;nb_output_streams = 0;output_files = NulL;nb_output_files = 0;
总结

以上是内存溢出为你收集整理的两次调用ffmpeg.c的主程序导致应用崩溃全部内容,希望文章能够帮你解决两次调用ffmpeg.c的主程序导致应用崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1095791.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存