ffmpeg应用测试编译问题

1. ffmpeg整个工程编译(主要编译使用ffplay):
<1>.编译、安装
./configure --prefix=/opt/test/
make
make install

<2>.查看最终安装了些什么文件
root@my-pc:/opt/test# tree
.
├── bin
│   ├── ffmpeg
│   ├── ffplay
│   ├── ffprobe
│   └── ffserver
├── include
│   ├── libavcodec
│   │   ├── avcodec.h
│   │   ├── avdct.h
│   │   ├── avfft.h
│   │   ├── d3d11va.h
│   │   ├── dirac.h
│   │   ├── dv_profile.h
│   │   ├── dxva2.h
│   │   ├── jni.h
│   │   ├── mediacodec.h
│   │   ├── qsv.h
│   │   ├── vaapi.h
│   │   ├── vda.h
│   │   ├── vdpau.h
│   │   ├── version.h
│   │   ├── videotoolbox.h
│   │   ├── vorbis_parser.h
│   │   └── xvmc.h
│   ├── libavdevice
│   │   ├── avdevice.h
│   │   └── version.h
│   ├── libavfilter
│   │   ├── avfiltergraph.h
│   │   ├── avfilter.h
│   │   ├── buffersink.h
│   │   ├── buffersrc.h
│   │   └── version.h
│   ├── libavformat
│   │   ├── avformat.h
│   │   ├── avio.h
│   │   └── version.h
│   ├── libavutil
│   │   ├── adler32.h
│   │   ├── aes_ctr.h
│   │   ├── aes.h
│   │   ├── attributes.h
│   │   ├── audio_fifo.h
│   │   ├── avassert.h
│   │   ├── avconfig.h
│   │   ├── avstring.h
│   │   ├── avutil.h
│   │   ├── base64.h
│   │   ├── blowfish.h
│   │   ├── bprint.h
│   │   ├── bswap.h
│   │   ├── buffer.h
│   │   ├── camellia.h
│   │   ├── cast5.h
│   │   ├── channel_layout.h
│   │   ├── common.h
│   │   ├── cpu.h
│   │   ├── crc.h
│   │   ├── des.h
│   │   ├── dict.h
│   │   ├── display.h
│   │   ├── downmix_info.h
│   │   ├── error.h
│   │   ├── eval.h
│   │   ├── ffversion.h
│   │   ├── fifo.h
│   │   ├── file.h
│   │   ├── frame.h
│   │   ├── hash.h
│   │   ├── hmac.h
│   │   ├── hwcontext_cuda.h
│   │   ├── hwcontext_dxva2.h
│   │   ├── hwcontext.h
│   │   ├── hwcontext_qsv.h
│   │   ├── hwcontext_vaapi.h
│   │   ├── hwcontext_vdpau.h
│   │   ├── imgutils.h
│   │   ├── intfloat.h
│   │   ├── intreadwrite.h
│   │   ├── lfg.h
│   │   ├── log.h
│   │   ├── lzo.h
│   │   ├── macros.h
│   │   ├── mastering_display_metadata.h
│   │   ├── mathematics.h
│   │   ├── md5.h
│   │   ├── mem.h
│   │   ├── motion_vector.h
│   │   ├── murmur3.h
│   │   ├── opt.h
│   │   ├── parseutils.h
│   │   ├── pixdesc.h
│   │   ├── pixelutils.h
│   │   ├── pixfmt.h
│   │   ├── random_seed.h
│   │   ├── rational.h
│   │   ├── rc4.h
│   │   ├── replaygain.h
│   │   ├── ripemd.h
│   │   ├── samplefmt.h
│   │   ├── sha512.h
│   │   ├── sha.h
│   │   ├── stereo3d.h
│   │   ├── tea.h
│   │   ├── threadmessage.h
│   │   ├── timecode.h
│   │   ├── time.h
│   │   ├── timestamp.h
│   │   ├── tree.h
│   │   ├── twofish.h
│   │   ├── version.h
│   │   └── xtea.h
│   ├── libswresample
│   │   ├── swresample.h
│   │   └── version.h
│   └── libswscale
│       ├── swscale.h
│       └── version.h
├── lib
│   ├── 1
│   ├── aaa.c
│   ├── libavcodec.a
│   ├── libavdevice.a
│   ├── libavfilter.a
│   ├── libavformat.a
│   ├── libavutil.a
│   ├── libswresample.a
│   ├── libswscale.a
│   ├── pkgconfig
│   │   ├── libavcodec.pc
│   │   ├── libavdevice.pc
│   │   ├── libavfilter.pc
│   │   ├── libavformat.pc
│   │   ├── libavutil.pc
│   │   ├── libswresample.pc
│   │   └── libswscale.pc
│   └── tutorial01.c
└── share
    ├── ffmpeg
    │   ├── examples
    │   │   ├── avio_dir_cmd.c
    │   │   ├── avio_reading.c
    │   │   ├── decoding_encoding.c
    │   │   ├── demuxing_decoding.c
    │   │   ├── extract_mvs.c
    │   │   ├── filter_audio.c
    │   │   ├── filtering_audio.c
    │   │   ├── filtering_video.c
    │   │   ├── http_multiclient.c
    │   │   ├── Makefile
    │   │   ├── metadata.c
    │   │   ├── muxing.c
    │   │   ├── qsvdec.c
    │   │   ├── README
    │   │   ├── remuxing.c
    │   │   ├── resampling_audio.c
    │   │   ├── scaling_video.c
    │   │   ├── transcode_aac.c
    │   │   └── transcoding.c
    │   ├── ffprobe.xsd
    │   ├── libvpx-1080p50_60.ffpreset
    │   ├── libvpx-1080p.ffpreset
    │   ├── libvpx-360p.ffpreset
    │   ├── libvpx-720p50_60.ffpreset
    │   └── libvpx-720p.ffpreset
    └── man
        ├── man1
        │   ├── ffmpeg.1
        │   ├── ffmpeg-all.1
        │   ├── ffmpeg-bitstream-filters.1
        │   ├── ffmpeg-codecs.1
        │   ├── ffmpeg-devices.1
        │   ├── ffmpeg-filters.1
        │   ├── ffmpeg-formats.1
        │   ├── ffmpeg-protocols.1
        │   ├── ffmpeg-resampler.1
        │   ├── ffmpeg-scaler.1
        │   ├── ffmpeg-utils.1
        │   ├── ffplay.1
        │   ├── ffplay-all.1
        │   ├── ffprobe.1
        │   ├── ffprobe-all.1
        │   ├── ffserver.1
        │   └── ffserver-all.1
        └── man3
            ├── libavcodec.3
            ├── libavdevice.3
            ├── libavfilter.3
            ├── libavformat.3
            ├── libavutil.3
            ├── libswresample.3
            └── libswscale.3

