參考 http://dranger.com/ffmpeg/tutorial04.html 進行實作練習,以下附上一個可以在 ffmpeg 1.1.1 (build Jan 27 2013) 正確編譯的例子。
// tutorial04.c
// A pedagogical video player that will stream through every video frame as fast as it can,
// and play audio (out of sync).
//
// Code based on FFplay, Copyright (c) 2003 Fabrice Bellard,
// and a tutorial by Martin Bohme (boehme@inb.uni-luebeckREMOVETHIS.de)
// Tested on Gentoo, CVS version 5/01/07 compiled with GCC 4.1.1
// Use
//
// gcc -o tutorial04 tutorial04.c -lavformat -lavcodec -lz -lm `sdl-config --cflags --libs`
// to build (assuming libavformat and libavcodec are correctly installed,
// and assuming you have sdl-config. Please refer to SDL docs for your installation.)
//
// Run using
// tutorial04 myvideofile.mpg
//
// to play the video stream on your screen.
// 20130204 albert.liao modified start
//#include
//#include
//#include
//#include
#include
#include
#include
#include
#include
//#undef main /* Prevents SDL from overriding main() */
// 20130204 albert.liao modified end
#ifdef __MINGW32__
#undef main /* Prevents SDL from overriding main() */
#endif
#include
#include