FFmpeg打印基本音视频信息

news/2024/9/17 19:07:01/ 标签: ffmpeg, 音视频

1. 编写可执行文件

vim  mediainfo_new.c
#include<stdio.h>
#include<libavutil/log.h>
#include <libavformat/avformat.h>int main(int argc, char *argv[])
{int err_code;AVFormatContext *fmt_ctx = NULL;av_log_set_level(AV_LOG_DEBUG);if(argc < 2){av_log(NULL,AV_LOG_ERROR, "[Usage]you should input media file!\n");return -1;}char *src_filename = argv[1];//av_register_all();/* open input file, and allocate format context */if ((err_code=avformat_open_input(&fmt_ctx, src_filename, NULL, NULL)) < 0) {av_log(NULL,AV_LOG_ERROR, "Could not open source file %s, %d\n", src_filename, err_code);return -1; }/* retreive stream information */if((err_code = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {av_log(NULL,AV_LOG_ERROR, "Could not open source file %s, %d\n", src_filename, err_code);return -1;}/* dump input information to stderr */av_dump_format(fmt_ctx, 0, src_filename, 0);/* close input file */avformat_close_input(&fmt_ctx);return 0;
}

其中关键api :

/*** Open an input stream and read the header. The codecs are not opened.* The stream must be closed with avformat_close_input().** @param ps       Pointer to user-supplied AVFormatContext (allocated by*                 avformat_alloc_context). May be a pointer to NULL, in*                 which case an AVFormatContext is allocated by this*                 function and written into ps.*                 Note that a user-supplied AVFormatContext will be freed*                 on failure.* @param url      URL of the stream to open.* @param fmt      If non-NULL, this parameter forces a specific input format.*                 Otherwise the format is autodetected.* @param options  A dictionary filled with AVFormatContext and demuxer-private*                 options.*                 On return this parameter will be destroyed and replaced with*                 a dict containing options that were not found. May be NULL.** @return 0 on success, a negative AVERROR on failure.** @note If you want to use custom IO, preallocate the format context and set its pb field.*/
int avformat_open_input(AVFormatContext **ps, const char *url,const AVInputFormat *fmt, AVDictionary **options);
/*** Close an opened input AVFormatContext. Free it and all its contents* and set *s to NULL.*/
void avformat_close_input(AVFormatContext **s);/*** Read packets of a media file to get stream information. This* is useful for file formats with no headers such as MPEG. This* function also computes the real framerate in case of MPEG-2 repeat* frame mode.* The logical file position is not changed by this function;* examined packets may be buffered for later processing.** @param ic media file handle* @param options  If non-NULL, an ic.nb_streams long array of pointers to*                 dictionaries, where i-th member contains options for*                 codec corresponding to i-th stream.*                 On return each dictionary will be filled with options that were not found.* @return >=0 if OK, AVERROR_xxx on error** @note this function isn't guaranteed to open all the codecs, so*       options being non-empty at return is a perfectly normal behavior.** @todo Let the user decide somehow what information is needed so that*       we do not waste time getting stuff the user does not need.*/int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);

2. gcc编译

sudo gcc -g -o mediainfo_new mediainfo_new.c  `pkg-config -cflags --libs  libavformat libavutil`

3. 执行mediainfo_new

./mediainfo_new ./game.flv
flv @ 0x60df51a89300] After avformat_find_stream_info() pos: 526978 bytes read:557161 seeks:0 frames:104
Input #0, flv, from './game.flv':Metadata:|RtmpSampleAccess: trueencoder         : Lavf61.5.101Duration: 00:00:33.93, start: 0.007000, bitrate: 2507 kb/sStream #0:0, 41, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(tv, bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 0/1, 30 fps, 30 tbr, 1k tbnStream #0:1, 63, 1/1000: Audio: aac (LC), 48000 Hz, stereo, fltp
[AVIOContext @ 0x60df51a91a80] Statistics: 557161 bytes read, 0 seeks

http://www.ppmy.cn/news/1523001.html

相关文章

51单片机的无线病床呼叫系统【proteus仿真+程序+报告+原理图+演示视频】

