
FFmpeg Basics
Multimedia handling with a
fast audio and video encoder
Frantisek Korbel

FFmpeg Basics
Copyright © 2012 Frantisek Korbel
All rights reserved.
Please if trademarked names are used in this book without a trademark symbol,
it is for easier reading with no intention of infringement of the trademark.
Book index, user forum and other resources
are available on the website ffmpeg.tv.
ISBN: 1479327832
ISBN-13: 978-1479327836

Acknowledgements
The greatest thanks belongs to the developers of excellent FFmpeg tools and libraries and to the whole
FFmpeg community that drives this project forward. The project documentation was the main source for
the book.
Another great source was the Wikipedia, especially articles about color spaces, quantization, sampling, etc.
Thank you very much and best wishes.

Brief Contents
Introduction 12
1. FFmpeg Fundamentals 15
2. Displaying Help and Features 29
3. Bit Rate, Frame Rate and File Size 60
4. Resizing and Scaling Video 64
5. Cropping Video 69
6. Padding Video 73
7. Flipping and Rotating Video 77
8. Blur, Sharpen and Other Denoising 81
9. Overlay - Picture in Picture 87
10. Adding Text on Video 93
11. Conversion Between Formats 99
12. Time Operations 108
13. Mathematical Functions 113
14. Metadata and Subtitles 117
15. Image Processing 122
16. Digital Audio 128
17. Presets for Codecs 138
18. Interlaced Video 142
19. FFmpeg Components and Projects 147
20. Microphone and Webcam 154
21. Batch Files 159
22. Color Corrections 164
23. Advanced Techniques 179
24. Video on Web 193
25. Debugging and Tests 200
Glossary 207
About the author 216

Table of Contents
Introduction ......................................................................................................12
Welcome................................................................................................................................12
First steps..............................................................................................................................12
Dedicated website.................................................................................................................12
Conventions ..........................................................................................................................13
Your feedback is important ................................................................................................14
1. FFmpeg Fundamentals ................................................................................15
FFmpeg introduction...........................................................................................................15
Developers of FFmpeg.........................................................................................................16
Participation in FFmpeg development ..............................................................................16
FFmpeg download ...............................................................................................................17
Command line syntax ..........................................................................................................17
Windows Command Prompt and its alternatives.............................................................18
Path setting ...........................................................................................................................19
Renaming to shortened form ..............................................................................................20
Displaying output preview ..................................................................................................21
Preview with FFplay media player ...................................................................................21
Preview with SDL output device ......................................................................................21
SI prefixes available in FFmpeg .........................................................................................21
Transcoding with ffmpeg ....................................................................................................22
Filters, filterchains and filtergraphs ..................................................................................23
Selection of media streams..................................................................................................25
Lavfi virtual device ..............................................................................................................27
Color names..........................................................................................................................27
2. Displaying Help and Features .....................................................................29
Text help in FFmpeg tools...................................................................................................29
Available bitstream filters...................................................................................................29
Available codecs ...................................................................................................................30
Available decoders ...............................................................................................................36
Available encoders ...............................................................................................................43
Available filters ....................................................................................................................46
Available formats.................................................................................................................48
Available layouts of audio channels ...................................................................................52
FFmpeg license.....................................................................................................................54
Available pixel formats........................................................................................................54
Available protocols ..............................................................................................................57
Available audio sample formats .........................................................................................58
FFmpeg version....................................................................................................................58
Using MORE command for output formatting ................................................................59
Redirecting output to file ....................................................................................................59
3. Bit Rate, Frame Rate and File Size.............................................................60
Frame (frequency) rate introduction .................................................................................60
Frame rate setting................................................................................................................61
Using -r option ..................................................................................................................61
Using fps filter...................................................................................................................61
Predefined values for frame rate........................................................................................61
Bit (data) rate introduction.................................................................................................62