ffmpeg 音频常用命令

2023-11-18

ffmpeg的使用方式: 
ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Stream specifier

Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers are used to precisely specify which stream(s) a given option belongs to.

A stream specifier is a string generally appended to the option name and separated from it by a colon. E.g. -codec:a:1 ac3 contains the a:1 stream specifier, which matches the second audio stream. Therefore, it would select the ac3 codec for the second audio stream.

A stream specifier can match several streams, so that the option is applied to all of them. E.g. the stream specifier in -b:a 128k matches all audio streams.

An empty stream specifier matches all streams. For example, -codec copy or -codec: copy would copy all the streams without reencoding.

Possible forms of stream specifiers are:

stream_index

Matches the stream with this index. E.g. -threads:1 4 would set the thread count for the second stream to 4.

stream_type[:stream_index]

stream_type is one of following: ’v’ or ’V’ for video, ’a’ for audio, ’s’ for subtitle, ’d’ for data, and ’t’ for attachments. ’v’ matches all video streams, ’V’ only matches video streams which are not attached pictures, video thumbnails or cover arts. If stream_index is given, then it matches stream number stream_indexof this type. Otherwise, it matches all streams of this type.

p:program_id[:stream_index] or p:program_id[:stream_type[:stream_index]] or

p:program_id:m:key[:value] In first version, if stream_index is given, then it matches the stream with number stream_index in the program with the id program_id. Otherwise, it matches all streams in the program. In the second version, stream_type is one of following: ’v’ for video, ’a’ for audio, ’s’ for subtitle, ’d’ for data. If stream_index is also given, then it matches stream number stream_index of this type in the program with the id program_id. Otherwise, if only stream_type is given, it matches all streams of this type in the program with the id program_id. In the third version matches streams in the program with the id program_id with the metadata tag key having the specified value. If value is not given, matches streams that contain the given tag with any value.

#stream_id or i:stream_id

Match the stream by stream id (e.g. PID in MPEG-TS container).

m:key[:value]

Matches streams with the metadata tag key having the specified value. If value is not given, matches streams that contain the given tag with any value.

u

Matches streams with usable configuration, the codec must be defined and the essential information such as video dimension or audio sample rate must be present.

Note that in ffmpeg, matching by metadata will only work properly for input files.

General options

-version

Show version.

-formats

Show available formats (including devices).

-demuxers

Show available demuxers.

-muxers

Show available muxers.

-devices

Show available devices.

-codecs

Show all codecs known to libavcodec.

Note that the term ’codec’ is used throughout this documentation as a shortcut for what is more correctly called a media bitstream format.

-decoders

Show available decoders.

-encoders

Show all available encoders.

-bsfs

Show available bitstream filters.

-filters

Show available libavfilter filters.

-sample_fmts

Show available sample formats.

-layouts

Show channel names and standard channel layouts.

Main options

-f fmt (input/output)

Force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases.

-i url (input)

input file url

-y (global)

Overwrite output files without asking.

-n (global)

Do not overwrite output files, and exit immediately if a specified output file already exists.

