Page 1 of 1

Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 06, 2013 7:26 am
by geofstro
I have a number of HiRez files. I can stream all formats at up to 48khz, no problem. I can't handle the > 48khz though.

Is there any way to create a rule to downsample to 48khz in those situations; but otherwise leave the file alone; i.e. not transcode?

Seems like it should be possible. I can't see a way to do it though.

Admittedly I'm not too familiar with the ffmpeg commands.

Thanks in advance to anyone who can offer advice.

geoff

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Wed Sep 18, 2013 2:47 am
by GJ51
Not understood.

Downsampling normally refers to kbps where higher bitrate music is downsampled to a lower bit rate to save bandwidth. If you set the rate to 128kbps then any file with a higher bit rate gets downsampled.

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Thu Sep 19, 2013 8:22 am
by geofstro
I'm speaking about lossless files only, so it's appropriate to speak about the sample rate; but I understand your point. Whatever a lossless flac file at 48khz translates to in kbps is what I need to down-sample to. The kbps figure varies as the file streams though, so the value which stays fixed is the sample rate.

Is there a flac transcoding command, for example that will down sample any file with a sample rate above 48khz (e.g. 96khz) down to 48khz for streaming.

Sorry; but I thought my question was clear.

geoff

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 11:44 am
by GJ51
I thought that may have been what you were referring to.

In the transcoding settings you will find the string that ffmpeg uses for flac > mp3. There should be a section in that string similar to "-ar 44100 -ac 2 -v 0 -f mp3 -" that reprocesses any flac down to 44100khz. It should then be that output that would be downsampled if necessary with Subsonics downsampling feature.

I don't know how else you would handle this issue.

I hope that helps a bit. Please let me know if I'm not seeing this correctly.

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 6:11 pm
by geofstro
Thanks Gary. Wouldn't that convert to MP3 though? I'm looking for a way to leave it in flac format; but just change the sample rate, when the rate of the file is greater than 48khz.

Thanks again.

Geoff

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 7:40 pm
by GJ51
It's a challenging issue that I've not seen posed before. If you look at the transcoding page in Settings, you do have an option to use ffmpeg to downsample. The current string outputs mp3.

You could experiment to see if replacing "mp3" with "flac" will work. If that simple substitution works then it would only be a matter of adding a parameter (maybe -ar 48000) into the string to limit the sample rate.

I assume that you must be attempting to do this for mobile playback? I know flac is great for quality, but you might consider ogg if this is for mobile as it is very efficient and maintains very good quality depending on the parameters you use.

The only other approach would be to limit the sample rate at the player end, but I can't imagine why you'd want to do that if the data is already to the player.

I have a dedicated mobile server that only outputs ogg that I set up to take advantage of the better performance in lower bandwidth connection environments. It is currently adjusted for around 100kbps for some of my mobile users to keep thier data usage reasonable. I'd be happy to give you access and adjust the data rate for you to a higher quality to see if that might be a better solution for you.

PostPosted: Fri Sep 20, 2013 7:50 pm
by daneren2005
Not to hijack the thread, but mind sharing the ogg line you use? I've considering switching to it before, but haven't felt like researching a good transcoding string.

Sent from my HTC One X using Tapatalk 4

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 7:56 pm
by GJ51
ffmpeg -v 0 -i %s -f ogg -vn -acodec libvorbis -ar 44100 -aq 3 -ac 1 -map_meta_data 0:0 -

Never a problem :) adjust the number after -aq to adjust quality, higher = better. Wikipedia has a reasonable approximation chart that converts settings to bitrate.

EDIT: ffmpeg -v 0 -i %s -f ogg -vn -acodec libvorbis -ar 44100 -aq 3 -ac 2 -map_meta_data 0:0 -

"-ac 2" enables 2 channels, sorry for the original.

Just looked at logs during playback and this is working fine for me. One thing that needs to be understood is that ogg doesn't just spit back a lower bitrate but varies bitrate based on the data being sampled. You can find 2 different tracks, both at 320kbps in the original format, but if one is full orchestra and the other is a solo acapella, the orchestration will use noticibly more bit rate.

Playing random tracks at the same settings -aq 3 I see anything from 80 - 120 kbps in the logs. Wikipedia has good explanations of how this works.

[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Input #0, mp3, from '\\MAPLEGROVE-DC\Music\Music\Florence + the Machine\Lungs\Florence + the Machine - Lungs - 13 - Youve Got The Love.mp3':
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Metadata:
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TPE1 : Florence + the Machine
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TALB : Lungs
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TPE2 : Florence + the Machine
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TIT2 : Youve Got The Love
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TPUB : Universal Republic
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TRCK : 13
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TYER : 2009
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TDRC : 2009
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Duration: 00:02:48.04, start: 0.000000, bitrate: 138 kb/s
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Stream #0.0: Audio: mp3, 44100 Hz, 2 channels, s16, 32 kb/s
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Output #0, ogg, to 'pipe:':
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Metadata:
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) artist : Florence + the Machine
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) album : Lungs
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TPE2 : Florence + the Machine
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) title : Youve Got The Love
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) publisher : Universal Republic
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) track : 13
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TYER : 2009
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) TDRC : 2009
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Stream #0.0: Audio: vorbis, 44100 Hz, 2 channels, s16, 64 kb/s
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Stream mapping:
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Stream #0.0 -> #0.0
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Press [q] to stop encoding
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) [mp3 @ 003e9200]Header missing
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) Error while decoding stream #0.0
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) size= 2454kB time=168.03 bitrate= 119.6kbits/s
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg)
[9/20/13 4:43:01 PM EDT] DEBUG InputStreamReaderThread (c:\subsonic\transcode\ffmpeg) video:0kB audio:2108kB global headers:4kB muxing overhead 16.197202%
The complete log is saved in c:\subsonic\subsonic.log.

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 8:00 pm
by mr_nobody
Yet another hijack! :wink: It is absolutely essential to use libvorbis. The vorbis encoder that ffmpeg defaults to encodes everything at 64kbps no matter what you tell it to for no apparent reason. :roll:

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 9:31 pm
by GJ51
Hijackers everywhere! :lol:

Let's just hope we've given the OP some things that might help.

Re: Can I limit down sampling to files above 48khz only?

PostPosted: Fri Sep 20, 2013 11:13 pm
by daneren2005
Sweet, I went ahead and put that in for experimentation later. I definitely notice nasty audio quality at 128 kpbs mp3, so hopefully this will provide an improvement without using more space :D