ffmpeg读取媒体文件信息

root@yangwang-virtual-machine:/home/yangwang/Desktop/ffmpegdemo# ./ffmpeg_mediainfo
Input #0, mp3, from ‘./1.mp3’:
Metadata:
encoder : Lizhi codec
title : Hello
artist : DJ|小七
album : 好乐分享
TLEN : 295636
genre : 网络电台
date : 2017
Duration: N/A, bitrate: N/A
Stream #0:0: Audio: mp3, 0 channels
Stream #0:1: Video: mjpeg, none, 90k tbn (attached pic)
Metadata:
comment : Other
root@yangwang-virtual-machine:/home/yangwang/Desktop/ffmpegdemo#

编译命令为这个:gcc -o ffmpeg_mediainfo mediainfo.c -L/usr/local/ffmpeg/lib -lavformat -lavutil

源码内容为:
#include
#include

int main()
{
int ret;
AVFormatContext * fmt_ctx=NULL;
av_log_set_level(AV_LOG_INFO);
//av_register_all();
ret=avformat_open_input(&fmt_ctx,“./1.mp3”,NULL,NULL);
if(ret <0 )
{
av_log(NULL,AV_LOG_ERROR,“Can’t open file:%s\n”,av_err2str(ret));
return -1;
}
av_dump_format(fmt_ctx,0,“./1.mp3”,0);
avformat_close_input(&fmt_ctx);

return 0;

}

你可能感兴趣的:(ffmpeg)