主页 > 创业  > 

FFmpeg:打印音/视频信息(Meta信息)

FFmpeg:打印音/视频信息(Meta信息)

多媒体文件基本概念 多媒体文件其实是个容器在容器里面有很多流(Stream/Track)每种流是由不同的编码器编码的从流中读出的数据称为包在一个包中包含着一个或多个帧 几个重要的结构体 AVFormatContextAVStreamAVPacket FFmpeg操作流数据的基本步骤

打印音/视频信息(Meta信息) av_register_all() avformat_open_input()/avformat_close_input()av_dump_format() :打印音视频的meta信息

具体来看一下 demo:

#include <stdio.h> #include <libavformat/avformat.h> #include <libavutil/log.h> int main(int argc,char* argv[]) { int ret; AVFormatContext* fmt_ctx = NULL; av_log_set_level(AV_LOG_INFO); av_register_all(); ret = avformat_open_input(&fmt_ctx,"./test.mp4",NULL,NULL); if(ret < 0) { av_log(NULL,AV_LOG_ERROR,"Can not open file: %s\n",av_err2str(ret)); return -1; } av_dump_format(fmt_ctx,0,"./test.mp4",0); avformat_close_input(&fmt_ctx); return 0; }

编译输出:

wj@ubuntu:~/FFmpeg$ gcc -g -o mediainfo mediainfo.c -lavformat -lavutil mediainfo.c: In function ‘main’: mediainfo.c:12:5: warning: implicit declaration of function ‘av_register_all’ [-Wimplicit-function-declaration] 12 | av_register_all(); | ^~~~~~~~~~~~~~~ wj@ubuntu:~/FFmpeg$ ./mediainfo Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './test.mp4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: isommp423gp5 creation_time : 2018-11-02T07:56:26.000000Z encoder : FormatFactory : .pcfreetime Duration: 00:05:26.05, bitrate: N/A Stream #0:0(und): Video: mpeg4 (mp4v / 0x7634706D), none, 151 kb/s, SAR 1:1 DAR 0:0, 14.90 fps, 14.90 tbr, 14898 tbn (default) Metadata: creation_time : 2018-11-02T07:56:26.000000Z handler_name : video Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, 2 channels, 125 kb/s (default) Metadata: creation_time : 2018-11-02T07:56:26.000000Z handler_name : sound Stream #0:2(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default) Metadata: creation_time : 2018-11-02T07:56:26.000000Z handler_name : GPAC MPEG-4 OD Handler Stream #0:3(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default) Metadata: creation_time : 2018-11-02T07:56:26.000000Z handler_name : GPAC MPEG-4 Scene Description Handler

标签:

FFmpeg:打印音/视频信息(Meta信息)由讯客互联创业栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“FFmpeg:打印音/视频信息(Meta信息)