Recent projects related to the development of streaming media, because of the development experience know its difficulty, no way can only be picked up, the latest version of the SDK was changed a mess, but the general development of ideas are the same, see how many books to check how much information is useless, step by step to write code is the key to learn.
I will pass every day of learning, updated to the blog post, I hope to give more people want to learn to bring help, the end of the article attached to the project and the latest version of the SDK.
FFmpeg is used by most people to command the line, in fact, in real streaming media development, in order to flexibly use its development of streaming media application sequence, must use the official SDK development, in fact, we have a lot of products on the market
are based on ffmpeg, such as XX Av.
FFmpeg official website http://www.ffmpeg.org/
API Address http://www.ffmpeg.org/doxygen/trunk/index.html
Because the compilation in Windows is very painful, so it is recommended to download the compiled binaries directly, note that the official web site does not have a direct complete development package, you need to remove the download Linux or Windows
Shared libraries for Windows also need to download. lib Import library, since I am windows here I will provide windows
http://ffmpeg.zeranoe.com/builds/This page can be downloaded to the dynamic library and to the storage. Because FFmpeg has been entrusted to other organizations to maintain ... Find it on the page below there is also a point is that since the use of other people's things to remember must follow the LGPL or GPL license ... Don't embarrass your countrymen.
That's what foreigners say.
Donating shows that's benefit from my work and is thankful for the time I spend on it. So if you like my work and would like to see more, feel free to donate, if you can ' t right now don ' t worry about it and Ju St enjoy using FFmpeg on Windows. Thank all who have donated in the past!
Specific no nonsense, how to configure the project what, this is the novice level of the problem, I will not elaborate directly on the code plus comments I will provide source code download ... Project configuration Well, everyone, download the research.
Ffmpeg_test.cpp: Defines the entry point of the console application. #include "stdafx.h" #include <windows.h> #ifdef _cpprttiextern "C" {#endif # include "libavcodec/avcodec.h"//Codec Device # include "libavformat/avformat.h"//Format context #include "libavformat/avio.h"//Audio/video Io#include "libavutil/file.h"//Processing Files # Ifdef _cpprtti}; #endifvoid setstdclr (WORD wd) {Setconsoletextattribute (:: GetStdHandle (Std_output_handle), wd);} int _tmain (int argc, _tchar* argv[]) {//Register all encoder parser Binary stream filter av_register_all (); Avcodec_register_all (); SETSTDCLR (foreground_red | Foreground_green); Avformatcontext *pcontext=null;//format context int errno=0; Pcontext=avformat_alloc_context (); Open input File New interface if (0==avformat_open_input (&pcontext, ". \\test.mp4", nullptr,null)) {printf ("Open file input succeeded!\n");} else return 0; Retrieves the stream information from the context if (0==avformat_find_stream_info (pcontext,null)) {printf ("Get Flow information successfully!\n");} Elsereturn 0;//Loop multiple Flow setstdclr (foreground_red | Foreground_blue); for (unsigned int i=0;i<pcontext->nb_streams;i++) {//Media stream Avstream *pstream = pcontext->streams[i];//frame rate information is rational number/irrational number avrational frame =pstream->r_frame_rate; Time ratio unit Avrational timebase = pstream->time_base; The duration bit rate of the stream int64_t duration= pstream->duration; printf ("Media Duration%d\n", duration);//Get the encoding type Avcodeccontext *pcodeccontext=pstream->codec;//Get Media type/**************** * Enum Avmediatype {avmedia_type_unknown =-1,///< Usually treated as Avmedia_type_dataavmedia_type_video,avmedia_type_audio,avmedia_type_data,///< Opaque DATA Information usually continuousavmedia_type_subtitle,avmedia_type_attachment,///< Opaque data information usually s PARSEAVMEDIA_TYPE_NB}; *//************************************************************************/avmediatype avMediaType= pcodeccontext->codec_type;//encoder idavcodecid codecid=pcodeccontext->codec_id; if (AvMediaType = = AVMEDIA_TYPE_ AUDIO) {//if it is video int audiochannels = PcodeccontexT->channels;int samplerate = pcodeccontext->sample_rate; PixelFormat PixelFormat = pcodeccontext->pix_fmt;printf ("stream%d audio \ n", i);p rintf ("Audio sampling frequency%d/%d\n", Timebase.num, Timebase.den);p rintf ("Audio Time Unit%d/%d\n", Timebase.num,timebase.den);p rintf ("Number of audio channels%d\n", audiochannels);} else if (Avmediatype = = Avmedia_type_video) {//If it is an audio int videowidth = Pcodeccontext->width;int Videoheight = pcodeccontext->height; Avsampleformat samplefmt = pcodeccontext->sample_fmt;printf ("stream%d video \ n", i);p rintf ("frame rate frame rate%d/%d\n", Frame.den, Frame.num);p rintf ("Video Time Unit%d/%d\n", Timebase.num,timebase.den);p rintf ("image width:%d\t height:%d\t%\n", Videowidth, Videoheight);p rintf ("image width:%d\t height:%d\t%\n", videowidth,videoheight);} Switch (codecid) {case av_codec_id_aac:printf ("Encoder faac\n"); Break;case av_codec_id_h264:printf ("encoder h264\n"); break;}} Releases the context environment if (!pcontext) {avformat_close_input (&pcontext);} return 0;}
The results of the operation are as follows:
Engineering
http://download.csdn.net/detail/yue7603835/8268095
Development of streaming media based on FFmpeg SDK 1---Decoding media file stream information