HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: sundance on 2013-10-27 13:27:53

Title: Problems with ffmpeg piping
Post by: sundance on 2013-10-27 13:27:53
Hello,
I was trying to create a batch command to easily convert popular lossless file formats (flac, tak, ape, ...) to lossyFLACs.
The plan was to use ffmpeg for the decoding stage - but I failed...

I started to create lossy WAVs first:
Can someone shed some light why this command doesn't work:
Code: [Select]
ffmpeg -i test.flac -f wav - | lossywav -

Error:
Code: [Select]
Could not write header for output file #0 (incorrect codec parameters ?): Error number -22 occurred

While this one works (and produces a "stdin.lossy.wav" output file as expected):
Code: [Select]
flac -d test.flac -c | lossywav -

Maybe it's the way lossyWAV works, because this one is working (though it doesn't make much sense):
Code: [Select]
ffmpeg -i test.flac -f wav - | qaac - -o test.m4a


.sundance.
Title: Problems with ffmpeg piping
Post by: nu774 on 2013-10-27 14:14:09
When piping to stdout, ffmpeg writes zero in size field of data chunk.
Therefore, receiver usually requires option like --ignorelength to read it.

As for qaac, it will automatically falls back into ignore length mode if size field of data chunk is zero. Strictly speaking it may not be spec compliant, but I think it's much likely the case that data is coming from ffmpeg than user actually wants to pass zero length audio to qaac, so I think it's more "convenient" for users.
Title: Problems with ffmpeg piping
Post by: sundance on 2013-10-27 16:12:04
So, since lossyWAV hasn't got an option like "ignore-length", is there a solution for ffmpeg to output correct length information?
Or is using a temporary WAV file the only way to go?
Title: Problems with ffmpeg piping
Post by: nu774 on 2013-10-27 16:23:01
So, since lossyWAV hasn't got an option like "ignore-length", is there a solution for ffmpeg to output correct length information?
Or is using a temporary WAV file the only way to go?

Try something like the following, it seems to work here:
Code: [Select]
ffmpeg -v 0 -i foo.flac -f wav - | qaac --silent -D - -o - | lossywav -

Here, qaac plays a role to convert size field of data chunk coming from ffmpeg to 0xffffffff, which qaac uses as a placeholder when input length is unknown.
Maybe other commands can do this as long as it has --ignorelenth like option, and writes sane size field to the pipe.
Title: Problems with ffmpeg piping
Post by: CoRoNe on 2013-10-27 17:12:17
Code: [Select]
ffmpeg.exe -i "lossless.flac" -f wav - | lossyWAV.exe - -I -- | flac.exe --ignore-chunk-sizes -8 -b 512 - -o "lossy.flac"

This works for me.
Title: Problems with ffmpeg piping
Post by: nu774 on 2013-10-27 17:19:32
Oh, thanks. I should have checked lossywav command line.
-I is shown by --longhelp.
Title: Problems with ffmpeg piping
Post by: sundance on 2013-10-27 19:43:19
I'm using lossyWAV v1.3.0 and -I is not shown @ --longhelp.
What version are you guys using?
Title: Problems with ffmpeg piping
Post by: Nick.C on 2013-10-27 19:49:27
In lossyWAV v1.3.0 a zero length file would cause an error. This has been changed in recent beta versions, along with added handling of WAVE64 and RF64 file formats.
Title: Problems with ffmpeg piping
Post by: sundance on 2013-10-27 19:57:03
Thanks Nick, nu774 and CoRoNe for the valuable pointers - will try the latest beta...
Title: Problems with ffmpeg piping
Post by: CoRoNe on 2013-10-27 20:03:30
lossyWAV beta 1.3.0c 15/09/2012
  • Piped I/O implemented - please report problems
[/size]

I believe Nick.C added it in this version, so you'd be better off by downloading the latest version I guess.
Title: Re: Problems with ffmpeg piping
Post by: Apesbrain on 2016-05-03 17:41:31
I am trying to pipe M4A to WAV and back to M4A applying SoX equalization during the WAV phase:
Code: [Select]
... | [ffmpeg] -i - -c:a aac -strict -2 -b:a 320k -f adts -
This last part is not working and it may be because I do not know how to specify the stdout file type is M4A.  Is it possible to do so?