banner
miaoer

miaoer

喵二の小博客 https://www.miaoer.net xLog 分站
tg_channel
telegram
bilibili

Common FFmpeg Commands

Preface#

Recently discovered and used FFmpeg and found it to be very powerful, capable of various audio and video operations. Some software also references FFmpeg mainly because it is a free and open-source tool that does not require licensing. Here, I will briefly make some notes on several common FFmpeg commands to help novice readers easily convert the encoding of their videos! Most of the content here is referenced from existing online sources with marked citations.

Let's have some fun together ฅ՞•ﻌ•՞ฅ

Installing FFmpeg#

image

Windows#

Since FFmpeg only provides source code that needs to be compiled, there are experts who have compiled FFmpeg that can be directly used from the repository.

https://github.com/BtbN/FFmpeg-Builds/releases

Ubuntu#


Overview#

Container Formats#

The common video file formats are actually containers that include video tracks, audio tracks, metadata, subtitles, titles, cover art, etc. Common video container formats include:

  • MP4 (MPEG 4)
  • MKV (Matroska)
  • WebM
  • AVI (ASF)
  • MOV (QuickTime)

TOP: WebM is a recently popular container used for AV1, VP9, and VP8, and requires specific hardware acceleration for encoding and decoding.

For example, AIN's new products in 2022 all support AV1 encoding and decoding hardware acceleration.

Encoding#

Common types of encoding include licensed encoding, royalty-free encoding, and audio encoding formats.

Licensed Encoding

  • H.262
  • H.264
  • H.265

Royalty-Free Encoding

  • VP8
  • VP9
  • AV1

Audio Encoding Formats

  • MP3
  • AAC

Video Encoders

  • libx264: The most popular open-source H.264 encoder
  • NVENC: H.264 encoder based on NVIDIA GPU
  • libx265: Open-source HEVC encoder
  • libvpx: Google's VP8 and VP9 encoders
  • libaom: AV1 encoder

Audio Encoders

  • libfdk-aac
  • aac

View the installed encoders in FFmpeg

ffmpeg -encoders

Usage#

[1] Global parameters

[2] Input file parameters

[3] Input file

[4] Output file parameters

[5] Output file

Parameters#

  • -c: Specify the encoder
  • -c copy: Directly copy without re-encoding, faster
  • -c:v: Specify the video encoder
  • -c:a: Specify the audio encoder
  • -i: Specify the input file
  • -an: Remove the audio stream
  • -vn: Remove the video stream
  • -preset: Video encoding quality ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow
  • -y: Overwrite files without confirmation

More: https://zh.m.wikipedia.org/zh-hans/FFmpeg


File Information#

Format Conversion#

-i Input file

-c copy Direct copy without transcoding is faster

Transcoding#

-i Input file

-c Convert encoder

Trimming#

-ss Start time

-t End time

-i Input file

Bitrate#

This section is too professional and requires a deeper understanding! Here, only the simplest encoding methods are demonstrated, excluding compression configurations.

ABR (VBR) Two-Pass Encoding#

CBR Constant Bitrate#

-i Input file

-b Audio bitrate

-b Video bitrate

-minrate Allowed minimum bitrate

-maxrate Allowed maximum bitrate

-bufsize Bitrate control buffer

Size#

-i Input file

-fs Control file size

Resolution#

-i Input file
[Maintain aspect ratio -1]

FPS#

-i Input file

-r Frame rate value

Extract Audio#

-i Input file

-f Output format

-vn Exclude video

-aq 0 Compression quality

-acodec Set audio codec

Separate Audio and Video#

Separate Video

Separate acc Format

Directly Extract Audio

Merge Audio and Video#

-i Input file

-c Audio encoding method

-c Video encoding method

Compress Audio#

-i Input file

-b Bitrate

-ar Sampling rate

Screenshot#

Screenshot at a specified time

Extract frames from the beginning

-i Input file

-r Frames per second

-q Image quality

-f Output format

Cover#

Video Cover

Audio Cover

Citations:
FFmpeg Video Processing Beginner's Tutorial

Using ffmpeg to Separate Video and Audio Streams

Common FFmpeg Parameters Explanation and Examples

Bitrate Control (1): Understanding Bitrate Control Modes (x264,x264,vpx)

This article is synchronized and updated to xLog by Mix Space The original link is https://www.miaoer.net/posts/blog/ffmpeg

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.