方式1:通过命令获取
ffprobe ../input.mp4
方式2:代码获取
main.c
#include "libavutil/log.h" #include "libavformat/avformat.h" int main(int argc,char **argv){ av_log_set_level(AV_LOG_DEBUG); if(argc <2){ av_log(NULL,AV_LOG_ERROR,"Usage:%s inputFile",argv[0]); } const char *inputFile = argv[1]; AVFormatContext *fCtx = NULL; int ret = avformat_open_input(&fCtx,inputFile,NULL,NULL); if (ret!=0){ av_log(NULL,AV_LOG_ERROR,"open input file:%s failed:%s\n",inputFile,av_err2str(ret)); } av_dump_format(fCtx,0,inputFile,0); avformat_close_input(&fCtx); return 0; }
Makefile
TARGET=main SRC=main.c cc=gcc CFLAGS=-I /usr/local/ffmpeg/include LDFLAGS=-L /usr/local/ffmpeg/lib LDFLAGS+= -lavutil -lavformat all:$(TARGET) $(TARGET):$(SRC) $(CC) $(SRC) $(CFLAGS) $(LDFLAGS) -o $(TARGET) clean: rm -rf $(TARGET)
编译运行
make && ./main ../input.mp4
标签:SRC,include,ffmpeg,视频,信息,LDFLAGS,main,TARGET From: https://www.cnblogs.com/navysummer/p/18212190