Mainly for my personal memo and maybe helpful for others.
https://ffmpeg.org/ffmpeg.html
To refer to input files in options, you must use their indices (0-based). E.g. the first input file is 0
, the second is 1
, etc. Similarly, streams within a file are referred to by their indices. E.g. 2:3
refers to the fourth stream in the third input file. Also see the Stream specifiers chapter.
As a general rule, options are applied to the next specified file. Therefore, order is important, and you can have the same option on the command line multiple times. Each occurrence is then applied to the next input or output file. Exceptions from this rule are the global options (e.g. verbosity level), which should be specified first.
Do not mix input and output files – first specify all input files, then all output files. Also do not mix options which belong to different files. All options apply ONLY to the next input or output file and are reset between files.
# quality options
# To set the video bitrate of the output file to 2048 kbit/s, frame rate 15Hz
ffmpeg -i input.mov -b:v 2048k -r 15 output.mp4
# time options:
-ss hh:mm:ss # specify start time
-to hh:mm:ss # specify end time
-t hh:mm:ss # specify time period
# To force the frame rate of the input file (valid for raw formats only) to 1 fps and the frame rate of the output file to 24 fps:
ffmpeg -r 1 -i input.m2v -r 24 output.avi
# copy both the original audio and video content without recompressing
-c:v copy -c:a copy
# batch processing
for i in *.mov; do ffmpeg -i "$i" -r 15 -b:v 2048k "${i%.*}.mp4"; done
# 截取视频里的某一段
ffmpeg -ss 00:00:52 -i input.webm -to 00:02:52 -c copy output.webm
# 去掉声音 在-c copy后加一个参数-an
ffmpeg -i input.webm -c copy -an output.webm