最简单的基于FFMPEG的Helloworld程序
生活随笔
收集整理的這篇文章主要介紹了
最简单的基于FFMPEG的Helloworld程序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
學習雷神的FFMPEG入門教程,本文基于命令行實現。
文件結構
G:\Coding\FFMpeg\Proj\Console>dir驅動器 G 中的卷沒有標簽。卷的序列號是 0FD5-0CC8G:\Coding\FFMpeg\Proj\Console 的目錄2016/08/10 12:46 <DIR> . 2016/08/10 12:46 <DIR> .. 2016/04/14 11:08 24,464,896 avcodec-57.dll 2016/04/14 11:08 168,948 avcodec.lib 2016/04/14 11:08 1,363,968 avdevice-57.dll 2016/04/14 11:08 15,628 avdevice.lib 2016/04/14 11:08 3,799,552 avfilter-6.dll 2016/04/14 11:08 50,364 avfilter.lib 2016/04/14 11:08 4,929,536 avformat-57.dll 2016/04/14 11:08 133,888 avformat.lib 2016/04/14 11:08 604,672 avutil-55.dll 2016/04/14 11:08 359,056 avutil.lib 2016/06/23 09:59 21,987,736 bad.mp4 2016/08/09 18:25 424 compile.bat 2016/04/14 11:08 <DIR> libavcodec 2016/04/14 11:08 <DIR> libavdevice 2016/04/14 11:08 <DIR> libavfilter 2016/04/14 11:08 <DIR> libavformat 2016/04/14 11:08 <DIR> libavutil 2016/04/14 11:08 <DIR> libpostproc 2016/04/14 11:08 <DIR> libswresample 2016/04/14 11:08 <DIR> libswscale 2016/04/14 11:08 110,080 postproc-54.dll 2016/04/14 11:08 8,904 postproc.lib 2016/04/14 11:08 287,232 swresample-2.dll 2016/04/14 11:08 17,944 swresample.lib 2016/04/14 11:08 513,536 swscale-4.dll 2016/04/14 11:08 27,064 swscale.lib 2013/09/01 09:07 5,800 test.swf 2016/08/09 18:01 4,334 tutorial.c 2016/08/10 12:01 3,075 tutorial.cpp21 個文件 58,856,637 字節10 個目錄 10,641,301,504 可用字節G:\Coding\FFMpeg\Proj\Console>
自己利用批處理寫的一小段編譯鏈接代碼:
@echo off color a call D:\VS2013\VC\vcvarsall.bat x86 cl /c tutorial.cpp if %errorlevel% == 0 (goto :LINK) else ((echo CL error) && goto :END)pause:LINK link tutorial.obj avformat.lib avfilter.lib avcodec.lib avutil.lib postproc.lib swresample.lib swscale.lib avdevice.lib if %errorlevel% == 0 (goto :RUN) else ((echo LINK error) && goto :END):RUN tutorial.exe tutorial.exe > 1.txt 1.txt:END @pause=====================================================
最簡單的基于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.csdn.net/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 //Windows extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libavfilter/avfilter.h" }; #else //Linux... #ifdef __cplusplus extern "C" { #endif #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libavfilter/avfilter.h> #ifdef __cplusplus }; #endif #endif//FIX struct URLProtocol; /*** Protocol Support Information*/ char * urlprotocolinfo(){char *info=(char *)malloc(40000);memset(info,0,40000);av_register_all();struct URLProtocol *pup = NULL;//Inputstruct 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;//Outputavio_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);//Inputwhile(if_temp!=NULL){sprintf(info, "%s[In ] %10s\n", info, if_temp->name);if_temp=if_temp->next;}//Outputwhile (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; }
輸出
轉載于:https://www.cnblogs.com/lgh1992314/p/5834653.html
總結
以上是生活随笔為你收集整理的最简单的基于FFMPEG的Helloworld程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android studio中不同颜色代
- 下一篇: php四种基础排序算法的运行时间比较