最近研究hls,发现需要使用m3u8_segmenter这个程序,搞了半天才编译通过,特此记录一下。
使用正常的./configure等编译老是出错误
gcc -Wall -g m3u8-segmenter.c -o segmenter -lavformat -lavcodec -lavutilm3u8-segmenter.c: In function ‘add_output_stream’:
m3u8-segmenter.c:58: warning: implicit declaration of function ‘avformat_new_stream’
m3u8-segmenter.c:58: warning: assignment makes pointer from integer without a cast
m3u8-segmenter.c: In function ‘main’:
m3u8-segmenter.c:343: warning: implicit declaration of function ‘avformat_find_stream_info’
m3u8-segmenter.c:380: error: ‘AVFMT_FLAG_IGNDTS’ undeclared (first use in this function)
m3u8-segmenter.c:380: error: (Each undeclared identifier is reported only once
m3u8-segmenter.c:380: error: for each function it appears in.)
m3u8-segmenter.c:390: warning: implicit declaration of function ‘avcodec_open2’
m3u8-segmenter.c:397: error: ‘AVIO_FLAG_WRITE’ undeclared (first use in this function)
在网上查资料,特别是参考xjd_1985的文章,m3u8-segmenter工程编译和使用
./configure FFMPEG_CFLAGS=-I../ffmpeg-2.1.1 FFMPEG_LIBS='-L ../ffmpeg-2.1.1/libavformat -L../ffmpeg-2.1.1/libavcodec -L../ffmpeg-2.1.1/libavutil -pthread -lavformat -lavcodec -lavutil -lm -lz'
ffmpeg-2.1.1是我使用ffmpeg的版本和目录
然后再make就通过了。