ffmpeg -i input.mp4 -b:v 64k output.mp4
ffmpeg -i input.mp4 -r 10 output.mp4
-r rate set frame rate (Hz value, fraction or abbreviation)
_______ ______________ | | | | | input | demuxer | encoded data | decoder | file | ---------> | packets | -----+ |_______| |______________| | v _________ | | | decoded | | frames | |_________| ________ ______________ | | | | | | | output | <-------- | encoded data | <----+ | file | muxer | packets | encoder |________| |______________|
demuxer/muxer 封装与解封装 decoder/encoder 解码与编码
ffmpeg calls the libavformat library (containing demuxers) to read input files and get packets containing encoded data from them. When there are multiple input files, ffmpeg tries to keep them synchronized by tracking lowest timestamp on any active input stream.
Encoded packets are then passed to the decoder (unless streamcopy is selected for the stream, see further for a description). The decoder produces uncompressed frames (raw video/PCM audio/...) which can be processed further by filtering (see next section). After filtering, the frames are passed to the encoder, which encodes them and outputs encoded packets. Finally those are passed to the muxer, which writes the encoded packets to the output file.
_______ ______________ ________ | | | | | | | input | demuxer | encoded data | muxer | output | | file | ---------> | packets | -------> | file | |_______| |______________| |________|
ffmpeg -i in.mp4 -vf crop=w=960:h=1080 -y out.mp4
The width of the output video. It defaults to iw. This expression is evaluated only once during the filter configuration, or when the ‘w’ or ‘out_w’ command is sent.
The height of the output video. It defaults to ih. This expression is evaluated only once during the filter configuration, or when the ‘h’ or ‘out_h’ command is sent.
The horizontal position, in the input video, of the left edge of the output video. It defaults to
(in_w-out_w)/2. This expression is evaluated per-frame.
The vertical position, in the input video, of the top edge of the output video. It defaults to
(in_h-out_h)/2. This expression is evaluated per-frame.
ffmpeg -i in.mp4 -vf scale=w=640:h=720 -y out.mp4
Set the output video dimension expression. Default value is the input dimension.
If the width or w value is 0, the input width is used for the output. If the height or h value is 0, the input height is used for the output.
If one and only one of the values is -n with n >= 1, the scale filter will use a value that maintains the aspect ratio of the input image, calculated from the other specified dimension. After that it will, however, make sure that the calculated dimension is divisible by n and adjust the value if necessary.
If both values are -n with n >= 1, the behavior will be identical to both values being set to 0 as previously detailed.
See below for the list of accepted constants for use in the dimension expression.