ffmpeg is a wonderful library for creating video applications or even general
purpose utilities. ffmpeg takes care of all the hard work of video processing
by doing all the decoding, encoding, muxing and demuxing for you. This can
make media applications much simpler to write. It’s simple, written in C,
fast, and can decode almost any codec you’ll find in use today, as well as
encode several other formats.
FFMPEG是一个很好的库,可以用来创建视频应用或者生成特定的工具。FFMPEG几乎为你把所有的繁重工作都做了,比如解码、编码、复用和解复用,这使得编写多媒体应用程序变得更容易。
它是一个用 C 编写的,简单,快速并且能够解码几乎所有你能用到的格式,当然也包括编码多种格式。
The only problem is that documentation was basically nonexistent. There is a
single tutorial that shows the basics of ffmpeg and auto-generated doxygen
documents. That’s it. So, when I decided to learn about ffmpeg, and in the
process about how digital video and audio applications work, I decided to
document the process and present it as a tutorial.
唯一的问题是它基本上是没有文档的。有一个单独的教程讲了它的基本原理另外还有一个使用 doxygen 生成的文档,就这么点。所以当我决定研究FFMPEG来弄清楚音视频应用程序是如何工作时,我决定把这个过程用文档的形式记录并且发布出来作为初学教程。
There is a sample program that comes with ffmpeg called ffplay. It is a simple
C program that implements a complete video player using ffmpeg. This tutorial
will begin with an updated version of the original tutorial, written by Martin
Bohme (I have stolen liberally borrowed from that work), and work from there
to developing a working video player, based on Fabrice Bellard’s ffplay.c. In
each tutorial, I’ll introduce a new idea (or two) and explain how we implement
it. Each tutorial will have a C file so you can download it, compile it, and
follow along at home. The source files will show you how the real program
works, how we move all the pieces around, as well as showing you the technical
details that are unimportant to the tutorial. By the time we are finished, we
will have a working video player written in less than 1000 lines of code!
在FFMPEG工程中有一个示例的程序叫作ffplay。它是一个简单的C程序,利用 ffmpeg 来实现了一个视频播放的完整播放器。这个教程将从原来 Martin Bohme 写的一个更新版本的教程开始,基于 Fabrice Bellard 的 ffplay,我将从那里开发一个可以使用的视频播放器。在每一个教程中,我将介绍一两个新的主意并且讲解我们如何来实现它。每一个教程都会有一个 C 源文件,你可以下载,编译并沿着这条思路来自己做。源文件将向你展示一个真正的程序是如何运行,我们如何来调用所有的部件,也将告诉你在这个教程中并不重要的技术实现细节。当我们结束这个教程的时候,我们将有一个少于 1000 行代码的可用的视频播放器。
In making the player, we will be using SDL to output the audio and video of
the media file. SDL is an excellent cross-platform multimedia library that’s
used in MPEG playback software, emulators, and many video games. You will need
to download and install the SDL development libraries for your system in order
to compile the programs in this tutorial.
在写播放器的过程中,我们将使用SDL来输出音频和视频。SDL 是一个优秀的跨平台的多媒体库,被用在MPEG 播放、模拟器和很多电子游戏中。你将需要下载并安装 SDL 开发库到你的系统中,用来编译这个教程中的程序。
This tutorial is meant for people with a decent programming background. At the
very least you should know C and have some idea about concepts like queues,
mutexes, and so on. You should know some basics about multimedia; things like
waveforms and such, but you don’t need to know a lot, as I explain a lot of
those concepts in this tutorial.
这篇教程适用于具有相当编程背景的人。至少应该懂得 C 并且有队列和互斥量等概念。你应当了解基本的多媒体中像波形一类的概念,但是你不必知道的太多,因为我将在这篇教程中介绍很多这样的概念。