如何在 Debian 12 上安装 FFmpeg

Linux命令 Edge插件网 1年前 (2023-07-08) 806次浏览 已收录 0个评论

视频和多媒体处理已成为现代应用程序和平台的重要组成部分。FFmpeg 是一款功能强大的开源软件,使用户能够轻松操作、转换和流式传输音频和视频文件。

如何在 Debian 12 上安装 FFmpeg

在 Debian 12 书虫上安装 FFmpeg

第 1 步。在我们安装任何软件之前,通过在终端中运行以下命令来确保您的系统是最新的非常重要:apt

<span class="pln">sudo apt update
sudo apt install apt</span><span class="pun">-</span><span class="pln">transport</span><span class="pun">-</span><span class="pln">https lsb</span><span class="pun">-</span><span class="pln">release ca</span><span class="pun">-</span><span class="pln">certificates build</span><span class="pun">-</span><span class="pln">essential git wget</span>

此命令将刷新存储库,允许您安装最新版本的软件包。

第 2 步。在 Debian 12安装 FFmpeg

现在您的系统已准备就绪,让我们继续安装过程。有两种主要方法:通过包管理器安装 FFmpeg 或从源代码编译它。

FFmpeg 在默认的 Debian 仓库中不可用。要访问它,请通过编辑源列表文件来启用非自由存储库:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">apt</span><span class="pun">/</span><span class="pln">sources</span><span class="pun">.</span><span class="pln">list</span>

将以下行添加到文件中:

<span class="pln">deb http</span><span class="pun">:</span><span class="com">//deb.debian.org/debian bullseye main contrib non-free</span>

更新软件包列表以包含新添加的存储库,并通过运行以下命令安装 FFmpeg

<span class="pln">sudo apt update
sudo apt install ffmpeg</span>
  • 方法 2:从源代码编译 FFmpeg。

要从源代码编译 FFmpeg,您需要安装其他构建工具。执行以下命令:

<span class="pln">sudo apt install build</span><span class="pun">-</span><span class="pln">essential nasm yasm libx264</span><span class="pun">-</span><span class="pln">dev libx265</span><span class="pun">-</span><span class="pln">dev libvpx</span><span class="pun">-</span><span class="pln">dev libfdk</span><span class="pun">-</span><span class="pln">aac</span><span class="pun">-</span><span class="pln">dev libmp3lame</span><span class="pun">-</span><span class="pln">dev libopus</span><span class="pun">-</span><span class="pln">dev</span>

N接下来,为 FFmpeg 创建一个目录并导航到它。然后,从官方网站或通过 Git 下载 FFmpeg 源代码:

<span class="pln">mkdir </span><span class="pun">~/</span><span class="pln">ffmpeg
cd </span><span class="pun">~/</span><span class="pln">ffmpeg
wget https</span><span class="pun">:</span><span class="com">//ffmpeg.org/releases/ffmpeg-x.x.x.tar.gz # Replace x.x.x with the desired version</span><span class="pln">
tar xzf ffmpeg</span><span class="pun">-</span><span class="pln">x</span><span class="pun">.</span><span class="pln">x</span><span class="pun">.</span><span class="pln">x</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz</span>

之后,解压缩 FFmpeg 目录并配置安装选项:

<span class="pln">cd ffmpeg</span><span class="pun">-</span><span class="pln">x</span><span class="pun">.</span><span class="pln">x</span><span class="pun">.</span><span class="pln">x
</span><span class="pun">./</span><span class="pln">configure </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">gpl </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">libx264 </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">libx265 </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">libvpx </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">libfdk</span><span class="pun">-</span><span class="pln">aac </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">libmp3lame </span><span class="pun">--</span><span class="pln">enable</span><span class="pun">-</span><span class="pln">libopus</span>

配置完成后,开始编译过程:

<span class="pln">make </span><span class="pun">-</span><span class="pln">j$</span><span class="pun">(</span><span class="pln">nproc</span><span class="pun">)</span><span class="pln">
sudo make install</span>

安装 FFmpeg 后,必须验证安装是否成功。执行以下检查:

<span class="pln">ffmpeg </span><span class="pun">-</span><span class="pln">version</span>

第 3 步。FFmpeg的基本用法。

现在 FFmpeg 已安装,让我们探索一些基本的使用场景,以帮助您开始操作多媒体文件:

  • 转换视频格式:

