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:~#
ffmpeg应用测试编译问题
最新推荐文章于 2024-05-06 10:05:52 发布