Common Commands for ffmpeg

1.1 Automatic video encoding conversion

1
ffmpeg -i input.mp4 -crf 10 output.mp4
  • -i input.mp4: This flag (-i) specifies the input file (input.mp4). -i is followed by the name of the input video file that you want to process. In this case, input.mp4 is the input video file.
  • -crf 10: This flag stands for Constant Rate Factor (CRF). -crf is followed by a numerical value. In this case, 10 is used as the CRF value. CRF is a parameter used for video encoding in ffmpeg that controls the quality and size of the output video. Lower CRF values correspond to higher quality and larger file sizes, while higher CRF values mean lower quality and smaller file sizes. A CRF value of 10 is generally considered high quality with a moderate file size.
  • output.mp4: This is the output file name. After processing the input file (input.mp4) using the specified CRF value (10), ffmpeg will create an output file named output.mp4.

2.1 Extracting the audio from a video file

1
ffmpeg -i input.mp4 -q:a 0 -map a output.mp3
  • -i input.mp4 This flag (-i) specifies the input file (input.mp4). -i is followed by the name of the input file that you want to process. In this case, input.mp4 is the input video file.
  • -q:a 0: This flag sets the audio quality for the output file. -q:a stands for “audio quality.” The value 0 indicates the highest possible quality for the audio. Using 0 for audio quality often means there’s little to no perceptible loss in audio quality due to compression.
  • -map a: This flag tells ffmpeg to select a specific stream from the input file. -map is used to choose a particular stream within the input file. In this case, a refers to the audio stream of the input file.
  • output.mp3: This is the output file name. After processing the input file (specified as meeting_17.mp4), ffmpeg will create an output file named output.mp3. The .mp3 extension indicates that the output file will be an MP3 audio file.

2.2 Extracting a specific segment of the audio

1
ffmpeg -i output.mp3 -ss 1:18:09 -to 2:18:09 1hours.mp3
  • -i output.mp3: This flag (-i) specifies the input file (output.mp3). -i is followed by the name of the input audio file that you want to process. In this case, output.mp3 is the input audio file.
  • -ss 1:18:09: This flag stands for “start time.” -ss is used to indicate the starting point from where the audio will be processed. 1:18:09 denotes the timestamp in the format of hours:minutes:seconds (1 hour, 18 minutes, and 9 seconds). It means the processing will begin from this specific time point in the input audio file (output.mp3).
  • -to 2:18:09: This flag stands for “end time.” -to is used to indicate the endpoint for the processing. 2:18:09 denotes the timestamp in the format of hours:minutes:seconds (2 hours, 18 minutes, and 9 seconds). It means the processing will end at this specific time point in the input audio file (output.mp3).
  • 1hours.mp3: This is the output file name. After processing the input file (specified as output.mp3) from the starting time (1:18:09) to the end time (2:18:09), ffmpeg will create an output file named 1hours.mp3.

Common Commands for ffmpeg
https://www.hardyhu.cn/2023/10/23/Common-Commands-for-ffmpeg/
Author
John Doe
Posted on
October 23, 2023
Licensed under