How to pipe Csound output to ffmpeg for conversion without an intermediate file?

169 Views Asked by At

On Ubuntu 20.04, Csound 6.13.0, ffmpeg 4.2.4 this plays fine:

git clone https://github.com/csound/csound
cd csound
git checkout 92409ecce053d707360a5794f5f4f6bf5ebf5d24
csound examples/xanadu.csd

and I can save to file with:

csound -o xanadu.wav xanadu.csd
ffplay xanadu.wav

or:

csound -W -o stdout xanadu.csd > xanadu-stdout.wav

and even convert from file:

ffmpeg -i xanadu-stdout.wav xanadu-stdout.ogg
ffplay xanadu-stdout.ogg

or:

cat xanadu-stdout.wav | ffmpeg -f wav -i - xanadu.ogg

or:

csound -W -o stdout xanadu.csd | cat > xanadu-cat.wav

So why does this fail from the direct pipe:

csound -W -o stdout xanadu.csd | ffmpeg -f wav -i - xanadu.ogg

or:

csound -W -o stdout xanadu.csd | cat > xanadu-cat.wav
ffmpeg -y -f wav -i xanadu-cat.wav xanadu.ogg

with:

[wav @ 0x56093284c6c0] invalid start code d[163][3][0] in RIFF header
xanadu-cat.wav: Invalid data found when processing input

So it seems that xanadu.wav and xanadu-cat.wav are different:

$ diff -u xanadu.wav xanadu-cat.wav
Binary files xanadu.wav and xanadu-cat.wav differ

and that makes the conversion fail.

I know about:

csound --ogg -o xanadu.ogg xanadu.csd

which does work, but I just want to pipe into ffmpeg for fun.

Also asked at: https://github.com/csound/csound/issues/1408

0

There are 0 best solutions below