I wanted to see if I could stream AAC audio to the web player. I tried...
* faac (You cannot use a MPEG4 container (-w) option and write to standard output, this is either a bug or a "feature"). Without this option it creates a file with a ADTS container which the web player can't use.
* Nero AAC encoder. This can't write to standard output.
I tried using process substiution (bash) and named pipes (using mkfifo command) but this doesn't work.
* ffmpeg can't write mp4 a container to standard output as it requires seekable output.
The solution I found was to use a flv container. I did this by using the following transcoding chain (just one step)
- Code: Select all
ffmpeg -i %s -acodec libfaac -ab %bk -f flv -
for
mp3 > aac
flac > aac
wav > aac
etc...
Note the maximum bitrate average bitrate that libfaac supports is 152kbit/s. But if a higher bit-rate is specified then libfaac will just use 152.
This works with the web player, note that you will need to disable all the " * > mp3" transcoders for the web player (.e.g flac > mp3). I created a new player called "aac-player" that only transcodes to AAC audio.
Libfaac can use a quality option with a range 10 to 500 instead of a average bitrate.
I wrote a bash wrapper script that is invoked as follows
- Code: Select all
aacenc-wrapper %s %b
that scales bit-rate [32,320] to a range of [10,500] linearly. The code for it is as follows
- Code: Select all
#!/bin/bash
#Wrapper script to linearly scale bit-rate [32,320] to quality range [10,500]
#For * > aac conversion for webplayer streaming (JWPlayer) in Subsonic
#
# usage aacencwrapper FILENAME BITRATE
#Maximum & minimum quality values to pass to libfaac
MAX_Q=500
MIN_Q=10
#calculate Quality
INPUT="$1"
BITRATE="$2"
QUALITY=$(echo "scale=2; ($MAX_Q - $MIN_Q)*($BITRATE - 32)/(288) + $MIN_Q" | bc)
#round calculated quality
QUALITY=$(printf %.0f $(echo $QUALITY))
echo "Using Quality: $QUALITY (from $BITRATE kbit/s)" 1>&2
#check input file exists
if [ ! -r "$INPUT" ]; then
echo "File $INPUT does not exist, transcode cancelled!" 1>&2
exit 1;
fi
#execute command
ffmpeg -i "$INPUT" -acodec libfaac -aq $QUALITY -f flv -
Please note:
* This may require a recent version of ffmpeg. It must be compiled with libfaac support and the faac library must be present (or statically linked, I'm not sure if that's possible though)
* This should work with VLC as an external player but I haven't tested it.
* This method will NOT work for streaming AAC to the android subsonic application as subsonic requires AAC audio to be in a MP4 container which as previously mentioned cannot be written to standard output.