我正在尝试编译此transcoding example from the FFMPEG site的修改版本,我已经使用了所有必需的包含并使用此加入了lib:
INCLUDEPATH += $$(FFMPEG_DEV_PATH)\include
LIBS += -L$$(FFMPEG_DEV_PATH)\lib -lavformat -lavcodec -lavutil -lswscale -liconv -lz -lavfilter
但是我得到了这个我无法理解的链接错误:
"avio_close(AVIOContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_strerror(int, char*, unsigned long)", referenced from:
av_make_error_string(char*, unsigned long, int) in PhVideoEncoder.o
"av_rescale_q(long long, AVRational, AVRational)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_frame_free(AVFrame**)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_read_frame(AVFormatContext*, AVPacket*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_close(AVCodecContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_dump_format(AVFormatContext*, int, char const*, int)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_frame_alloc()", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"av_free_packet(AVPacket*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_init_packet(AVPacket*)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_opt_set_bin(void*, char const*, unsigned char const*, int, int)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"av_register_all()", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_rescale_q_rnd(long long, AVRational, AVRational, AVRounding)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_write_trailer(AVFormatContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avfilter_graph_free(AVFilterGraph**)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avfilter_inout_free(AVFilterInOut**)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_new_stream(AVFormatContext*, AVCodec const*)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
"avcodec_copy_context(AVCodecContext*, AVCodecContext const*)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"avcodec_find_decoder(AVCodecID)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
"avcodec_find_encoder(AVCodecID)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"avfilter_get_by_name(char const*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avfilter_graph_alloc()", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avfilter_inout_alloc()", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_close_input(AVFormatContext**)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, AVPacket const*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_decode_video2(AVCodecContext*, AVFrame*, int*, AVPacket const*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avcodec_encode_audio2(AVCodecContext*, AVPacket*, AVFrame const*, int*)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"avcodec_encode_video2(AVCodecContext*, AVPacket*, AVFrame const*, int*)", referenced from:
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"avfilter_graph_config(AVFilterGraph*, void*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avfilter_register_all()", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avformat_free_context(AVFormatContext*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"avformat_write_header(AVFormatContext*, AVDictionary**)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_get_sample_fmt_name(AVSampleFormat)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"av_buffersink_get_frame(AVFilterContext*, AVFrame*)", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"avfilter_graph_parse_ptr(AVFilterGraph*, char const*, AVFilterInOut**, AVFilterInOut**, void*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_find_stream_info(AVFormatContext*, AVDictionary**)", referenced from:
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
"av_interleaved_write_frame(AVFormatContext*, AVPacket*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
"av_buffersrc_add_frame_flags(AVFilterContext*, AVFrame*, int)", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"avfilter_graph_create_filter(AVFilterContext**, AVFilter const*, char const*, char const*, void*, AVFilterGraph*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"av_get_default_channel_layout(int)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avformat_alloc_output_context2(AVFormatContext**, AVOutputFormat*, char const*, char const*)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_get_channel_layout_nb_channels(unsigned long long)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
"av_frame_get_best_effort_timestamp(AVFrame const*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_log(void*, int, char const*, ...)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
PhVideoEncoder::flush_encoder(unsigned int) in PhVideoEncoder.o
PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
...
"av_free(void*)", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"av_malloc(unsigned long)", referenced from:
av_malloc_array(unsigned long, unsigned long) in PhVideoEncoder.o
"av_strdup(char const*)", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"avio_open(AVIOContext**, char const*, int)", referenced from:
PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
我试图寻找丢失的图书馆,但没有运气......我缺少什么?
感谢第一个答案,我添加了extern C
内容,但我仍然面临一些错误:
Undefined symbols for architecture x86_64:
"_av_buffersink_get_frame", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"_av_buffersrc_add_frame_flags", referenced from:
PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
"_avfilter_get_by_name", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_alloc", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_config", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_create_filter", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_graph_free", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
"_avfilter_graph_parse_ptr", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_inout_alloc", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_inout_free", referenced from:
PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
"_avfilter_register_all", referenced from:
PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
ld: symbol(s) not found for architecture x86_64
答案 0 :(得分:6)
请参阅this post - 最有可能在将C ++代码与FFMPEG的C接口混合时,您忘记了extern "C"
关键字,因此链接器正在使用C ++函数名称修改,因此无法找到引用。你应该用这样的extern "C"
包装FFMPEG包含:
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
答案 1 :(得分:0)
现在已经破解了带转码示例的FFmpeg网站链接,但您可以在此处找到它:http://ffmpeg.org/doxygen/trunk/doc_2examples_2transcoding_8c-example.html
我认为问题在于该示例使用了更高版本的FFmpeg。我使用的是来自https://github.com/appunite/AndroidFFmpeg的FFmpeg 1.0的Android端口,我也面临同样的问题(即未声明的avfilter_graph_parse_ptr
)。我的FFmpeg源代码没有它,而是声明avfilter_graph_parse
。
我的源代码没有代码转换示例,我认为应该使用 doc / examples / decoding_encoding.c 。
我更改了代码以使用旧功能,example av_frame_free
- &gt; avcodec_free_frame
,av_buffersrc_write_frame_flags
- &gt; av_buffersrc_write_frame
等等,现在它至少可以编译......