17 directories, 175 files
root@my-pc:/opt/test# 



2.使用静态库编译测试程序
<1>.//测试程序:
#include <libavutil/avstring.h>
#include <libavutil/eval.h>
#include <libavutil/mathematics.h>
#include <libavutil/pixdesc.h>
#include <libavutil/imgutils.h>
#include <libavutil/dict.h>
#include <libavutil/parseutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/avassert.h>
#include <libavutil/time.h>
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
#include <libswscale/swscale.h>
#include <libavutil/opt.h>
#include <libavcodec/avfft.h>
#include <libswresample/swresample.h>
int main(int argc, char * argv[])
{
        av_register_all();
        return 0;
}
--------------------------------------------------

<1>.gcc  -o aa aaa.c -lavformat 编译出现问题:
/usr/local/lib/libavformat.a(flacdec.o):在函数‘flac_read_timestamp’中:
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:250:对‘av_init_packet’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:251:对‘av_parser_init’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:267:对‘av_init_packet’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:268:对‘av_parser_parse2’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:272:对‘av_packet_unref’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:263:对‘av_packet_unref’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:267:对‘av_init_packet’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:268:对‘av_parser_parse2’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:272:对‘av_packet_unref’未定义的引用
/usr/local/src/ffmpeg-3.2.2/libavformat/flacdec.c:285:对‘av_parser_close’未定义的引用
......

