Page 1 of 1

[Solved] flac>m4a

PostPosted: Sat Dec 18, 2010 2:17 am
by hyatari
Can anyone tell me the commands to transcode flac to m4a? Mainly for use on android device. Also is it necessary to change the downsample command as well?

Thanks.

PostPosted: Sat Dec 18, 2010 4:18 am
by GJ51
Stozher's the man when it comes to transcoding! Here's his suggetions.

One step with a fixed bit rate (all tags transferred to MP3)

Step 1: ffmpeg -i %s -f mp3 -ar 44100 -ab 320k -ac 2 -map_meta_data 0:0 -
Step 2: none (blank)

or two step transcoding (above is a better choice)

Step 1: ffmpeg -i %s -f wav -ar 44100 -ac 2 -
Step 2: lame --preset cbr %b -S --tt %t --ta %a --tl %l - -

See also http://forum.subsonic.org/forum/viewtop ... 7540#17540

PP: Mark check boxes right from Step 3 and check players settings (log as admin to see all players).


Pasted from

http://forum.subsonic.org/forum/viewtopic.php?t=4914

PostPosted: Sat Dec 18, 2010 4:39 am
by stozher
FLAC > M4A (AAC):

flac > m4a (aac) | flac | m4a | ffmpeg -i %s -f flv -vn -acodec libfaac -ar 44100 -aq 500 -ac 2 -map_meta_data 0:0 - |

Step 2 is a blank (none). See also http://forum.subsonic.org/forum/viewtop ... 8197#18197 and next post for ABR testing.

Test on my server (see link in my profile). Currently I use VBR and quality is a better... also on my server sample rate is a 48 kHz (-ar 48000).

PostPosted: Sat Dec 18, 2010 5:30 am
by GJ51
Thanks Stozher!

No doubt I really need to educate myself more on the whole transcoding subject.

There's also no doubt that your site sounds fantastic. Great quality. Many thanks for all your contributions!

PostPosted: Sat Dec 18, 2010 4:03 pm
by hyatari
is this meant to work on android? i keep getting an I/O error when trying to play flac now on device. it shows the flac > m4a when looking through flac files but wont play anything. ive disabled the flac > mp3 made flac > m4a defualt and checked the boxes for the player. i tried the 48000 and 44100.

PostPosted: Sat Dec 18, 2010 4:14 pm
by GJ51
I can stream to my phone when connected to Stozher's site.

PostPosted: Sat Dec 18, 2010 4:32 pm
by hyatari
ok its working with the 2 step method you posted previously. thanks. this is a cbr it appears. i would like to get the vbr method working if possible. basically i want the highest quality with lowest bitrate/least amount of bandwidth i can achieve.

PostPosted: Sat Dec 18, 2010 5:16 pm
by stozher
FLAC > MP3 (VBR):

Step 1: ffmpeg -i %s -f wav -acodec pcm_s16le -ar 44100 -ac 2 -
Step 2: lame --preset extreme -S --tt %t --ta %a --tl %l - -

--preset medium - this preset should provide near transparency to most people on most music;
--preset standard - this preset should generally be transparent to most people on most music and is already quite high in quality;
--preset extreme - if you have extremely good hearing and similar equipment, this preset will generally provide slightly higher quality than the standard mode.


Step 1: ffmpeg -i %s -f wav -acodec pcm_s16le -ar 44100 -ac 2 -
Step 2: lame -v --vbr-new -B %b -S --tt %t --ta %a --tl %l - -

-B %b - specifies the maximum allowed bitrate from SS Settings / Players. Always specify different from "No limit" in Setting / Users ("No limit" for lame is a default = 128k; for ffmpeg is a default = 64k).


Step 1: ffmpeg -i %s -f wav -acodec pcm_s16le -ar 44100 -ac 2 -
Step 2: lame -v --vbr-new -V 0 -S --tt %t --ta %a --tl %l - -

Step 1: ffmpeg -i %s -f mp3 -acodec libmp3lame -ar 44100 -aq 0 -ac 2 -map_meta_data 0:0 -
Step 2: none (blank)

VBR quality (default = 4). In this mode, you choose the desired quality on a scale from 9 (lowest quality/biggest distortion) to 0 (highest quality/lowest distortion).

PostPosted: Sat Dec 18, 2010 5:53 pm
by stozher
hyatari, you need to upgrade FFmpeg (see "--enable-libfaac" and other built-in configuration options in my version):

Code: Select all
stozher@stozher:~$ ffmpeg
FFmpeg version SVN-r25838, Copyright (c) 2000-2010 the FFmpeg developers
  built on Nov 29 2010 15:39:30 with gcc 4.4.5
  configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
  libavutil     50.33. 0 / 50.33. 0
  libavcore      0.14. 0 /  0.14. 0
  libavcodec    52.97. 2 / 52.97. 2
  libavformat   52.87. 1 / 52.87. 1
  libavdevice   52. 2. 2 / 52. 2. 2
  libavfilter    1.65. 0 /  1.65. 0
  libswscale     0.12. 0 /  0.12. 0
  libpostproc   51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


EDIT: I tested on Motorola Milestone and AAC included in FLV container don't work. Next days I check with other container formats...

PostPosted: Thu Dec 30, 2010 5:06 pm
by gabbott
stozher,
You seem to be pretty knowledgeable with transcoding. Looking for some help. I'm running subsonic on an unraid box (basically slackware distro) and trying to get flac to ogg transcoding working to my android device. I've got it working but no matter what I try I can't get tags on the transcoded files.

Code: Select all

root@Media02:/boot/subsonic/data/transcode# ffmpeg
FFmpeg version 0.6, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jun 18 2010 17:09:12 with gcc 4.4.4
  configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/man --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-libdc1394 --enable-libfaad --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --disable-vdpau --enable-memalign-hack --enable-pthreads --enable-x11grab --enable-bzlib --enable-zlib --enable-shared --enable-static --disable-debug --extra-cflags='-I/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/include -DRUNTIME_CPUDETECT' --extra-ldflags='-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib -lssl -lcrypto -lz -lusb'
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'



Code: Select all

root@Media02:/boot/subsonic/data/transcode# oggenc -h
oggenc from vorbis-tools 1.3.0 by the Xiph.Org Foundation (http://www.xiph.org/)



Here is what I'm using for transcoding (just one step)

oggenc -Q -q 4.5 %s -o -

PostPosted: Thu Dec 30, 2010 8:10 pm
by stozher
FLAC > OGG:

ffmpeg -loglevel error -v 0 -i %s -f ogg -acodec flac -ar 44100 -aq 4.5 -ac 2 -map_meta_data 0:0 -

ffmpeg -loglevel error -v 0 -i %s -f ogg -acodec libvorbis -ar 44100 -aq 4.5 -ac 2 -map_meta_data 0:0 -

For "-aq" option value see "Wikipedia: Vorbis - Technical details". If you specify only "-f ogg" (not "-acodec") FFmpeg use "-acodec vorbis" - better variant is a libvorbis. Option "-map_meta_data 0:0" used to transfer vorbis tags from FLAC to OGG.


oggenc %s -Q -q 4.5 --resample 44100 -a %a -t %t -l %l -o -

-q n, --quality=n

Sets encoding quality to n, between -1 (very low) and 10 (very high). This is the default mode of operation, with a default quality level of 3. Fractional quality levels such as 2.5 are permitted. Using this option allows the encoder to select an appropriate bitrate based on your desired quality level.

PostPosted: Thu Dec 30, 2010 10:15 pm
by gabbott
stozher wrote:FLAC > OGG:

ffmpeg -loglevel error -v 0 -i %s -f ogg -acodec flac -ar 44100 -aq 4.5 -ac 2 -map_meta_data 0:0 -

ffmpeg -loglevel error -v 0 -i %s -f ogg -acodec libvorbis -ar 44100 -aq 4.5 -ac 2 -map_meta_data 0:0 -

For "-aq" option value see "Wikipedia: Vorbis - Technical details". If you specify only "-f ogg" (not "-acodec") FFmpeg use "-acodec vorbis" - better variant is a libvorbis. Option "-map_meta_data 0:0" used to transfer vorbis tags from FLAC to OGG.


oggenc -Q -q 4.5 --resample 44100 -o - -a %a -t %t -l %l %s

-q n, --quality=n

Sets encoding quality to n, between -1 (very low) and 10 (very high). This is the default mode of operation, with a default quality level of 3. Fractional quality levels such as 2.5 are permitted. Using this option allows the encoder to select an appropriate bitrate based on your desired quality level.


Thanks for this, I think I need to figure out how to compile ffmpeg with libvorbis.

PostPosted: Fri Dec 31, 2010 3:06 pm
by rgthorpe2001
First, thanks to Stozher and other posters here in other threads I have my Subsonic server successfully transcoding tracks in flac to ogg. This is a MAJOR improvement to my Subsonic experience, as I use Subsonic to stream to an Android client, and with ogg I now have gapless (or nearly gapless) playback.

Rather than transcoding my existing mp3s and aacs with the resulting quality loss, I plan to rerip my existing cds for which I need gapless playback to flac. I understand that the optimal way to do this is to encode to a single flac file with cue sheet, rather than to a flac for each track as I have done thus far. Has anyone had success transcoding on the fly from flac plus cue, and what commands have you used? (Goggling thus far has only turned up ways to split the flac -- I would like to leave the single flac file + cue as is, and only transcode to separate oggs when called from the Android client.)

PostPosted: Fri Dec 31, 2010 4:35 pm
by stozher
Linux commands to transcoding track by choice from FLAC+CUE to other format isn't a big problem but SS don't see separate tracks in big FLAC file...

PostPosted: Fri Dec 31, 2010 5:33 pm
by rgthorpe2001
Thanks, makes sense -- I'll stick to a file for each track for my re-ripping project.