ffmpeg helloworld之vs2008

我的ffmpeg的頭文件和dll. lib都是從雷神的ffplaymfc裏提取的。

新建vs工程.控制檯。  鏈接裏輸入

avutil.lib
avcodec.lib
avformat.lib
avdevice.lib
avfilter.lib
postproc.lib
swresample.lib
swscale.lib
SDL.lib

 

項目設置unicode編碼  


#include "stdafx.h"
#include <stdint.h> 
/**
 
 * 
 * 本程序是基於FFmpeg函數的最簡單的程序。它可以打印出FFmpeg類庫的下列信息:
 * Protocol:  FFmpeg類庫支持的協議
 * AVFormat:  FFmpeg類庫支持的封裝格式
 * AVCodec:   FFmpeg類庫支持的編解碼器
 * AVFilter:  FFmpeg類庫支持的濾鏡
 * Configure: FFmpeg類庫的配置信息
 
 */
 
#include <stdio.h>
 
 
   
//Windows
extern "C"
{

#include "libavutil/log.h"
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavfilter/avfilter.h"

};
 
 
 
 
//FIX
struct URLProtocol;
/**
 * Protocol Support Information
 */
char * urlprotocolinfo(){
	
	char *info=(char *)malloc(40000);
	memset(info,0,40000);
 
	av_register_all();
 
	struct URLProtocol *pup = NULL;
	//Input
	struct URLProtocol **p_temp = &pup;
	avio_enum_protocols((void **)p_temp, 0);
	while ((*p_temp) != NULL){
		sprintf(info, "%s[In ][%10s]\n", info, avio_enum_protocols((void **)p_temp, 0));
	}
	pup = NULL;
	//Output
	avio_enum_protocols((void **)p_temp, 1);
	while ((*p_temp) != NULL){
		sprintf(info, "%s[Out][%10s]\n", info, avio_enum_protocols((void **)p_temp, 1));
	}
 
	return info;
}
 
/**
 * AVFormat Support Information
 */
char * avformatinfo(){
 
	char *info=(char *)malloc(40000);
	memset(info,0,40000);
 
	av_register_all();
 
	AVInputFormat *if_temp = av_iformat_next(NULL);
	AVOutputFormat *of_temp = av_oformat_next(NULL);
	//Input
	while(if_temp!=NULL){
		sprintf(info, "%s[In ] %10s\n", info, if_temp->name);
		if_temp=if_temp->next;
	}
	//Output
	while (of_temp != NULL){
		sprintf(info, "%s[Out] %10s\n", info, of_temp->name);
		of_temp = of_temp->next;
	}
	return info;
}
 
/**
 * AVCodec Support Information
 */
char * avcodecinfo()
{
	char *info=(char *)malloc(40000);
	memset(info,0,40000);
 
	av_register_all();
 
	AVCodec *c_temp = av_codec_next(NULL);
 
	while(c_temp!=NULL){
		if (c_temp->decode!=NULL){
			sprintf(info, "%s[Dec]", info);
		}
		else{
			sprintf(info, "%s[Enc]", info);
		}
		switch (c_temp->type){
		case AVMEDIA_TYPE_VIDEO:
			sprintf(info, "%s[Video]", info);
			break;
		case AVMEDIA_TYPE_AUDIO:
			sprintf(info, "%s[Audio]", info);
			break;
		default:
			sprintf(info, "%s[Other]", info);
			break;
		}
 
		sprintf(info, "%s %10s\n", info, c_temp->name);
 
		c_temp=c_temp->next;
	}
	return info;
}
 
/**
 * AVFilter Support Information
 */
char * avfilterinfo()
{
	char *info=(char *)malloc(40000);
	memset(info,0,40000);
 
	avfilter_register_all();
 
	AVFilter *f_temp = (AVFilter *)avfilter_next(NULL);
	
	while (f_temp != NULL){
		sprintf(info, "%s[%15s]\n", info, f_temp->name);
		f_temp=f_temp->next;
	}
	return info;
}
 
/**
 * Configuration Information
 */
char * configurationinfo()
{
	char *info=(char *)malloc(40000);
	memset(info,0,40000);
 
	av_register_all();
 
	sprintf(info, "%s\n", avcodec_configuration());
 
	return info;
}
 
int main(int argc, char* argv[])
{
	char *infostr=NULL;
	infostr=configurationinfo();
	printf("\n<<Configuration>>\n%s",infostr);
	free(infostr);
 
	infostr=urlprotocolinfo();
	printf("\n<<URLProtocol>>\n%s",infostr);
	free(infostr);
 
	infostr=avformatinfo();
	printf("\n<<AVFormat>>\n%s",infostr);
	free(infostr);
 
	infostr=avcodecinfo();
	printf("\n<<AVCodec>>\n%s",infostr);
	free(infostr);
 
	infostr=avfilterinfo();
	printf("\n<<AVFilter>>\n%s",infostr);
	free(infostr);
 
	return 0;

}

 

如果一切ok,運行截圖類似

hello  world就搞好了。你可以開始下一步的ffmpeg之旅了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章