Changes between Version 5 and Version 6 of audio types


Ignore:
Timestamp:
Aug 4, 2017, 2:11:58 PM (23 months ago)
Author:
slhck
Comment:

style and some improvements

Legend:

Unmodified
Added
Removed
Modified
  • audio types

    v5 v6  
    1 Raw audio in FFmpeg can take several different "forms"
     1= Audio Types =
    22
    3 for instance:
     3FFmpeg can read various raw audio types (sample formats) and demux or mux them into different containers (formats). For example, you can read and write raw PCM audio into a WAV container.
    44
    5 * pcm_s16le PCM means "traditional wave like format" (raw bytes, basically).  16 means 16 bits per sample, "le" means "little endian", s means "signed", u would mean "unsigned"
     5== Sample Formats ==
    66
    7 You can see a list, by running a command like this on your own local box:
     7Raw audio in FFmpeg can take several different "forms", i.e. sample formats. For instance:
     8
     9* `s` means "signed" (for the integer representations), `u` would mean "unsigned"
     10* 16 means 16 Bits per sample
     11* `le` means "little endian" coding for the samples
     12
     13You can see a list of supported sample formats by inspecting the `ffmpeg -formats` output:
    814
    915{{{
    1016$ ffmpeg -formats | grep PCM
    11 ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers
    1217 DE alaw            PCM A-law
    1318 DE f32be           PCM 32-bit floating-point big-endian
     
    3237}}}
    3338
    34 Basically these represent all the raw audio type combination possibilities.
     39These represent all the built-in raw audio sample formats.
     40
     41== Reading and Writing Raw Audio ==
    3542
    3643FFmpeg can take input of raw audio types by specifying the type on the command line.  For instance, to convert a "raw" audio type to a ".wav" file:
    3744
    38 {{{ ffmpeg -f pcm_s32le input_filename.raw output.wav }}}
     45{{{
     46ffmpeg -f pcm_s32le input_filename.raw output.wav
     47}}}
    3948
    4049You can specify number of channels, etc. as well, ex:
    4150
    42 {{{ ffmpeg -f u16le -ar 44100 -ac 1 -i input.raw output.wav }}}
     51{{{
     52ffmpeg -f u16le -ar 44100 -ac 1 -i input.raw output.wav
     53}}}
    4354
    44 The default for encoding .wav files it uses is pcm_s16le, you can change it by specifying an "acodec" and using the .wav file extension:
     55The default for muxing into WAV files is `pcm_s16le`. You can change it by specifying the audio codec and using the WAV file extension:
    4556
    46 {{{ ffmpeg -i input -acodec pcm_s32le output.wav }}}
     57{{{
     58ffmpeg -i input -c:a pcm_s32le output.wav
     59}}}
    4760
    48 Which will create a .wav file containing audio with that codec (not a raw file) (there are also other containers that can contain raw audio packets, like pcm_bluray).  If you want to create a raw file, don't use the ".wav" ending:
     61which will create a WAV file containing audio with that codec (not a raw file). There are also other containers that can contain raw audio packets, like `pcm_bluray`.
    4962
    50 {{{ ffmpeg -i input -f s16le -acodec pcm_s16le output.raw }}}
     63If you want to create a raw file, don't use the WAV format, but the raw one (as seen in the table above), e.g. `s16le`, and the appropriate audio codec:
    5164
    52 You can tell what encoding by this part of your output, if it says ", s16le" then it's raw, it it says ", wav," then it's wav.
    53 
    54 {{{ > >> Output #0, s16le, to 'out.2.raw' }}}
     65{{{ ffmpeg -i input -f s16le -c:a pcm_s16le output.raw }}}