-c[:stream_specifiercodec (input/output,per-stream)-codec[:stream_specifiercodec (input/output,per-stream)

Select an encoder (when used before an output file) or a decoder (when used before an input file) for one or more streams. codec is the name of a decoder/encoder or a special value copy (output only) to indicate that the stream is not to be re-encoded.

-dframes number (output)

Set the number of data frames to output. This is an obsolete alias for -frames:d, which you should use instead.

-frames[:stream_specifierframecount (output,per-stream)

Stop writing to the stream after framecount frames.

-q[:stream_specifierq (output,per-stream)-qscale[:stream_specifierq (output,per-stream)

Use fixed quality scale (VBR). The meaning of q/qscale is codec-dependent. If qscale is used without a stream_specifier then it applies only to the video stream, this is to maintain compatibility with previous behavior and as specifying the same codec specific value to 2 different codecs that is audio and video generally is not what is intended when no stream_specifier is used.

-filter[:stream_specifierfiltergraph (output,per-stream)

Create the filtergraph specified by filtergraph and use it to filter the stream.

filtergraph is a description of the filtergraph to apply to the stream, and must have a single input and a single output of the same type of the stream. In the filtergraph, the input is associated to the label in, and the output to the label out. See the ffmpeg-filters manual for more information about the filtergraph syntax.

See the -filter_complex option if you want to create filtergraphs with multiple inputs and/or outputs.

Audio Options

-aframes number (output)

Set the number of audio frames to output. This is an obsolete alias for -frames:a, which you should use instead.

-ar[:stream_specifierfreq (input/output,per-stream)

Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options.

-aq q (output)

Set the audio quality (codec-specific, VBR). This is an alias for -q:a.

-ac[:stream_specifierchannels (input/output,per-stream)

Set the number of audio channels. For output streams it is set by default to the number of input audio channels. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options.

-an (output)

Disable audio recording. For full manual control see the -map option.

-acodec codec (input/output)

Set the audio codec. This is an alias for -codec:a.

-sample_fmt[:stream_specifiersample_fmt (output,per-stream)

Set the audio sample format. Use -sample_fmts to get a list of supported sample formats.

-af filtergraph (output)

Create the filtergraph specified by filtergraph and use it to filter the stream.

This is an alias for -filter:a,

 

常用命令:

提取视频中的音频:

ffmpeg -i input.mp4 -acodec copy -vn output.aac 

如果stream红包含多个音频(多个PID),使用map指定要提取的音频。

ffmpeg -i xxx.ts  -map 0:1 -acodec copy -vn output.ac3

解码音频:

ffmpeg -i input.aac -ar 48000 -ac 2 output.wav

编码:

ffmpeg -i input.wav output.ac3

 

转载于:https://www.cnblogs.com/fellow1988/p/9127420.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ffmpeg 音频常用命令 的相关文章

  • 在 MacOS 终端上运行 ffmpeg [关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我对 MacOS 相当陌生 我发现使用终端来获取信息并不容易ffmpeg和我在 Window 上一样正常运行 我有 ffmpeg 二进制文件ffmpe
  • 同时从多个流中捕获、最佳方法以及如何减少 CPU 使用率

    我目前正在编写一个应用程序 该应用程序将捕获大量 RTSP 流 在我的例子中为 12 个 并将其显示在 QT 小部件上 当我超过大约 6 7 个流时 问题就会出现 CPU 使用率激增并且出现明显的卡顿 我认为它不是 QT 绘制函数的原因是因
  • 从 ffmpeg 获取实时输出以在进度条中使用(PyQt4,stdout)

    我已经查看了很多问题 但仍然无法完全弄清楚 我正在使用 PyQt 并且希望能够运行ffmpeg i file mp4 file avi并获取流式输出 以便我可以创建进度条 我看过这些问题 ffmpeg可以显示进度条吗 https stack
  • 致命错误:libavcodec/avcodec.h 没有这样的文件或目录编译终止

    我正在尝试使用 gcc 执行tutorial01 c 并且 gcc 和tutorial01 c 以及 libavcodec 和 libavformat 及其关联文件位于同一文件夹中 它给了我这个错误 致命错误 libavcodec avco
  • Chromium 中的 MP4 编解码器支持

    我们已将 Chromium 嵌入式框架集成到我们的 Windows 游戏中 以允许我们从应用程序内渲染网页 并且一切正常 除了 MP4 视频 据我所知 由于许可问题 Chromium 不包含此编解码器 但任何人都可以提供有关我们如何添加支持
  • 如何在服务器上使用 ffmpeg 从 WebRTC 流获取音频和视频

    我正在尝试从 WebRTC 流获取音频和视频 并在 ubuntu 服务器上使用 ffmpeg 处理它 转码或转储 我天真地期望它能简单地解释 WebRTC 提供的 sdp 但我错了 我怀疑 ffmpeg 无法发回答案 sdp 必须手动完成
  • 将 ffmpeg 编译为独立二进制文件

    我正在尝试编译ffmpeg作为独立的二进制文件 因为我想在 AWS lambda 中使用它 我可以让事情在我正在编译的服务器上正常工作 但是如果我复制二进制文件并从另一台服务器运行它 我会得到 ffmpeg error while load
  • Xuggler 未转换 .webm 文件?

    我只是尝试使用 Xuggler 将 mov 文件转换为 webm 这应该可以工作 因为 FFMPEG 支持 webm 文件 这是我的代码 IMediaReader reader ToolFactory makeReader home use
  • Android 中的 FFMpeg jni?

    我已经构建了 Bambuser http bambuser com opensource 提供的 FFMPEG 可执行文件和库 所以我设法构建了 Android 可执行文件和库 如何在 Eclipse 项目中链接这些库并从 Java 调用
  • 如何在google colab中安装ffmpeg包

    我正在尝试使用 Google Colab 来做一些事情 我特别想用ffmpeg打包到从图像创建视频 https stackoverflow com a 44951066 6890234 但 ffmpeg 似乎工作得不太好 这个 在最后一个块
  • 如何在 RTMP 流中嵌入 pic_timing SEI 挂钟时间码?

    我需要将我的桌面流式传输到 AWS MediaLive 服务 并且根据要求 我必须在流中包含挂钟时间码 AWS 支持人员善意地通知我 对于 h 264 编码流 我需要提供时间码作为 pic timing SEI 消息 我在 Windows
  • 如何将AVFrame转换为glTexImage2D使用的纹理?

    如您所知 AVFrame 有 2 个属性 pFrame gt data pFrame gt linesize 当我从视频 sdcard test mp4 android平台 读取帧后 并将其转换为RGB AVFrame副 img conve
  • FFmpeg 缩放不是平滑中心(而是锯齿形)

    我尝试执行基本操作zoompan https www ffmpeg org ffmpeg all html zoompan with FFmpeg 我有一个输入图像 png 1280x720 并从中创建一个 8 秒的视频 mp4 320x1
  • swscaler 警告:使用了已弃用的像素格式

    我想先对视频帧执行颜色空间转换 然后使用以下代码将其转换为 opengl 纹理 struct SwsContext pSwsCtx sws getCachedContext NULL width height codec gt pix fm
  • 如何从 ffmpeg 中打开的文件获取流信息?

    我正在尝试使用 ffmpeg 读取视频文件 我有与其旧版本相对应的工作代码 并开始尝试升级到最新的构建版本 将所有这些已弃用的函数替换为其实际的类似函数 但是我遇到了问题 似乎没有检索到任何流 并且视频负载停止在轨道中 这是我正在使用的代码
  • FFMPEG Seeking 带来音频伪影

    我正在使用 ffmpeg 实现音频解码器 在读取音频甚至搜索已经可以工作时 我无法找到一种在搜索后清除缓冲区的方法 因此当应用程序在搜索后立即开始读取音频时 我没有任何工件 avcodec flush buffers似乎对内部缓冲区没有任何
  • 使用 ffmpeg 将 mp4 转换为 gif 时帧率较低

    我正在使用 ffmpeg 将高质量视频转换为 gif 大多数视频都是 60fps 及以上720p 但是当我使用下面的代码将视频转换为 gif 时 我得到的 gif 输出的 fps 非常低 usr bin env palette tmp pa
  • 图像序列到视频质量[关闭]

    Closed 这个问题是无关 help closed questions 目前不接受答案 我一直在尝试从一系列图像创建视频 当我使用建议的 ffmpeg 方法时 ffmpeg f image2 i image d jpg video mpg
  • 如何使用 FFmpeg 连接 MTS 视频并应用过滤器而不重新编码?

    我有一个包含许多 MTS 视频文件的 txt 文件 我想使用将它们全部合并在一起FFmpeg并获取一个大的 MTS 文件 但我想申请fade in and fade out到最后的视频 我可以在不重新编码的情况下做到这一点吗 因为重新编码需
  • 尽管重新采样音频过滤器,FFmpeg 对 ts 和 m3u8 文件的切割不准确

    我需要准确地寻找并剪切视频 一些在线资源说将 ss 放在源的前面或后面 结果对我来说是一样的 在下面的示例中 开始时间准确 但持续时间不准确 ffmpeg y ss 00 00 05 t 00 00 05 i output ts 5s wa

随机推荐

  • 获取下拉菜单值

    function getSelectVal ele var selectedIndex ele selectedIndex var value ele options selectedIndex value return value
  • oracle生成编号(首字母+YYYY-DD-MM+4位序号)自动增长,4位序号达到9999,在从1001开始。

    今天写业务的时候遇见需要系统生成13位的编号 规则编号按一个大写字母 YYYY MM DD 4位序号组成 数据库用的oracle 所以就打算用序列实现 下面是实现方式 1 先创建序列 create sequence contact seq
  • vue2.x 插件的开发

    前言 第一次好好学习插件的开发 有什么不正确的地方麻烦指正 另外写这篇文章 纯粹是当作自己的学习笔记 插件 插件通常用来为 Vue 添加全局功能 插件的功能范围没有严格的限制 一般有下面几种 添加全局方法或者 property 如 vue
  • 如何查看和修改操作系统字符集

    在Windows平台下查看和修改字符集 一 查看字符集 chcp 二 修改字符集为936 chcp 936 简体中文 可以得到操作系统的代码页信息 你可以从控制面板的语言选项中 可以查看代码页对应的详细的字符集信息 linux下查看和修改字
  • JavaScript 手写深拷贝

    深拷贝 深拷贝就是要拷贝的对象内的所有引用类型的属性进行完整的拷贝 也就是说拷贝出来的对象和原对象之间没有任何数据是共享的 所有的东西都是自己独占的一份 三步实现深拷贝 第一步 判断入参是值类型还是引用类型 值类型直接返回 if typeo
  • 数字图像处理课程设计-疲劳检测系统

    文章目录 数字图像处理课程设计 疲劳检测系统 前言 一 课程设计任务 二 设计框图 三 准备工作 四 任务流程 视频预处理 4 2图片分割 五 结果 六 项目总结 数字图像处理课程设计 疲劳检测系统 前言 此系统基于MATLAB设计 核心思
  • 系统稳定性设计原则:简单、冗余、标准化、健壮

    作者介绍 淇公 蚂蚁金服技术专家 热爱java和一些函数式语言 长期关注系统稳定性领域 因为base在分公司 需要经常去总部出差 所以搭乘飞机成了家常便饭 很多时候坐在飞机上会不由的感叹 设计制造这样精密复杂的机器的那帮人真的是了不起 他们
  • 如何获取Windows软件安装信息

    猜你感兴趣 使用Pyqt5玩转ChatGpt 内网文件共享服务 快速搭建私有pip镜像源 python设计模式 创建型模式 docker搭建私有git服务器 项目备份和迁移 redis持久化方案 说明 windows注册表中有两支子健存储有
  • Swagger3 注解使用(Open API 3.0)

    文章目录 前言 一 swagger 3 的使用 Swagger SpringFox 3 0 相关特性 SpringDoc 二 从 spring fox 迁移到 springdoc 三 使用 swagger3 注解代替 swagger2 的
  • 【算法/剑指Offer】从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。

    题目描述 从上到下按层打印二叉树 同一层结点从左至右输出 每一层输出一行 struct TreeNode int val struct TreeNode left struct TreeNode right TreeNode int x v
  • (Oracle基础篇) Select检索数据

    Select语句语法 Select语句是日常使用最多的语句 它以select开头 其中最重要的部分就是Select和From关键字 这两项是查询当中必须的部分 其他子句可以根据实际的需求进行变动 获取指定字段数据代码 查询指定字段数据实例代
  • 如何在Jupyter Notebook中使用Tensorflow

    下边是原文链接 中文翻译如下 http stackoverflow com questions 35771285 using tensorflow through jupyter python 3 解决该问题主要参考Using a virt
  • 7个学习UI、UX设计一定要经历的步骤

    我们不是一些有才华的设计师 我们天生就有艺术天赋 后天我们学会了设计技巧 设计的根本目的是解决问题 设计是不断发现和解决问题 有许多设计领域 UI UX 产品设计师 平面设计师 交互设计师 信息架构师等 所以要找出你最感兴趣的设计专业 现在
  • 【C++入门】新增nullptr关键字详解

    1 C和C 中NULL的区别 ifdef cplusplus 定义这个符号就表示当前是C 环境 define NULL 0 在C 中NULL就是0 else define NULL void 0 在C中NULL是强制类型转换为void 的0
  • 使用externals配置,在VUE 工程中引入外部js文件,减少打包时间

    以VUE项目中引入echarts文件为例 第一步在VUE项目中找到index html文件 引入 第二步 在项目找到 build gt webpack base conf js module exports externals echart
  • CTF--web学习

    这是大二上学期主要学习的一些知识 分享一下 一 linux常见命令 Linux切换到超级管理员 sudo su 切换到普通用户 su username touch创建文件 mkdir创建文件夹 mkdir p aaa bbb ccc创建aa
  • Jupyter:数据分析和网络爬虫开发利器

    Jupyter是一种流行的数据分析和网络爬虫开发工具 它具有许多功能 使得在各种语言 如Python R和Julia 中编写 测试和调试代码变得简单 Jupyter的一个优点是 它允许用户在Web浏览器中与数据和可视化进行交互 无需在本地计
  • 解决webview不显示图片常用方法,亲测有效

    左图不显示图片 右边是解决后显示的 我是先截右边再截左边 所以时间上右边的早了 都有的代码如下 项目中用的dataBinding数据绑定 mBinding wvBaseWebView指的是webview控件 mBinding wvBaseW
  • STM32:Custom HID实现USB双向通信

    本文章主要讲了使用STM32的USB Device 实现控制板和电脑通信功能 从而实现 上位机对控制板进行调试 USB Device可以有多种类型 实现双向通信的话 推荐使用Custom HID类型 首先使用STM32CubeMx实现功能引
  • ffmpeg 音频常用命令

    ffmpeg的使用方式 ffmpeg options infile options i infile outfile options outfile Stream specifier Some options are applied per