其他分享
首页 > 其他分享> > 编译FFmpeg时踩的那些坑

编译FFmpeg时踩的那些坑

作者:互联网

编译FFmpeg过程中遇到如下报错:

1号坑:error: 'ERROR_NOT_ENOUGH_MEMORY' undeclared

libavformat/options.c:77:5: warning: 'av_oformat_next' is deprecated [-Wdeprecated-declarations]
     while (ofmt = av_oformat_next(ofmt))
     ^~~~~
In file included from libavformat/options.c:20:0:
libavformat/avformat.h:2095:17: note: declared here
 AVOutputFormat *av_oformat_next(const AVOutputFormat *f);
                 ^~~~~~~~~~~~~~~
CC      libavformat/os_support.o
In file included from libavformat/os_support.h:115:0,
                 from libavformat/os_support.c:29:
libavformat/os_support.c: In function 'ff_gai_strerror':
libavformat/os_support.c:194:10: error: 'ERROR_NOT_ENOUGH_MEMORY' undeclared (first use in this function)
     case EAI_MEMORY:
          ^
libavformat/os_support.c:194:10: note: each undeclared identifier is reported only once for each function it appears in
make: *** [libavformat/os_support.o] Error 1

or 

make: [ffbuild/.config] Error 127 (ignored)

WARNING: libavdevice/alldevices.c libavfilter/allfilters.c libavformat/allformats.c libavcodec/allcodecs.c libavcodec/bitstream_filters.c libavcodec/parsers.c libavformat/protocols.c newer than config.h, rerun configure

make: [ffbuild/.config] Error 127 (ignored)
CC      libavformat/os_support.o
In file included from libavformat/os_support.h:115:0,
                 from libavformat/os_support.c:29:
libavformat/os_support.c: In function 'ff_gai_strerror':
libavformat/os_support.c:194:10: error: 'ERROR_NOT_ENOUGH_MEMORY' undeclared (first use in this function)
     case EAI_MEMORY:
          ^
libavformat/os_support.c:194:10: note: each undeclared identifier is reported only once for each function it appears in
make: *** [libavformat/os_support.o] Error 1

解决:

在os_support.h中增加winerror.h头文件的引用:

2号坑:error: 'ENOTCONN' undeclared

make: [ffbuild/.config] Error 127 (ignored)

WARNING: libavdevice/alldevices.c libavfilter/allfilters.c libavformat/allformats.c libavcodec/allcodecs.c libavcodec/bitstream_filters.c libavcodec/parsers.c libavformat/protocols.c newer than config.h, rerun configure

make: [ffbuild/.config] Error 127 (ignored)
CC      libavformat/rtsp.o
libavformat/rtsp.c: In function 'rtsp_send_cmd_with_content_async':
libavformat/rtsp.c:1322:16: error: 'ENOTCONN' undeclared (first use in this function)
         return ENOTCONN;
                ^~~~~~~~
libavformat/rtsp.c:1322:16: note: each undeclared identifier is reported only once for each function it appears in

解决:

可以配置引用宏 ENOTCONN 的头文件,因为 ENOTCONN 其实对应着126这个值,最简单的做法就是直接修改为126。

3号坑:ffmpeg 由于找不到libiconv-2.dll 无法继续执行代码。重新安装程序可能会解决此问题。

运行编译出来的ffmpeg.exe文件,报错:

原本以为自己编译的ffmpeg.exe必须依赖libiconv-2.dll库,就把libiconv-2.dll拷贝到同级目录,再运行依然报错:

 

看来是自己想简单了!

搜遍了网络资源也没有找到解决办法,自己就经过两个小时的尝试,终于找到了解决方法。

一、 拷贝libiconv-2.dll库到msys.bat脚本依赖的bin目录下,如图:

二、运行如下命令注册libiconv-2.dll库到系统中。

regsvr32 libiconv-2.dll /s

如果没有报错,表示注册成功。

三、configure配置项增加“--disable-iconv”。

完成上述三步,再运行./configure && make 进行编译。

终于,这次编译出来的ffmpeg.exe可以正常使用了。

赶紧使用如下命令测试一下:

./ffmpeg.exe -h

如果ffmpeg.exe正常可用,会得到如下结果: 

