最简单的基于FFMPEG的Helloworld程序

本文介绍了一个基于FFmpeg的简单HelloWorld程序,用于验证FFmpeg的安装配置。程序展示了如何打印FFmpeg库的基本信息,包括Configure、Protocol和AVFormat信息。此外,文章还提到了Markdown编辑器的新功能,如代码高亮、图片拖拽、数学公式支持等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

=====================================================

最简单的基于FFmpeg的视频播放器系列文章列表:

100行代码实现最简单的基于FFMPEG+SDL的视频播放器(SDL1.x)

最简单的基于FFMPEG+SDL的视频播放器 ver2 (采用SDL2.0)

最简单的基于FFmpeg的解码器-纯净版(不包含libavformat)

最简单的基于FFMPEG+SDL的视频播放器:拆分-解码器和播放器

最简单的基于FFMPEG的Helloworld程序

=====================================================



本文记录一个基于FFmpeg的HelloWorld程序。该程序可以打印出FFmpeg类库的基本信息。使用该程序通常可以验证FFmpeg是否正确的安装配置。


源代码

/** * 最简单的FFmpeg Helloworld程序 * Simplest FFmpeg HelloWorld * * 雷霄骅 Lei Xiaohua * leixiaohua1020@126.com * 中国传媒大学/数字电视技术 * Communication University of China / Digital TV Technology * http://blog.youkuaiyun.com/leixiaohua1020 * *  * 本程序是基于FFmpeg函数的最简单的程序。它可以打印出FFmpeg类库的下列信息: * Protocol:  FFmpeg类库支持的协议 * AVFormat:  FFmpeg类库支持的封装格式 * AVCodec:   FFmpeg类库支持的编解码器 * AVFilter:  FFmpeg类库支持的滤镜 * Configure: FFmpeg类库的配置信息 *  * This is the simplest program based on FFmpeg API. It can show following  * informations about FFmpeg library: * Protocol:  Protocols supported by FFmpeg. * AVFormat:  Container format supported by FFmpeg. * AVCodec:   Encoder/Decoder supported by FFmpeg. * AVFilter:  Filters supported by FFmpeg. * Configure: configure information of FFmpeg. * */#include <stdio.h>#define __STDC_CONSTANT_MACROS#ifdef _WIN32//Windowsextern "C"{
   
   #include "libavcodec/avcodec.h"#include "libavformat/avformat.h"#include "libavfilter/avfilter.h"};#else//Linux...#ifdef __cplusplusextern "C"{
   
   #endif#include <libavcodec/avcodec.h>#include <libavformat/avformat.h>#include <libavfilter/avfilter.h>#ifdef __cplusplus};#endif#endif//FIXstruct 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;}



运行结果


Configure信息格式如下所示。

--disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib

Protocol信息格式如下所示。

[In ][     cache][In ][    concat][In ][    crypto][In ][      data][In ][      file][In ][       ftp][In ][    gopher][In ][       hls][In ][      http][In ][ httpproxy][In ][     https][In ][      mmsh][In ][      mmst][In ][      pipe][In ][       rtp][In ][      srtp][In ][   subfile][In ][       tcp][In ][       tls][In ][       udp][In ][      rtmp][In ][     rtmpe][In ][     rtmps][In ][     rtmpt][In ][    rtmpte][In ][    (null)][Out][       ftp][Out][    gopher][Out][      http][Out][ httpproxy][Out][     https][Out][   &nbs
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值