"error: 'avcodec_open' was not declared in this scope"尝试编译untrunc
"error: 'avcodec_open' was not declared in this scope" on attempting to compile untrunc
我有一段由电源中断的摄像机录制的视频。因此,它正在制作的H.264编解码器的MP4文件被损坏。我想在Ubuntu 14.04.1中修复这个文件。我看到有人建议使用untrunc。我正试图编译这个,但遇到了一个错误,我不知道如何解决。到目前为止,我所做的如下:
sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev
git clone https://github.com/ponchio/untrunc.git
cd untrunc/
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil
尝试编译时,出现以下错误:
track.cpp: In member function 'void Track::parse(Atom*, Atom*)':
track.cpp:217:47: error: 'avcodec_open' was not declared in this scope
if(avcodec_open(codec.context, codec.codec)<0)
你能建议一个解决这个错误的方法吗?
avcodec_open
不支持avcodec_open2
。请看下面的注释。通读avcodec_open
的文档,似乎做替换的方法是转换:
avcodec_open(a,b);
avcodec_open2(a,b,NULL);
这个修复类似于建议的修复,但没有在untrunc库本身中进行验证,在这里。
我试图验证修复是否有效。实际上,这是对track.cpp的单行修改。:
if(avcodec_open(codec.context, codec.codec)<0)
并替换为
if(avcodec_open2(codec.context, codec.codec, NULL)<0)
(在commit 3c708a上,这个更改是在第218行)。注意:我只验证了代码编译,而不是它实际上按照它应该的方式工作(我没有一个坏的m4v来测试)。
不是您问题的确切解决方案(编译错误),但可能是您主要问题的解决方案(mp4破碎):http://untrunc.it/
相关文章:
- 表示"accepting anything for this template argument" C++概念的通配符
- 为什么使用 "this" 指针调用派生成员函数?
- C++错误:"error: int aaa::bbb is protected within this context"
- 我可以将调用类的"this"传递给 lambda 函数吗?
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 关于C++中具有多重继承"this"指针的说明
- 在noexcept 规范中是否允许使用"this"?
- 如何修复"error: ‘_1’ was not declared in this scope"?
- C++调用具有 *this 属性的单个帮助程序函数
- Doees the 'this' 指针参与虚函数的多态行为
- 在 c++ 中正确定义"this"关键字?
- 在什么情况下,两个堆栈分配的结构对象的 this 点指向同一个地址?
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- QObject::连接无法将信号连接到*this*对象的插槽
- 析构函数中的"delete this"
- 为什么成员函数内的"this"指针为空?
- 为什么我需要在转换构造函数上引用 this->?
- "this"指针的值在对象的生存期内是否恒定?
- C++ "Invalid use of 'this' in non-member function" ,
- "error: 'avcodec_open' was not declared in this scope"尝试编译untrunc