栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

ffmpeg——vs集成ffmpeg相关开发

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ffmpeg——vs集成ffmpeg相关开发

ffmpeg是强大且完全开源的音视频处理工具,下文主要说明在windows下vs开发工具集成ffmpeg进行相关开发工作


一、将ffmpeg相关的api放入工程



二、配置包含目录、引用目录、链接器等环境



三、动态链接库dll文件可以放到debug目录下




四、代码开发


比如,一个简单的求输入视频文件时长的函数


头文件:

extern "C"
{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
};

 

 


函数实现:


float getvideolen(string strInputVideo){	float VideoLen =-1;	AVFormatContext	*pFormatCtx=NULL;	pFormatCtx = avformat_alloc_context();	int nerrnum = avformat_open_input(&pFormatCtx,strInputVideo.c_str(),NULL,NULL);	if( nerrnum!=0 )	{		return -2;	}	nerrnum = avformat_find_stream_info(pFormatCtx,NULL);	if( nerrnum<0 )	{		return -3;	}	if (pFormatCtx->nb_streams >0)	{		if(pFormatCtx->duration >0)		{			VideoLen= pFormatCtx->duration;		}		else		{			VideoLen= -4;		}	}	else	{		VideoLen = -5;	}	avformat_close_input(&pFormatCtx);	avformat_free_context(pFormatCtx);	return VideoLen/1000000;           //ffmpeg返回的是微秒,转换成秒}


主函数时记得要初始化av_register_all();




int main(int argc, char* argv[]){	av_register_all();		if(NULL==argv[1])	{		cout<<"No such Input file"<#endif


#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif

 


运行截图:




完整项目工程包下载:http://download.csdn.net/download/sm9sun/9687608


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/232615.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号