HydrogenAudio

Lossy Audio Compression => AAC => AAC - Tech => Topic started by: LigH on 2008-10-09 08:21:02

Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: LigH on 2008-10-09 08:21:02
Related to this thread in the german doom9/Gleitz board (http://forum.gleitz.info/showthread.php?t=38560):

A user would like to use ffmpeg as generic input decoder and NeroAacEnc as AAC encoder, receiving input via pipe from ffmpeg. In general, this works even with multi-channel sources. Just the channel mapping in the output of ffmpeg seems to be not in the order one should use to feed NeroAacEnc.

Is there a solution preferably without the need to store intermediate files?
Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: menno on 2008-10-09 15:39:24
Already discussed here:
http://forum.doom9.org/showthread.php?p=1192821#post1192821 (http://forum.doom9.org/showthread.php?p=1192821#post1192821)

Regarding the intermediate solution, there might be a tool that can read from stdin and write to stdout and does the channel reordering. Maybe SoX can do that?
Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: LigH on 2008-10-09 16:17:42
That's the same "Selur"; he forgot his account details here at HA.

SoX is indeed a suggestion he will gladly test.
Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: smok3 on 2008-10-09 19:04:05
sox should do it, if you can construct the cli from the incredibly sparse docs.
Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: tebasuna51 on 2008-10-10 03:50:22
Regarding the intermediate solution, there might be a tool that can read from stdin and write to stdout and does the channel reordering. Maybe SoX can do that?


Seems sox don't accept the incomplete wav header send by ffmpeg (worse than the old neroaacenc):
Code: [Select]
ffmpeg -i test.ac3  -acodec pcm_s16le -ac 6 -f wav -ar 48000 - | sox -t wav - -t wav - remix 2 4 3 1 5 6 | neroAacEnc -ignorelength -if - -of audio.mp4
...
\sox wav: Length in output .wav header will be wrong since can't seek to fix it

av_interleaved_write_frame(): Error while opening file


We need a intermediate wav file to do the conversion properly:
Code: [Select]
ffmpeg -i test.ac3  -acodec pcm_s16le -ac 6 -f wav -ar 48000 z1.wav
sox -t wav z1.wav -t wav - remix 2 4 3 1 5 6 | neroAacEnc -ignorelength -if - -of audio.mp4


BTW, Windows users only need:

eac3to test.ac3 audio.mp4

(neroaacenc at same folder than eac3to, libav decoder used like ffmpeg).
Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: aconverse on 2008-10-22 07:38:01

Regarding the intermediate solution, there might be a tool that can read from stdin and write to stdout and does the channel reordering. Maybe SoX can do that?


Seems sox don't accept the incomplete wav header send by ffmpeg (worse than the old neroaacenc):
Code: [Select]
ffmpeg -i test.ac3  -acodec pcm_s16le -ac 6 -f wav -ar 48000 - | sox -t wav - -t wav - remix 2 4 3 1 5 6 | neroAacEnc -ignorelength -if - -of audio.mp4
...
\sox wav: Length in output .wav header will be wrong since can't seek to fix it

av_interleaved_write_frame(): Error while opening file


We need a intermediate wav file to do the conversion properly:
Code: [Select]
ffmpeg -i test.ac3  -acodec pcm_s16le -ac 6 -f wav -ar 48000 z1.wav
sox -t wav z1.wav -t wav - remix 2 4 3 1 5 6 | neroAacEnc -ignorelength -if - -of audio.mp4


BTW, Windows users only need:

eac3to test.ac3 audio.mp4

(neroaacenc at same folder than eac3to, libav decoder used like ffmpeg).


If SoX doesn't like ffmpeg's wav header then the obvious solution is to send headerless PCM 

Code: [Select]
ffmpeg -i test.ac3 -f u16le -acodec pcm_s16le - | sox -t raw -s -2 -c6 -r48000 - -t wav - remix 2 4 3 1 5 6 | neroAacEnc.exe -ignorelength -if - -of audio.mp4


Be careful about channel counts and sample rates. Without headers it's your responsibility to send them.
Title: Piping 6ch from ffmpeg to NeroAacEnc
Post by: tebasuna51 on 2008-10-22 12:44:20
If SoX doesn't like ffmpeg's wav header then the obvious solution is to send headerless PCM 

Code: [Select]
ffmpeg -i test.ac3 -f u16le -acodec pcm_s16le - | sox -t raw -s -2 -c6 -r48000 - -t wav - remix 2 4 3 1 5 6 | neroAacEnc.exe -ignorelength -if - -of audio.mp4


Be careful about channel counts and sample rates. Without headers it's your responsibility to send them.


Yep, this work now.

But, obviously, we must know previously the channel count and samplerate. If ffmpeg output the correct channel order this workaround is unnecessary.