logo资料库

FFMPEG官方文档.pdf

第1页 / 共216页
第2页 / 共216页
第3页 / 共216页
第4页 / 共216页
第5页 / 共216页
第6页 / 共216页
第7页 / 共216页
第8页 / 共216页
资料共216页,剩余部分请下载后查看
Introduction
Welcome
First steps
Dedicated website
Conventions
Your feedback is important
1. FFmpeg Fundamentals
FFmpeg introduction
Developers of FFmpeg
Participation in FFmpeg development
FFmpeg download
Command line syntax
Windows Command Prompt and its alternatives
Path setting
Renaming to shortened form
Displaying output preview
Preview with FFplay media player
Preview with SDL output device
SI prefixes available in FFmpeg
Transcoding with ffmpeg
Filters, filterchains and filtergraphs
Selection of media streams
Lavfi virtual device
Color names
2. Displaying Help and Features
Text help in FFmpeg tools
Available bitstream filters
Available codecs
Available decoders
Available encoders
Available filters
Available formats
Available layouts of audio channels
FFmpeg license
Available pixel formats
Available protocols
Available audio sample formats
FFmpeg version
Using MORE command for output formatting
Redirecting output to file
3. Bit Rate, Frame Rate and File Size
Frame (frequency) rate introduction
Frame rate setting
Using -r option
Using fps filter
Predefined values for frame rate
Bit (data) rate introduction
Setting bit rate
Constant bit rate (CBR) setting
Setting maximum size of output file
File size calculation
4. Resizing and Scaling Video
Resizing video
Predefined video frame sizes
Considerations when resizing - Nyquist sampling theorem
Special enlarging filter
Advanced scaling
Scaling video proportionately to input
Scaling to predefined width or height
5. Cropping Video
Cropping basics
Cropping frame center
Automatic detection of cropping area
Cropping of timer
6. Padding Video
Padding basics
Padding videos from 4:3 to 16:9
Padding videos from 16:9 to 4:3
Padding from and to various aspect ratios
Pillarboxing - adding boxes horizontally
Letterboxing - adding boxes vertically
7. Flipping and Rotating Video
Horizontal flip
Vertical flip
Introduction to rotating
Rotation by 90 degrees counterclockwise and flip vertically
Rotation by 90 degrees clockwise
Rotation by 90 degrees counterclockwise
Rotation by 90 degrees clockwise and flip vertically
8. Blur, Sharpen and Other Denoising
Blur video effect
Sharpen video
Noise reduction with denoise3d
Noise reduction with hqdn3d
Noise reduction with nr option
9. Overlay - Picture in Picture
Introduction to overlay
Command structure for overlay
Logo in one of corners
Logo in top-left corner
Logo in top-right corner
Logo in bottom-right corner
Logo in bottom-left corner
Logo shows in specified moment
Video with timer
Other overlay examples
10. Adding Text on Video
Introduction to adding text on video
Text positioning
Horizontal location setting
Vertical location setting
Font size and color setting
Dynamic text
Horizontal text movement
Vertical text movement
11. Conversion Between Formats
Introduction to media formats
File formats
Media containers
Transcoding and conversion
Introduction to codecs
Overwriting same named output files
Generic options for conversion
Private options for conversion
MPEG-1 video encoder
MPEG-2 video encoder
MPEG-4 video encoder
libvpx video encoder
AC-3 audio encoder
Simplified encoding of VCD, SVCD, DVD, DV and DV50
12. Time Operations
Duration of audio and video
Setting with -t option
Setting with number of frames
Setting delay from start
Extracting specific part from media file
Delay between input streams
One input file
Two or more input files
Limit for processing time
Shortest stream determines encoding time
Timestamp and time bases
Encoder timebase setting
Audio and video speed modifications
Video speed change
Audio speed change
Synchronizing audio data with timestamps
13. Mathematical Functions
Expressions that can use mathematical functions
Built-in arithmetic operators
Built-in constants
Table of built-in mathematical functions
Examples of using functions
14. Metadata and Subtitles
Introduction to metadata
Creating metadata
Saving and loading metadata to/from the file
Deletion of metadata
Introduction to subtitles
Subtitles encoded directly to video
15. Image Processing
Supported image formats
Creating images
Screenshots from videos
Animated GIFs from videos
Images from FFmpeg video sources
Video conversion to images
Resizing, cropping and padding images
Flipping, rotating and overlaying images
Conversion between image types
Creating video from images
Video from one image
Video from many images
16. Digital Audio
Introduction to digital audio
Audio quantization and sampling
Audio file formats
Sound synthesis
Stereo and more complex sounds
Binaural tones for stress reduction
Sound volume settings
Multiple sounds mixed to one output
Downmixing stereo to mono, surround to stereo
Simple audio analyzer
Adjusting audio for listening with headphones
Audio modifications with -map_channel option
Switching audio channels in stereo input
Splitting stereo sound to 2 separate streams
Muting one channel from stereo input
Merging 2 audio streams to 1 multichannel stream
Audio stream forwarding with buffer order control
17. Presets for Codecs
Introduction to preset files
Examples of preset files
Preset file libvpx-1080p.ffpreset
Preset file libvpx-1080p50_60.ffpreset
Preset file libvpx-360p.ffpreset
Preset file libvpx-720p.ffpreset
Preset file libvpx-720p50_60.ffpreset
18. Interlaced Video
NTSC, PAL and SECAM TV standards
Interlaced frame type setting
Field order change of interlaced video
Deinterlacing
yadif filter
Option -deinterlace
Deinterlacing filters from MPlayer project
Pullup filter
Interlaced video and digital television
19. FFmpeg Components and Projects
FFplay introduction
Key and mouse controls during playback
FFplay show modes
FFprobe introduction
FFserver introduction
FFmpeg software libraries
libavcodec
libavdevice
libavfilter
libavformat
libavutil
libpostproc
libswresample
libswscale
Projects using FFmpeg components
HTML5 support in Google Chrome
Videoprocessing on YouTube and Facebook
Multimedia frameworks utilizing FFmpeg
Video editors
Audio editors
Media players using FFmpeg
20. Microphone and Webcam
Introduction to input devices
List of available cameras and microphones
Available options for webcam
Displaying and recording webcam input
Using two webcams
Recording sound and sending it to loudspeakers
21. Batch Files
Advantages of batch files
Batch file commands
Typical usage of batch files
Tone generator
Creating Jingle Bells
Simplified conversion
22. Color Corrections
Video modifications with lookup table
Conversion to monochrome (black-and-white) image
Introduction to color spaces
YUV color space and its derivatives
Luma (luminance) and chroma (chrominance)
Pixel formats
RGB pixel format modifications
Color balance
Modifications of YUV pixel format
Brightness correction
Hue and saturation setting
Comparison in 2 windows
2 windows compared horizontally
2 windows compared vertically
Space between windows
Modified version first
2 modified versions without input
Comparison in 3 windows
3 windows compared horizontally
3 windows compared vertically
Input in the middle window
Brightness correction in 2 and 3 windows
Comparison in 4 windows
23. Advanced Techniques
Joining audio and video files
Concatenation with shell command
Concatenation with concat protocol
Concatenation with concat filter
Other types of joining
Removing logo
delogo filter
Fixing of shaking video parts
Adding color box to video
Number of frames detection
Detection of ads, section transitions or corrupted encoding
Detection with blackframe filter
Selecting only specified frames to output
Scaling input by changing aspect ratios
Screen grabbing
Detailed video frame information
Audio frequency spectrum
Audio waves visualization
Voice synthesis
Saving output to multiple formats at once
Additional media input to filtergraph
24. Video on Web
HTML5 support on main browsers
Adding audio with HTML5
Adding video with HTML5
Adding video for Flash Player
Video sharing websites
Videoprocessing on webserver
Monetizing video uploads
25. Debugging and Tests
debug, debug_ts and fdebug options
Flags for error detection
Logging level setting
Timebase configuration test
Testing encoding features
Test patterns
RGB test pattern
Color pattern with scrolling gradient and timestamp
SMPTE bars pattern
Simple packet dumping or with payload (hexadecimally)
CPU time used and memory consumption
Glossary
About the author
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 1. FFmpeg Fundamentals 2. Displaying Help and Features 3. Bit Rate, Frame Rate and File Size 4. Resizing and Scaling Video 5. Cropping Video 6. Padding Video 7. Flipping and Rotating Video 8. Blur, Sharpen and Other Denoising 9. Overlay - Picture in Picture 10. Adding Text on Video 11. Conversion Between Formats 12. Time Operations 13. Mathematical Functions 14. Metadata and Subtitles 15. Image Processing 16. Digital Audio 17. Presets for Codecs 18. Interlaced Video 19. FFmpeg Components and Projects 20. Microphone and Webcam 21. Batch Files 22. Color Corrections 23. Advanced Techniques 24. Video on Web 25. Debugging and Tests Glossary About the author 12 15 29 60 64 69 73 77 81 87 93 99 108 113 117 122 128 138 142 147 154 159 164 179 193 200 207 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 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 6
Table of Contents 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 7
Table of Contents Expressions that can use mathematical functions.............................................................113 Built-in arithmetic operators ..............................................................................................114 Built-in constants .................................................................................................................114 Table of built-in mathematical functions...........................................................................114 Examples of using functions................................................................................................116 14. Metadata and Subtitles ..............................................................................117 Introduction to metadata ....................................................................................................117 Creating metadata ...............................................................................................................117 Saving and loading metadata to/from the file ...................................................................119 Deletion of metadata............................................................................................................119 Introduction to subtitles ......................................................................................................119 Subtitles encoded directly to video .....................................................................................121 15. Image Processing........................................................................................122 Supported image formats....................................................................................................122 Creating images....................................................................................................................123 Screenshots from videos....................................................................................................123 Animated GIFs from videos ..............................................................................................123 Images from FFmpeg video sources..................................................................................123 Video conversion to images ..............................................................................................124 Resizing, cropping and padding images.............................................................................125 Flipping, rotating and overlaying images..........................................................................126 Conversion between image types........................................................................................127 Creating video from images................................................................................................127 Video from one image.......................................................................................................127 Video from many images ..................................................................................................127 16. Digital Audio...............................................................................................128 Introduction to digital audio...............................................................................................128 Audio quantization and sampling......................................................................................128 Audio file formats ................................................................................................................130 Sound synthesis ....................................................................................................................130 Stereo and more complex sounds .......................................................................................132 Binaural tones for stress reduction ....................................................................................132 Sound volume settings .........................................................................................................133 Multiple sounds mixed to one output.................................................................................133 Downmixing stereo to mono, surround to stereo ..............................................................134 Simple audio analyzer..........................................................................................................135 Adjusting audio for listening with headphones.................................................................136 Audio modifications with -map_channel option ...............................................................136 Switching audio channels in stereo input..........................................................................137 Splitting stereo sound to 2 separate streams......................................................................137 Muting one channel from stereo input ..............................................................................137 Merging 2 audio streams to 1 multichannel stream .........................................................137 Audio stream forwarding with buffer order control........................................................137 17. Presets for Codecs ......................................................................................138 Introduction to preset files ..................................................................................................138 Examples of preset files .......................................................................................................139 8
分享到:
收藏