1. Installing FFmpeg
Run this command on macOS:
| |
2. Using FFmpeg
| |
The five parts of the arguments are, in order:
- Global arguments, such as
-y,-loglevel,-preset, which control the overall behavior - Input file arguments, such as
-i,-ss,-t,-stream_loop, which control how the input file is read - Input file, the path to the audio/video input file to process
- Output file arguments, such as
-c:v,-c:a,-vf,-af, which control the encoding and filtering of the output - Output file, the path to the processed output audio/video file
Common output arguments:
-vcodec specifies the video codec; copy means copy only, with no encoding or decoding
-acodec specifies the audio codec; copy means copy only, with no encoding or decoding
When using the copy argument, because no encoding or decoding is done, it is much faster. If the input and output files have different codecs, it will error out. In addition, FFmpeg guesses the container format from the file extension.
3. Some Usage Scenarios
- Inspecting video information
| |
It contains two streams: one h264-encoded video stream and one aac-encoded audio stream.
- Extracting the audio
| |
-vn means do not process the video stream, and -acodec copy means copy the audio stream directly without encoding or decoding.
- Converting the audio format
| |
- Extracting the video
| |
- Converting the video format
| |
- Merging audio and video
| |