FFmpeg 允许您毫不费力地将视频转换为不同的格式。使用以下命令转换视频文件:

<span class="pln">ffmpeg </span><span class="pun">-</span><span class="pln">i input</span><span class="pun">.</span><span class="pln">mp4 output</span><span class="pun">.</span><span class="pln">mkv</span>
  • 从视频中提取音频:

如果要从视频文件中提取音轨,请使用以下命令:

<span class="pln">ffmpeg </span><span class="pun">-</span><span class="pln">i input</span><span class="pun">.</span><span class="pln">mp4 </span><span class="pun">-</span><span class="pln">vn </span><span class="pun">-</span><span class="pln">acodec copy output</span><span class="pun">.</span><span class="pln">mp3</span>
  • 修剪和拆分视频:

FFmpeg 使您能够轻松修剪和拆分视频文件。使用以下命令作为示例:

<span class="pln">ffmpeg </span><span class="pun">-</span><span class="pln">i input</span><span class="pun">.</span><span class="pln">mp4 </span><span class="pun">-</span><span class="pln">ss </span><span class="lit">00</span><span class="pun">:</span><span class="lit">00</span><span class="pun">:</span><span class="lit">10</span> <span class="pun">-</span><span class="pln">t </span><span class="lit">00</span><span class="pun">:</span><span class="lit">00</span><span class="pun">:</span><span class="lit">20</span> <span class="pun">-</span><span class="pln">c</span><span class="pun">:</span><span class="pln">v copy </span><span class="pun">-</span><span class="pln">c</span><span class="pun">:</span><span class="pln">a copy output</span><span class="pun">.</span><span class="pln">mp4
ffmpeg </span><span class="pun">-</span><span class="pln">i input</span><span class="pun">.</span><span class="pln">mp4 </span><span class="pun">-</span><span class="pln">f segment </span><span class="pun">-</span><span class="pln">segment_time </span><span class="lit">10</span> <span class="pun">-</span><span class="pln">c copy output</span><span class="pun">%</span><span class="pln">d</span><span class="pun">.</span><span class="pln">mp4</span>
  • 为视频添加水印:

您可以使用 FFmpeg 在视频上叠加文本或图像水印。以下是一些示例:

<span class="pln">ffmpeg </span><span class="pun">-</span><span class="pln">i input</span><span class="pun">.</span><span class="pln">mp4 </span><span class="pun">-</span><span class="pln">vf </span><span class="str">"drawtext=text='Your Watermark':fontsize=20:fontcolor=white:x=10:y=10"</span> <span class="pun">-</span><span class="pln">c</span><span class="pun">:</span><span class="pln">v libx264 </span><span class="pun">-</span><span class="pln">crf </span><span class="lit">18</span><span class="pln"> output</span><span class="pun">.</span><span class="pln">mp4
ffmpeg </span><span class="pun">-</span><span class="pln">i input</span><span class="pun">.</span><span class="pln">mp4 </span><span class="pun">-</span><span class="pln">i watermark</span><span class="pun">.</span><span class="pln">png </span><span class="pun">-</span><span class="pln">filter_complex </span><span class="str">"overlay=10:10"</span> <span class="pun">-</span><span class="pln">c</span><span class="pun">:</span><span class="pln">v libx264 </span><span class="pun">-</span><span class="pln">crf </span><span class="lit">18</span><span class="pln"> output</span><span class="pun">.</span><span class="pln">mp4
</span>

第 4 步。对 FFmpeg 进行故障排除。

安装和使用 FFmpeg 时,您可能会遇到一些常见问题。以下是一些故障排除提示,可帮助您解决这些问题:

  1. 常见安装问题:
    • 未找到依赖项:仔细检查是否已安装本指南前面提到的所有必要依赖项。
    • 编译错误:验证是否正确执行了编译步骤,以及是否具有所需的生成工具。
  2. 常见使用问题:
    • 不支持的格式或编解码器:确保 FFmpeg 支持您正在使用的格式和编解码器。查看官方 FFmpeg 文档,了解支持的格式和编解码器的完整列表。
    • 意外的输出质量或文件大小:尝试不同的命令选项和设置,以实现所需的输出质量或文件大小。

感谢您使用本教程在 Debian 11 书虫上安装最新版本的 FFmpeg。有关其他帮助或有用信息,我们建议您查看 FFmpeg 官方网站

 

VPS Manage Service

Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Debian 12 上安装 FFmpeg
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址