Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Piping 6ch from ffmpeg to NeroAacEnc (Read 11002 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Piping 6ch from ffmpeg to NeroAacEnc

Related to this thread in the german doom9/Gleitz board:

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?

Piping 6ch from ffmpeg to NeroAacEnc

Reply #1
Already discussed here:
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?

Piping 6ch from ffmpeg to NeroAacEnc

Reply #2
That's the same "Selur"; he forgot his account details here at HA.

SoX is indeed a suggestion he will gladly test.

Piping 6ch from ffmpeg to NeroAacEnc

Reply #3
sox should do it, if you can construct the cli from the incredibly sparse docs.
PANIC: CPU 1: Cache Error (unrecoverable - dcache data) Eframe = 0x90000000208cf3b8
NOTICE - cpu 0 didn't dump TLB, may be hung

Piping 6ch from ffmpeg to NeroAacEnc

Reply #4
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).

Piping 6ch from ffmpeg to NeroAacEnc

Reply #5

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.

Piping 6ch from ffmpeg to NeroAacEnc

Reply #6
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.