1、主要功能 该系统由AT89C51/STC89C52单片机LCD1602显示模块温湿度传感器模块矩阵按键时钟模块等模块构成。适用于病床呼叫系统、16床位呼叫等相似项目。 可实现基本功能: 1、LCD1602实时显示北京时间、温湿度信息、呼叫床位等信息&#xff1b; 2、DHT11采集病房温湿度信息&…

Linux echo命令讲解及与重定向符搭配使用方法,tail命令及日志监听方式详解

echo echo具有回声&#xff0c;回响的意思&#xff0c;在linux系统中echo一般可以输出指定字符或用于命令执行 echo命令的用法为 echo 输出字符串 或 echo 命令 若参数为字符串则进行字符串输出&#xff0c;注意若字符串中含空格最好将其用引号括起&#xff0c;防止echo命…

揭秘尖端PCB制造:猎板PCB精工细作铸就电子创新之基

随着科技的不断进步&#xff0c;电子设备正变得越来越小巧、功能越来越强大&#xff0c;这背后离不开精密印刷电路板&#xff08;PCB&#xff09;的制造技术。PCB&#xff0c;作为电子组件的载体&#xff0c;其制造工艺的精细程度直接决定了电子产品的性能和可靠性。本文将带您…

如何做好网络安全

随着互联网技术的飞速发展&#xff0c;网站已成为企业对外展示、交流和服务的重要窗口。然而&#xff0c;随之而来的网站安全问题也日益凸显&#xff0c;给企业的业务发展和用户数据安全带来了巨大威胁。因此&#xff0c;高度重视网站安全已成为网络安全的首要任务。今天我们就…

uni-app开发微信小程序时 - 地理位置接口流程调整

在开发微信小程序时&#xff0c;控制台报“chooseLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json”错误&#xff0c;意思要使用chooseLocation前需要在requiredprivateinfo中先声明。 一、声明接口 由于小程序地理位置很…

结构型设计模式—组合模式

结构型设计模式—组合模式 欢迎长按图片加好友&#xff0c;我会第一时间和你分享持续更多的开发知识&#xff0c;面试资源&#xff0c;学习方法等等。 组合模式&#xff08;Composite Pattern&#xff09;是一种结构型设计模式&#xff0c;它允许你将对象组合成树形结构来表示…

GMT绘图笔记:在地图上绘制直线而不是大圆弧

问题&#xff1a;利用GMT地图上绘制两点之间的直线&#xff0c;如果跨度过大会出现大圆弧线&#xff0c;而通常在备注地图图例的时候&#xff0c;通常需要强制绘制为直线。 在GMT&#xff08;Generic Mapping Tools&#xff09;中&#xff0c;使用plot命令绘制大跨度的范围线段…

让Mac更Mac|明基MA系列显示器上市

凭借出色的性能和设计&#xff0c;MacBook成为了很多人的心头好。可13~16英寸的屏幕&#xff0c;时常让人感到视野受限&#xff0c;就像无边创意中的一道隐形壁垒。想要外接显示大屏&#xff0c;但除了Studio Display等苹果显示器之外&#xff0c;其他品牌的外接显示屏&#xf…

llvm后端之td定义指令信息

llvm后端之td定义指令信息 引言1 定义指令2 定义Operand3 定义SDNode4 PatFrags4.1 ImmLeaf4.2 PatLeaf 5 ComplexPattern6 谓词条件7 理解dag 引言 llvm后端通过td定义指令信息&#xff0c;并通过dag匹配将IR节点转换为平台相关的指令。 1 定义指令 td通过class Instructio…

c语言和c++的区别

在计算机编程领域&#xff0c;C语言和C无疑是两座重要的里程碑。尽管它们在很多方面有着相似之处&#xff0c;但在设计理念、功能特性以及应用场景上&#xff0c;两者又存在着显著的差异。小编将从多个角度深入探讨C语言和C的区别&#xff0c;帮助读者更好地理解这两种编程语言…

不小心从 Android 设备中删除了重要消息,恢复永久删除的消息知识

