FFmpeg Basics
Multimedia handling with a
fast audio and video encoder
Frantisek Korbel
Links
Book homepage: http://ffmpeg.tv
Facebook: http://ffmpeg.tv/facebook
Twitter: http://twitter.com/FFmpeg
YouTube: http://youtube.com/FFmpegTv
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
Table of Contents
4
Setting bit rate......................................................................................................................62
Constant bit rate (CBR) setting..........................................................................................62
Setting maximum size of output file...................................................................................63
File size calculation ..............................................................................................................63
4. Resizing and Scaling Video.......................................................................... 64
Resizing video .......................................................................................................................64
Predefined video frame sizes...............................................................................................64
Considerations when resizing - Nyquist sampling theorem.............................................66
Special enlarging filter.........................................................................................................67
Advanced scaling..................................................................................................................67
Scaling video proportionately to input...............................................................................68
Scaling to predefined width or height ................................................................................68
5. Cropping Video ............................................................................................69
Cropping basics....................................................................................................................69
Cropping frame center ........................................................................................................70
Automatic detection of cropping area................................................................................71
Cropping of timer ................................................................................................................71
6. Padding Video...............................................................................................73
Padding basics ......................................................................................................................73
Padding videos from 4:3 to 16:9 .........................................................................................75
Padding videos from 16:9 to 4:3 .........................................................................................75
Padding from and to various aspect ratios........................................................................76
Pillarboxing - adding boxes horizontally ..........................................................................76
Letterboxing - adding boxes vertically..............................................................................76
7. Flipping and Rotating Video .......................................................................77
Horizontal flip ......................................................................................................................77
Vertical flip...........................................................................................................................77
Introduction to rotating.......................................................................................................78
Rotation by 90 degrees counterclockwise and flip vertically ...........................................79
Rotation by 90 degrees clockwise .......................................................................................79
Rotation by 90 degrees counterclockwise ..........................................................................80
Rotation by 90 degrees clockwise and flip vertically ........................................................80
8. Blur, Sharpen and Other Denoising ...........................................................81
Blur video effect ...................................................................................................................81
Sharpen video .......................................................................................................................83
Noise reduction with denoise3d ..........................................................................................84
Noise reduction with hqdn3d ..............................................................................................85
Noise reduction with nr option ...........................................................................................86
9. Overlay - Picture in Picture.........................................................................87
Introduction to overlay........................................................................................................87
Command structure for overlay.........................................................................................87
Logo in one of corners .........................................................................................................88
Logo in top-left corner ......................................................................................................89
Logo in top-right corner ....................................................................................................89
Logo in bottom-right corner ..............................................................................................89
Table of Contents
5
Logo in bottom-left corner ................................................................................................90
Logo shows in specified moment ........................................................................................90
Video with timer ..................................................................................................................91
Other overlay examples.......................................................................................................92
10. Adding Text on Video ................................................................................93
Introduction to adding text on video..................................................................................93
Text positioning....................................................................................................................95
Horizontal location setting ................................................................................................95
Vertical location setting ....................................................................................................95
Font size and color setting...................................................................................................96
Dynamic text.........................................................................................................................97
Horizontal text movement.................................................................................................97
Vertical text movement .....................................................................................................98
11. Conversion Between Formats....................................................................99
Introduction to media formats ...........................................................................................99
File formats .......................................................................................................................99
Media containers ...............................................................................................................99
Transcoding and conversion...............................................................................................99
Introduction to codecs .........................................................................................................100
Overwriting same named output files................................................................................101
Generic options for conversion...........................................................................................102
Private options for conversion............................................................................................105
MPEG-1 video encoder.....................................................................................................105
MPEG-2 video encoder.....................................................................................................106
MPEG-4 video encoder.....................................................................................................106
libvpx video encoder .........................................................................................................106
AC-3 audio encoder ..........................................................................................................107
Simplified encoding of VCD, SVCD, DVD, DV and DV50..............................................107
12. Time Operations .........................................................................................108
Duration of audio and video ..............................................................................................108
Setting with -t option.........................................................................................................108
Setting with number of frames..........................................................................................108
Setting delay from start.......................................................................................................108
Extracting specific part from media file............................................................................108
Delay between input streams ..............................................................................................109
One input file.....................................................................................................................109
Two or more input files.....................................................................................................109
Limit for processing time ....................................................................................................109
Shortest stream determines encoding time........................................................................109
Timestamp and time bases..................................................................................................110
Encoder timebase setting ....................................................................................................110
Audio and video speed modifications.................................................................................111
Video speed change...........................................................................................................111
Audio speed change ..........................................................................................................112
Synchronizing audio data with timestamps ......................................................................112
13. Mathematical Functions ............................................................................113
1 / 12 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !