Search code examples
ffmpegcontainersaudio-streaming

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.


Solution

  • 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