ffmpeg和docker导致averror_invaliddata
我在docker容器中运行ffmpeg,我遇到了一个问题 我有一个简单的调试程序(如下所示),它只打开(并读取)一个test.mp4我用fopen()打开文件,读取并打印前32个字节。无论是在docker中运行还是在本地运行,这些值都一致且正确。(即,该文件在docker容器中可以访问和读取)但是,当它达到avformat_open_input()时: 本地运行:工作正常。(真正的程序完全解码) 在docker容器中运行:调用avformat_open_input()失败,AVERROR_INVALIDDATA。这是docker目录中的test.mp4 在这一点上我有点不知所措。我很欣赏你的想法 测试程序列表:=========================================ffmpeg和docker导致averror_invaliddata,docker,ffmpeg,Docker,Ffmpeg,我在docker容器中运行ffmpeg,我遇到了一个问题 我有一个简单的调试程序(如下所示),它只打开(并读取)一个test.mp4我用fopen()打开文件,读取并打印前32个字节。无论是在docker中运行还是在本地运行,这些值都一致且正确。(即,该文件在docker容器中可以访问和读取)但是,当它达到avformat_open_input()时: 本地运行:工作正常。(真正的程序完全解码) 在docker容器中运行:调用avformat_open_input()失败,AVERROR_INV
#include <stdio.h>
extern "C" {
#include <libavformat/avformat.h>
}
int main (int argc, char **argv)
{
int erc=0;
AVFormatContext* srcFmtCtx = NULL;
const char* srcFile = "test.mp4";
// Simple read/echo
FILE *f = fopen(srcFile, "rb");
printf("fopen() %s 0x%lx\n", srcFile, (unsigned long)f);
for (int i=0; i<4; i++) {
long val;
erc = fread(&val, 1, sizeof(long), f);
printf("[%d]0x%lx ", i, val);
}
printf("\n");
fclose(f);
// Open source with ffmpeg libavformat utils
printf("avformat_open_input(): %s\n", srcFile);
if ((erc = avformat_open_input(&srcFmtCtx, srcFile, NULL, NULL)) < 0) {
printf("avformat_open_input(): Returned AvError: %d\n", erc);
exit(1);
}
printf("avformat_open_input(): Returned normally\n");
avformat_close_input(&srcFmtCtx);
}
#包括
外部“C”{
#包括
}
int main(int argc,字符**argv)
{
int-erc=0;
AVFormatContext*srcFmtCtx=NULL;
const char*srcFile=“test.mp4”;
//简单读取/回显
FILE*f=fopen(srcFile,“rb”);
printf(“fopen()%s 0x%lx\n”,srcFile,(无符号长)f);
对于(inti=0;i来说,我的问题似乎是版本不匹配
我的docker容器正在构建ubuntu:18.10映像(最新版本)
该图像提供ffmpeg v3.3.5(或更高版本),libavformat v57.83.100
avformat_version():3756900标识:Lavf57.83.100
我的本地ffmpeg安装是v4.0,libavformat v58.12.100
avformat_version():3804260内部版本:3804260标识:Lavf58.12.100
这些版本之间的一个重要区别是avformat::av_register_all()已弃用,不再使用。我的代码基于新的源代码,没有该调用。但是,旧版本的libavformat需要该调用。因此,在docker容器中,而不是在我的本地环境中失败