码迷,mamicode.com
首页 > 其他好文 > 详细

ffmpeg 音频常用命令

时间:2018-06-02 23:59:14      阅读:593      评论:0      收藏:0      [点我收藏+]

标签:reads   encoder   dem   for   rtc   ref   AC   apply   fir   

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 

解码音频:

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

编码:

ffmpeg -i input.wav output.ac3

  

ffmpeg 音频常用命令

标签:reads   encoder   dem   for   rtc   ref   AC   apply   fir   

原文地址:https://www.cnblogs.com/fellow1988/p/9127420.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!