$ ./ffmpeg.exe -h
ffmpeg version n4.2.2-9-g393eff8 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (MinGW.org GCC-6.3.0-1)
  configuration: --disable-everything --disable-x86asm --enable-encoder=aac --disable-iconv
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Getting help:
    -h      -- print basic options
    -h long -- print more options
    -h full -- print all options (including all format and codec specific options, very long)
    -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf
    See man ffmpeg for detailed description of the options.

Print help / information / capabilities:
-L                  show license
-h topic            show help
-? topic            show help
-help topic         show help
--help topic        show help
-version            show version
-buildconf          show build configuration
-formats            show available formats
-muxers             show available muxers
-demuxers           show available demuxers
-devices            show available devices
-codecs             show available codecs
-decoders           show available decoders
-encoders           show available encoders
-bsfs               show available bit stream filters
-protocols          show available protocols
-filters            show available filters
-pix_fmts           show available pixel formats
-layouts            show standard channel layouts
-sample_fmts        show available audio sample formats
-colors             show available color names
-sources device     list sources of the input device
-sinks device       list sinks of the output device
-hwaccels           show available HW acceleration methods

Global options (affect whole program instead of just one file:
-loglevel loglevel  set logging level
-v loglevel         set logging level
-report             generate a report
-max_alloc bytes    set maximum size of a single allocated block
-y                  overwrite output files
-n                  never overwrite output files
-ignore_unknown     Ignore unknown stream types
-filter_threads     number of non-complex filter threads
-filter_complex_threads  number of threads for -filter_complex
-stats              print progress report during encoding
-max_error_rate maximum error rate  ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-bits_per_raw_sample number  set the number of bits per raw sample
-vol volume         change audio volume (256=normal)

Per-file main options:
-f fmt              force format
-c codec            codec name
-codec codec        codec name
-pre preset         preset name
-map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
-t duration         record or transcode "duration" seconds of audio/video
-to time_stop       record or transcode stop time
-fs limit_size      set the limit file size in bytes
-ss time_off        set the start time offset
-sseof time_off     set the start time offset relative to EOF
-seek_timestamp     enable/disable seeking by timestamp with -ss
-timestamp time     set the recording timestamp ('now' to set the current time)
-metadata string=string  add metadata
-program title=string:st=number...  add program with specified streams
-target type        specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
-apad               audio pad
-frames number      set the number of frames to output
-filter filter_graph  set stream filtergraph
-filter_script filename  read stream filtergraph description from a file
-reinit_filter      reinit filtergraph on input parameter changes
-discard            discard
-disposition        disposition

Video options:
-vframes number     set the number of video frames to output
-r rate             set frame rate (Hz value, fraction or abbreviation)
-s size             set frame size (WxH or abbreviation)
-aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-bits_per_raw_sample number  set the number of bits per raw sample
-vn                 disable video
-vcodec codec       force video codec ('copy' to copy stream)
-timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
-pass n             select the pass number (1 to 3)
-vf filter_graph    set video filters
-ab bitrate         audio bitrate (please use -b:a)
-b bitrate          video bitrate (please use -b:v)
-dn                 disable data

Audio options:
-aframes number     set the number of audio frames to output
-aq quality         set audio quality (codec-specific)
-ar rate            set audio sampling rate (in Hz)
-ac channels        set number of audio channels
-an                 disable audio
-acodec codec       force audio codec ('copy' to copy stream)
-vol volume         change audio volume (256=normal)
-af filter_graph    set audio filters

Subtitle options:
-s size             set frame size (WxH or abbreviation)
-sn                 disable subtitle
-scodec codec       force subtitle codec ('copy' to copy stream)
-stag fourcc/tag    force subtitle tag/fourcc
-fix_sub_duration   fix subtitles duration
-canvas_size size   set canvas size (WxH or abbreviation)
-spre preset        set the subtitle options to the indicated preset

至此,终于把FFmpeg最新的4.2.2版本在windows上编译过了。不容易,windows系统坑太多。相比较macOS,复杂繁琐了不少。

上边的几个问题,是编译过程中比较容易遇到的,希望对你有所帮助!

了解本专栏 订阅专栏 解锁全文

标签:set,FFmpeg,libavformat,show,number,那些,编译,os,options
来源: https://blog.csdn.net/liuzehn/article/details/106520787