【问题标题】:Slient crash when calls to ffmpeg's libav exist存在对 ffmpeg libav 的调用时静默崩溃
【发布时间】:2021-08-25 04:43:21
【问题描述】:

我有一个相当简单的例子。

#include <iostream>

extern "C"
{
#include <libavutil/opt.h>
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}

int main(int, char **)
{
  AVFormatContext *format = 0; // avformat_alloc_context();

  // avformat_open_input(&format, "http://s5radio.ponyvillelive.com:8026/stream.mp3", NULL, NULL);
  // avformat_find_stream_info(format, NULL);

  std::cout << "Hello, world!" << std::endl;

  return 0;
}

我这会输出“你好,世界!”我可以设置断点,但是当我取消注释任何调用 avformat 代码的程序时,程序会静默关闭,没有错误,也没有中断点,因此无法调试。

例如,将AVFormatContext *format = 0; 更改为AVFormatContext *format = avformat_alloc_context(); 或取消注释avformat_open_input(&amp;format, "http://s5radio.ponyvillelive.com:8026/stream.mp3", NULL, NULL);。没有断点或错误我该如何解决?

更新: 这是我从调试器中得到的:

错误:无法开始调试。来自命令“-exec-run”的意外 GDB 输出。在启动过程中,程序以代码 0xc0000139 退出。 程序 'path\to\my\project\LibavPlayground.exe' 已退出,代码为 0 (0x00000000)。

更新2:

这是我的 cmake:

cmake_minimum_required(VERSION 3.0.0)
project(LibavPlayground VERSION 0.1.0 LANGUAGES CXX C)

find_package(PkgConfig REQUIRED) 
pkg_check_modules(LIBAV REQUIRED libavutil libavcodec libavformat)
include_directories(${LIBAV_INCLUDE_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS -Wno-deprecated-declarations")

include_directories(include PUBLIC)
include_directories(src PRIVATE)

file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)

add_executable(LibavPlayground ${SRC_FILES})
target_link_libraries(LibavPlayground ${LIBAV_LIBRARIES})

所有的 libav* 库都是用一个 pacman -S mingw-w64-x86_64-ffmpeg 命令安装的

【问题讨论】:

  • 在调用 ffmpeg 函数之前调用 av_register_all(); avcodec_register_all();。
  • @S.M.这些方法已被弃用。
  • 另外,如果我使用 -Wno-deprecated-declarations 并调用 av_register_all(); avcodec_register_all();,它们会导致相同的行为。
  • 显示的代码(avformat_* 调用未注释)的行为符合我的预期。你能澄清"...the program silently closes"的意思吗?如果您在调试器下运行它,它是否永远不会到达std::cout &lt;&lt; ... 语句?
  • 我看到错误 c0000139(未找到入口点)。这暗示您安装的共享库存在问题。

标签: c++ ffmpeg mingw-w64 libav libavformat


【解决方案1】:

当前的解决方案是使用 WSL 而不是 MinGw,因为我不会在 WSL 中重复该问题。虽然我真的希望有人有一个真正的解决方案。

【讨论】:

    猜你喜欢
    • 2017-02-22
    • 1970-01-01
    • 2018-12-11
    • 2012-06-15
    • 2016-11-25
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 2020-06-26
    相关资源
    最近更新 更多