Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What format/protocol does ffmpeg use for "raw" output?

Given a commandline ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ar 8000 -c:a FOO pipe:1, ffmpeg might complain it's "unable to find a suitable output format". For some codecs, ffmpeg has a default container format, e.g. -c:a libmp3lame will produce MP3's. For other codecs, you just repeat yourself (sort of): -c:a pcm_alaw -f alaw

But what if I want to stream the raw codec output, and there's no matching -f? Can I just take -f alaw and assume that it doesn't do anything? (G711 alaw is a simple codec which produces a byte stream, so -f alaw presumably just copies that byte stream)

Obviously the other side of the pipe needs to know how the data stream needs to be interpreted, if there's no container info. But assume that I already know the other side of the pipe is expecting an audio stream, sampled at 8 kHz, encoded with -c:a FOO.

like image 285
MSalters Avatar asked Oct 21 '25 03:10

MSalters


2 Answers

Yes, a raw stream is just that: no encapsulation of the codec payload.

For the sake of clarity in your command syntax, you can use data

ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ar 8000 -c:a FOO -map 0 -f data pipe:1  
like image 180
Gyan Avatar answered Oct 24 '25 03:10

Gyan


I presume by 'raw' you meant uncompressed audio samples (PCM).

In addition to alaw, ffmpeg supports other variations of PCM formats.

ffmpeg -formats | grep PCM

shows

 DE alaw            PCM A-law
 DE f32be           PCM 32-bit floating-point big-endian
 DE f32le           PCM 32-bit floating-point little-endian
 DE f64be           PCM 64-bit floating-point big-endian
 DE f64le           PCM 64-bit floating-point little-endian
 DE mulaw           PCM mu-law
 DE s16be           PCM signed 16-bit big-endian
 DE s16le           PCM signed 16-bit little-endian
 DE s24be           PCM signed 24-bit big-endian
 DE s24le           PCM signed 24-bit little-endian
 DE s32be           PCM signed 32-bit big-endian
 DE s32le           PCM signed 32-bit little-endian
 DE s8              PCM signed 8-bit
 DE u16be           PCM unsigned 16-bit big-endian
 DE u16le           PCM unsigned 16-bit little-endian
 DE u24be           PCM unsigned 24-bit big-endian
 DE u24le           PCM unsigned 24-bit little-endian
 DE u32be           PCM unsigned 32-bit big-endian
 DE u32le           PCM unsigned 32-bit little-endian
 DE u8              PCM unsigned 8-bit

Similarly,

ffmpeg -codecs | grep PCM

will show list of audio codecs for PCM format.

like image 33
wto Avatar answered Oct 24 '25 04:10

wto