FFmpeg 安装指南 – wiki大全


FFmpeg Installation Guide

FFmpeg is a powerful, open-source command-line tool widely used for processing audio and video files. It can handle a vast array of tasks, including format conversion, basic editing (cutting, concatenating), scaling, and streaming. This guide will walk you through the installation process on Windows, macOS, and Linux.

1. Installation on Windows

For Windows users, the recommended method involves downloading a pre-built executable and adding it to your system’s PATH.

Steps:

  1. Download FFmpeg:

    • Visit the official FFmpeg download page or a reliable source like gyan.dev (recommended for Windows builds).
    • Navigate to the “Windows builds” section and choose a static build (e.g., ffmpeg-git-full.7z for a comprehensive feature set). Ensure you select the 64-bit version for modern systems.
  2. Extract the Files:

    • The downloaded FFmpeg file will typically be compressed in a .7z format. You will need a tool like 7-Zip to extract its contents.
    • Extract the entire folder to a permanent and easily accessible location on your system, such as C:\ffmpeg. This will create a directory structure like C:\ffmpeg\bin, C:\ffmpeg\doc, etc.
  3. Add FFmpeg to System PATH:

    • Adding FFmpeg to your system’s PATH environment variable allows you to execute FFmpeg commands from any directory in Command Prompt or PowerShell without specifying the full path to the executable.
    • Search for “Edit the system environment variables” in the Windows search bar and open it.
    • In the “System Properties” window, click on the “Environment Variables…” button.
    • Under “System variables” (or “User variables” if you want it only for your account), find and select the “Path” variable, then click “Edit”.
    • Click “New” and add the path to the bin folder within your FFmpeg installation directory (e.g., C:\ffmpeg\bin).
    • Click “OK” on all open windows to save the changes.
  4. Verify Installation:

    • Open a new Command Prompt or PowerShell window (restart any existing ones to ensure PATH changes are loaded).
    • Type ffmpeg -version and press Enter.
    • If the installation was successful, you should see FFmpeg’s version information and configuration details. If you encounter an error like “ffmpeg is not recognized,” double-check your PATH settings and confirm that ffmpeg.exe is present in the C:\ffmpeg\bin directory.

2. Installation on macOS

The easiest and most recommended way to install FFmpeg on macOS is by using Homebrew, a popular package manager for macOS.

Steps:

  1. Install Homebrew (if not already installed):

    • Open your Terminal application (located in Applications/Utilities).
    • Paste the following command and press Enter:
      bash
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    • Follow the on-screen instructions to complete the Homebrew installation.
  2. Install FFmpeg using Homebrew:

    • Once Homebrew is installed, it’s good practice to update it to ensure you have the latest formulae:
      bash
      brew update
    • Then, install FFmpeg:
      bash
      brew install ffmpeg
    • Homebrew will automatically download and install FFmpeg along with its necessary dependencies.
  3. Verify Installation:

    • In the Terminal, type ffmpeg -version and press Enter.
    • You should see the FFmpeg version information, confirming a successful installation.

3. Installation on Linux

FFmpeg is typically available in the official repositories of most Linux distributions, making its installation straightforward using the distribution’s native package manager.

Steps:

  1. Update Package Repository:

    • Before installing new software, it’s always recommended to update your system’s package list.
    • Open your Terminal.
    • For Debian/Ubuntu-based systems:
      bash
      sudo apt update
    • For Fedora:
      bash
      sudo dnf update
    • For Arch Linux:
      bash
      sudo pacman -Syu
  2. Install FFmpeg:

    • Use the appropriate command for your specific Linux distribution:
    • Debian/Ubuntu:
      bash
      sudo apt install ffmpeg
    • Fedora:
      bash
      sudo dnf install ffmpeg
    • Arch Linux:
      bash
      sudo pacman -S ffmpeg
    • Using Snap (an alternative for many distributions, if Snap is installed):
      bash
      sudo snap install ffmpeg

      (You may need to install Snap itself if it’s not pre-installed on your system.)
  3. Confirm Installation:

    • When prompted by your package manager, confirm the installation by pressing Y and Enter.
  4. Verify Installation:

    • After the installation completes, type ffmpeg -version in the Terminal and press Enter.
    • This command should display the installed FFmpeg version and its build configuration, indicating a successful installation.

滚动至顶部