您是否曾经不小心从 Android 设备中删除了重要消息&#xff0c;并迫切希望能够恢复它们&#xff1f;好吧&#xff0c;好消息是你可以&#xff01;通过一些简单的步骤和正确的工具&#xff0c;您可以恢复那些已删除的消息并找回您认为永远丢失的信息。在本教程中&#xff0c;我将…

Linux操作系统下的一些常用命令分享(ubuntu16.04)

注意一般Linux命令字符与字符之间都是空格来隔开的&#xff0c;所以千万不能忘记打空格&#xff0c;而且Linux区分大小写。&#xff08;目录就是文件夹&#xff09; 1、pwd 查看当前所在目录 2、查看帮助 命令 --help 但是这个命令会把所有内容一次性全部显示我们看帮助时很…

【应急响应】webshell的排查与处置

❤️博客主页&#xff1a; iknow181 &#x1f525;系列专栏&#xff1a; 网络安全、 Python、JavaSE、JavaWeb、CCNP &#x1f389;欢迎大家点赞&#x1f44d;收藏⭐评论✍ 引言 Webshell 是攻击者入侵 Web 服务器后常用的远程控制工具&#xff0c;它通过一段恶意代码&#xff…

12.1.1.案例专题-数据流图

大纲 数据流图 DFD 基本图形元素 外部实体、加工、数据存储、数据流 灰洞、黑洞、奇迹 考题中如果出现黑洞&#xff0c;说明至少缺一条输出 考题中如果出现奇迹&#xff0c;说明至少缺一条输入 考题中几乎不会考到 灰洞 顶层图、0层图、1层图 考试中不会出现 1层图&#x…

3DMax基础- 样条线和点,线,面,边界操作

目录 一、样条线 二、多边形编辑​​​​​​​ 三. 点操作 三、线操作 四、面操作 五. 边界 一、样条线 创建样条线&#xff1a; 在 “创建” 面板中选择 “图形”&#xff0c;然后可以看到各种样条线工具&#xff0c;如线、矩形、圆、椭圆等。以 “线” 工具为例&#…

数据分析——基础

目录 一、什么是数据分析 1、什么是数据 2、数据类型 3、数据分析 3.1 数据分析概念 3.2 数据分析要结合的维度 3.3 数据分析的目的 二、数据分析流程 三、数据呈现形式 1、柱状图 2、折线图 3、柱线图 4、饼图 5、漏斗图 6、雷达图 7、散点图 8、桑基图 …

计算机网络 第二章: 物理层_信道的极限容量 奈氏准则 香农公式 (带习题)

文章目录 1. 造成信号失真的主要因素2. 奈氏准则3. 香农公式习题解答 1. 造成信号失真的主要因素 信道上传输的数字信号&#xff0c;可以看做是多个频率的模拟信号进行多次叠加后形成的方波。 如果数字信号中的高频分量在传输时受到衰减甚至不能通过信道&#xff0c;则接收端接…

高防IP的作用有哪些?

高防IP一般是指哪些能够提供高等级防御服务的IP地址&#xff0c;这些IP地址通常是属于高性能的服务器或者是在互联网基础设施中具有较高的带宽和计算能力会通过将服务器放置在高防IP段中&#xff0c;为用户提供更加高级的DDOS攻击防护。 本文就来探讨一下高防IP的作用都有哪些吧…

TCP 拥塞控制

概念详解 TCP拥塞控制是网络通信中的一个关键机制&#xff0c;它通过动态调整发送数据的速率来避免网络拥塞。以下是TCP拥塞控制的详细概念解释&#xff1a; 拥塞窗口&#xff08;CWND, Congestion Window&#xff09;: 定义&#xff1a;发送方在收到接收方的确认&#xff08;…

oracle数据的完整性

一.数据的完整性 向某张表插入数据、更新、删除数据之前会对数据做校验&#xff0c;目 的就是为了确保数据的正确性、一致性、最大限度 减少重复 的数据、避免脏数据&#xff0c;这就是数据完整性。以下的数据就是脏 数据&#xff1a; 如何减少数据冗余、避免脏数据&#xff1…