int main(int argc, char *argv[])
{
const char* file_name = "video.mp4";
int ret;
unsigned int i; AVFormatContext *ifmt_ctx = NULL; av_register_all();
if ((ret = avformat_open_input(&ifmt_ctx, file_name, NULL, NULL)) < ) {
printf("Cannot open input file\n");
return ret;
} if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < ) {
printf("Cannot find stream information\n");
return ret;
} for (i = ; i < ifmt_ctx->nb_streams; i++) {
if (ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
printf("width:%d\n",ifmt_ctx->streams[i]->codec->width);
printf("height:%d\n",ifmt_ctx->streams[i]->codec->height);
}
} return ;
}

或者用mediainfo

http://blog.csdn.net/leixiaohua1020/article/details/11902195

 int main()
{
MediaInfo MI;
CString width,height;
MI.Open("file.mp4");
width = MI.Get(stream_t::Stream_Video,,"Width").c_str();
height = MI.Get(stream_t::Stream_Video,,"Height").c_str();
printf("width: %s, height: %s\n", width, height);
MI.Close();
}

要是内存数据可以参考

http://blog.csdn.net/leixiaohua1020/article/details/12980423

即自己写好buffer的回调函数然后注册……

ffmpeg 获取视频宽高的更多相关文章

  1. 从H264码流中获取视频宽高 (SPS帧) 升级篇

    之前写过 <从H264码流中获取视频宽高 (SPS帧)> . 但发现很多局限性,而且有时解出来是错误的. 所以重新去研究了. 用了 官方提供的代码库来解析. 花了点时间,从代码库里单独把解 ...

  2. 从H264码流中获取视频宽高 (SPS帧)

    获取.h264视频宽高的方法 花了2个通宵终于搞定.(后面附上完整代码) http://write.blog.csdn.net/postedit/7852406 图像的高和宽在H264的SPS帧中.在 ...

  3. android中加载的html获取的宽高不正确

    wap页面使用 js库是zepto,按照惯例在$(function(){})中,来获取当前可视区的宽高,但得到的宽高却与预想的相差十万八千里. 原本android手机的浏览器设定的宽高基本是360*6 ...

  4. 微信 小程序 drawImage wx.canvasToTempFilePath wx.saveFile 获取设备宽高 尺寸问题

    以下问题测试环境为微信开发者0.10.102800,手机端iphone6,如有不对敬谢指出. 根据我的测试,context.drawImage,在开发者工具中并不能画出来,只有预览到手机中显示. wx ...

  5. JS快速获取图片宽高的方法

    快速获取图片的宽高其实是为了预先做好排版样式布局做准备,通过快速获取图片宽高的方法比onload方法要节省很多时间,甚至一分钟以上都有可能,并且这种方法适用主流浏览器包括IE低版本浏览器. 我们一步一 ...

  6. view--4种Android获取View宽高的方式

    有时我们会有基于这样的需求,当Activity创建时,需要获取某个View的宽高,然后进行相应的操作,但是我们在onCreate,onStart中获取View的大小,获取到的值都是0,只是由于View ...

  7. 转载:JS快速获取图片宽高的方法

    快速获取图片的宽高其实是为了预先做好排版样式布局做准备,通过快速获取图片宽高的方法比onload方法要节省很多时间,甚至一分钟以上都有可能,并且这种方法适用主流浏览器包括IE低版本浏览器. 我们一步一 ...

  8. android获取屏幕宽高与获取控件宽高

    获取屏幕宽高 // 获取屏幕宽高(方法1) int screenWidth = getWindowManager().getDefaultDisplay().getWidth(); // 屏幕宽(像素 ...

  9. JQUERY获取loaded 宽高这么变态

    JQUERY获取loaded 宽高这么变态: $('<img/>').attr('src',img.src).load(function() { img.Owidth = $(this). ...

随机推荐

  1. JAVA实现EXCEL公式专题(七)——统计函数

    统计函数主要实现的是较为复杂的统计函数如countif.sumif.frequency,也是,直接上代码 /** * 项目名称: * 文件说明: * 主要特点:文件说明:EXCEL函数类型:统计函数 ...

  2. quartz项目中的运用

    下面是之前项目中quartz的运用,我将它梳理出来. 测试类: public class OrdExpireTaskMain { public static void main(String[] ar ...

  3. PHP - 获取音频长度

    getID3() 是从MP3等媒体文件中提取文件信息的php类,既可以提取也能修改文件的标签信息.它能读取的文件类型非常多,例如MP3.wav等. 示例官方下载地址:http://sourceforg ...

  4. LeetCode78:Subsets

    Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must ...

  5. 3s 简介

    "3S"技术是英文遥感技术(Remote Sensing RS).地理信息系统(Geographical information System GIS).全球定位系统(Global ...

  6. Angular1.0 在Directive中调用Controller的方法

    Controller中定义了$scope.method = function(){} Directive中需要引入$scope http://stackoverflow.com/questions/2 ...

  7. linux卸载一个源码包安装的软件的流程

    完全卸载memcached的方法(CentOS) 我的大内存vps(centos系统)曾经安装过memcached,想给论坛提速,实际上不但没有明显效果,反倒耗费内存,看着碍眼,于是想卸载,于是网上各 ...

  8. ios 即时通讯 xmpp

    [iPhone高级] 基于XMPP的IOS聊天客户端程序(XMPP服务器架构) http://blog.csdn.NET/kangx6/article/details/7739828 [iPhone高 ...

  9. linux关机前同步数据(sync)

    sync,将内存中未更新的数据写入硬盘中.

  10. lua(简单的传参)

    #include <iostream> #include <string.h> extern "C" { /*头文件lua.h定义了Lua提供的基础函数,包 ...