Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipe input in to ffmpeg stdin

Tags:

I am trying to use ffmpeg to decode audio data. While it works to load from a file, I would like to avoid using files because to do so, means I would have to use a temporary. Instead, I'd like to pipe in the data(which I've previously loaded) using stdin.

Is this possible?

e.g.,

  1. Manually load mp3 file
  2. Pipe it in to the ffmpeg spawned process
  3. Get raw output

(it should work with ffprobe and ffplay also)

like image 264
AbstractDissonance Avatar asked Aug 26 '17 20:08

AbstractDissonance


1 Answers

ffmpeg has a special pipe flag that instructs the program to consume stdin. note that almost always the input format needs to be defined explicitly.

example (output is in PCM signed 16-bit little-endian format):

cat file.mp3 | ffmpeg -f mp3 -i pipe: -c:a pcm_s16le -f s16le pipe: 

pipe docs are here
supported audio types are here

like image 80
MrBar Avatar answered Sep 18 '22 20:09

MrBar