資源簡介
記得將ffmpeg/bin目錄下的dll文件拷貝到編譯生成的exe所在的目錄下,否則會無法運行。
關于代碼的解釋 請參考:
http://blog.yundiantech.com/?log=blog&id=15
代碼片段和文件信息
/**
?*?葉海輝
?*?QQ群121376426
?*?http://blog.yundiantech.com/
?*/
#include?
extern?“C“
{
#include?“libavcodec/avcodec.h“
#include?“libavformat/avformat.h“
#include?“libswscale/swscale.h“
#include?“libavdevice/avdevice.h“
}
//‘1‘?Use?Dshow
//‘0‘?Use?VFW
#define?USE_DSHOW?0
//Show?Dshow?Device
void?show_dshow_device(){
????AVFormatContext?*pFormatCtx?=?avformat_alloc_context();
????AVDictionary*?options?=?NULL;
????av_dict_set(&options“list_devices““true“0);
????AVInputFormat?*iformat?=?av_find_input_format(“dshow“);
????printf(“========Device?Info=============\n“);
????avformat_open_input(&pFormatCtx“video=dummy“iformat&options);
????printf(“================================\n“);
}
//Show?Dshow?Device?Option
void?show_dshow_device_option(){
????AVFormatContext?*pFormatCtx?=?avformat_alloc_context();
????AVDictionary*?options?=?NULL;
????av_dict_set(&options“list_options““true“0);
????AVInputFormat?*iformat?=?av_find_input_format(“dshow“);
????printf(“========Device?Option?Info======\n“);
????avformat_open_input(&pFormatCtx“video=Integrated?Camera“iformat&options);
????printf(“================================\n“);
}
//Show?VFW?Device
void?show_vfw_device(){
????AVFormatContext?*pFormatCtx?=?avformat_alloc_context();
????AVInputFormat?*iformat?=?av_find_input_format(“vfwcap“);
????printf(“========VFW?Device?Info======\n“);
????avformat_open_input(&pFormatCtx“list“iformatNULL);
????printf(“=============================\n“);
}
//Show?AVFoundation?Device
void?show_avfoundation_device(){
????AVFormatContext?*pFormatCtx?=?avformat_alloc_context();
????AVDictionary*?options?=?NULL;
????av_dict_set(&options“list_devices““true“0);
????AVInputFormat?*iformat?=?av_find_input_format(“avfoundation“);
????printf(“==AVFoundation?Device?Info===\n“);
????avformat_open_input(&pFormatCtx““iformat&options);
????printf(“=============================\n“);
}
#define?USE_DSHOW?1
int?main(int?argc?char*?argv[])
{
????AVFormatContext *pFormatCtx;
????int i?videoindex;
????AVCodecContext *pCodecCtx;
????AVCodec *pCodec;
????av_register_all();
????avformat_network_init();
????avdevice_register_all();//Register?Device
????//Show?Dshow?Device
????show_dshow_device();
????//Show?Device?Options
//????show_dshow_device_option();
????//Show?VFW?Options
//????show_vfw_device();
????pFormatCtx?=?avformat_alloc_context();
#if?USE_DSHOW
????AVInputFormat?*ifmt=av_find_input_format(“dshow“);
????//Set?own?video?device‘s?name
????if(avformat_open_input(&pFormatCtx“video=e2eSoft?VCam“ifmtNULL)!=0){
????????printf(“Couldn‘t?open?input?stream.\n“);
????????return?-1;
????}
#else
????AVInputFormat?*ifmt=av_find_input_format(“vfwcap“);
????if(avformat_open_input(&pFormatCtx“0“ifmtNULL)!=0){
????????printf(“Couldn‘t?open?input?stream.\n“);
????????return?-1;
????}
#endif
????if(avformat_find_stream_info(pFormatCtxNULL)<0)
????{
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-09-22?17:19??VideoRecorder_1\
?????目錄???????????0??2016-09-19?22:33??VideoRecorder_1\ffmpeg\
?????目錄???????????0??2016-09-19?22:33??VideoRecorder_1\ffmpeg\bin\
?????文件????19646464??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\avcodec-56.dll
?????文件?????1367552??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\avdevice-56.dll
?????文件?????2314752??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\avfilter-5.dll
?????文件?????5839360??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\avformat-56.dll
?????文件??????452096??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\avutil-54.dll
?????文件??????324608??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\ffmpeg.exe
?????文件??????475136??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\ffplay.exe
?????文件??????152576??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\ffprobe.exe
?????文件??????121344??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\postproc-53.dll
?????文件??????270336??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\swresample-1.dll
?????文件??????446976??2014-12-31?06:21??VideoRecorder_1\ffmpeg\bin\swscale-3.dll
?????目錄???????????0??2016-09-19?22:33??VideoRecorder_1\ffmpeg\include\
?????目錄???????????0??2016-09-19?22:33??VideoRecorder_1\ffmpeg\include\libavcodec\
?????文件??????179819??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\avcodec.h
?????文件????????3111??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\avfft.h
?????文件????????3764??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\dv_profile.h
?????文件????????2358??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\dxva2.h
?????文件???????10623??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\old_codec_ids.h
?????文件????????4007??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\vaapi.h
?????文件????????5437??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\vda.h
?????文件????????7094??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\vdpau.h
?????文件????????6340??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\version.h
?????文件????????2317??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\vorbis_parser.h
?????文件????????6062??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavcodec\xvmc.h
?????目錄???????????0??2016-09-19?22:33??VideoRecorder_1\ffmpeg\include\libavdevice\
?????文件???????16642??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavdevice\avdevice.h
?????文件????????1859??2014-12-31?06:21??VideoRecorder_1\ffmpeg\include\libavdevice\version.h
?????目錄???????????0??2016-09-19?22:33??VideoRecorder_1\ffmpeg\include\libavfilter\
............此處省略111個文件信息
- 上一篇:黑客入門書籍
- 下一篇:conquer征服服務器端+數據庫1
評論
共有 條評論