<2>.静态库的依赖关系存储在lib/pkgconfig/*文件中:
root@my-pc:/opt/test# ls -l
总用量 16
drwxr-xr-x 2 root root 4096  1月 17 18:36 bin
drwxr-xr-x 9 root root 4096  1月 17 18:36 include
drwxr-xr-x 3 root root 4096  1月 19 17:34 lib
drwxr-xr-x 4 root root 4096  1月 17 18:36 share
root@my-pc:/opt/test# 
root@my-pc:/opt/test# ls -l lib
总用量 231336
-rw-r--r-- 1 root root 154766062  1月 17 18:36 libavcodec.a
-rw-r--r-- 1 root root   2262434  1月 17 18:36 libavdevice.a
-rw-r--r-- 1 root root  20440376  1月 17 18:36 libavfilter.a
-rw-r--r-- 1 root root  49992880  1月 17 18:36 libavformat.a
-rw-r--r-- 1 root root   2771482  1月 17 18:36 libavutil.a
-rw-r--r-- 1 root root    697120  1月 17 18:36 libswresample.a
-rw-r--r-- 1 root root   5929160  1月 17 18:36 libswscale.a
drwxr-xr-x 2 root root      4096  1月 17 18:36 pkgconfig
root@my-pc:/opt/test# ls -l lib/pkgconfig/
总用量 28
-rw-r--r-- 1 root root 513  1月 17 18:36 libavcodec.pc
-rw-r--r-- 1 root root 623  1月 17 18:36 libavdevice.pc
-rw-r--r-- 1 root root 604  1月 17 18:36 libavfilter.pc
-rw-r--r-- 1 root root 551  1月 17 18:36 libavformat.pc
-rw-r--r-- 1 root root 273  1月 17 18:36 libavutil.pc
-rw-r--r-- 1 root root 310  1月 17 18:36 libswresample.pc
-rw-r--r-- 1 root root 303  1月 17 18:36 libswscale.pc
root@my-pc:/opt/test# 
root@my-pc:/opt/test# cat lib/pkgconfig/libavformat.pc 
prefix=/opt/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libavformat
Description: FFmpeg container format library
Version: 57.56.100
Requires: libavcodec >= 57.64.101, libswresample >= 2.3.100, libavutil >= 55.34.100
Requires.private: 
Conflicts:
Libs: -L${libdir}  -lavformat -lXv -lX11 -lXext -ldl -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lX11 -lasound -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -L/usr/local/lib -lSDL2 -lm -lz -pthread
Libs.private: 
Cflags: -I${includedir}
root@my-pc:/opt/test# 


<3>.最终修改命令
gcc -o aa aaa.c -lavformat -lavcodec -lswresample -lavutil  -lXv -lX11 -lXext -ldl -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lX11 -lasound -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -L/usr/local/lib 
-lSDL2 -lm -lz -pthread


root@my-pc:~# gcc -o aa aaa.c -lavformat -lavcodec  -lswresample -lavutil  -lXv -lX11 -lXext -ldl -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lX11 -lasound -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -L/usr/local/lib -lSDL2 -lm -lz -pthread
root@my-pc:~# ls -l
总用量 182432
-rwxr-xr-x 1 root root 80251124  1月 19 17:43 aa
-rw-r--r-- 1 root root      583  1月 19 16:57 aaa.c
root@my-pc:~# ./aa
root@my-pc:~# 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Visual Studio 2019编译FFmpeg的简单教程如下: 1. 首先,确保您已经安装了Visual Studio 2019,并且已经正确配置了相关的开发环境。 2. 下载FFmpeg源代码,并解压到您喜欢的目录。 3. 打开Visual Studio 2019,并选择“文件”菜单中的“新建”->“项目”。 4. 在“创建新项目”对话框中,选择“Visual C++”类别,并选择“空项目”。 5. 输入项目名称,并选择项目保存的位置,然后单击“确定”按钮。 6. 在解决方案资源管理器中,右键单击您刚创建的项目,选择“属性”。 7. 在属性页面中,选择“配置属性”->“VC++目录”,然后在包含目录一栏中,添加FFmpeg源代码的头文件路径。 8. 在“配置属性”->“零售”或“调试”->“VC++目录”下的“库目录”一栏,添加FFmpeg库文件的路径。 9. 在“配置属性”->“链接器”->“输入”,在“附加依赖项”一栏中,添加FFmpeg的库文件的名称。 10. 单击“应用”按钮,然后关闭属性页面。 11. 在解决方案资源管理器中,右击项目,选择“添加”->“现有项”,并选择FFmpeg源代码中的所需源文件。 12. 在代码中,添加必要的#include语句,并编写您的应用程序逻辑。 13. 单击“生成”菜单,然后选择“生成解决方案”。 14. 如果编译成功,您将在输出窗口看到“已成功编译”等提示。 15. 在输出目录下找到生成的可执行文件,运行并测试您的应用程序。 请注意,这只是一个简单的FFmpeg编译教程,实际上可能会涉及更多的配置和调整步骤,具体取决于您的项目需求和环境设置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值