Wednesday, 15 January 2014

Converting 20-bit PCM from a DVD soundtrack to FLAC on Windows

Almost everything refuses to work with this 20-bit format, but here’s a process I found to work.

DVDDecrypter can demultiplex the stream and split it into chapters.

  • In the settings, on the IFO tab choose splitting by chapter. On the Stream processing tab ensure Convert PCM to WAV is unchecked.
  • Choose IFO mode
  • Select the PGC in the Input tab
  • Enable stream processing, check only the LPCM stream
  • Choose Direct Stream Copy
  • Choose an output folder
  • Hit the decrypt button

You should now have a folder with PCM files in, which nothing understands. Except Twen.

For each PCM file in turn:

  • Press open, select the PCM file.
  • Press Process.

That should create a WAV file for each chapter, which nothing understands. Except ffmpeg.

From a command prompt in the folder with the WAVs,

for %f in (*.wav) do "path-to-ffmpeg.exe" -i "%f" -acodec flac "%~nf.flac"

You can now get rid of everything except the FLAC files in that folder. They should be playable in your favourite music app, as 24-bit 48kHz FLAC.

Monday, 6 January 2014

Setting up a DLNA renderer with decent line out on a Raspberry Pi

GMediaRenderer/GMRender-Resurrect with a USB soundcard on Raspbian Wheezy (as of January 2014).
I could only get rid of the choppy sound by lowering the USB speed, so if that’s a problem for you then these instructions won’t help…
I’m not claiming any of this is groundbreaking or even original. This is basically me pulling together all the information I found on various blogs and forum posts into one set of steps that seemed to be ‘current’. I hope I have given everyone the appropriate credit for their hard work, if not please let me know and I’ll fix it.

Install Raspbian (Wheezy) using NOOBS

Available from the Raspberry Pi downloads page.

Get a USB soundcard

But check that it works with the Raspberry Pi. This is the one I used (because on of the reviewers had it working): Dynamode USB Sound Card 7.1

Install gstreamer-1.0

Add the custom repository line
deb http://vontaene.de/raspbian-updates/ . main
to /etc/apt/sources.list as described in this forum post, where Defiant has compiled gstreamer-1.0 for Raspbian.
Update the package information and install the upnp and gstreamer libraries.
sudo apt-get update
sudo apt-get install libupnp-dev \
libgstreamer1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
gstreamer1.0-alsa

Get and build gmrender-resurrect

From Henner Zeller’s  instructions in the gmrender-resurrect repository
sudo apt-get install autoconf automake libtool git
git clone https://github.com/hzeller/gmrender-resurrect.git
cd gmrender-resurrect
./autogen.sh
./configure
make
sudo make install

Set up alsa and tweak the USB settings

I made the USB soundcard the default sound following the instructions in atom’s forum post:
In /etc/modprobe.d/alsa-base.conf, comment out the line that prevents usb-audio from being loaded first, and add the line to prevent the on-board sound being loaded first:
#options snd-usb-audio index=-2
options snd_bcm2835 index =-2
options snd-usb-audio nrpacks=1
Then configure the volume to be full using
sudo alsamixer

sudo alsactl store
I tried enabling fiq_split (whatever that is), but I still couldn’t get the playback to not stutter, until I lowered the usb speed to USB 1. Edit /boot/cmdline.txt to add
dwc_otg.fiq_split_enable=0 dwc_otg.speed=1

Install gmrender-resurrect

From inside the gmrender-resurrect folder
sudo make install
And then create a script to run at startup with some appropriate settings. Save this script as /etc/init.d/gmediarenderer (from Stephen C Phillips’ post on Making gmediarender start on boot - but with the command line changed for ALSA instead of pulseaudio). You’ll need a guid, which you can generate using your favourite guid generating tool (what? you don’t have a favourite guid generating tool – try http://www.random-guid.com/).
#!/bin/sh
### BEGIN INIT INFO
# Provides: gmediarender
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start GMediaRender at boot time
# Description: Start GMediaRender at boot time.
### END INIT INFO
USER=root
HOME=/root
export USER HOME
case "$1" in
start)
echo "Starting GMediaRender"
start-stop-daemon -x /usr/local/bin/gmediarender -S -- -d --gstout-audiosink=alsasink --gstout-audiodevice=sysdefault --uuid insert-your-guid-here -f "name-your-media-renderer" --logfile /dev/null
;;
stop)
echo "Stopping GMediaRender"
start-stop-daemon -x /usr/local/bin/gmediarender -K
;;
*)
echo "Usage: /etc/init.d/gmediarender {start|stop}"
exit 1
;;
esac
exit 0
And then install the service with
sudo update-rc.d gmediarenderer defaults
And reboot.

Android remote control

To play audio from my DLNA server (Buffalo LinkStation Live NAS) on the newly running renderer, I had good success with MediaHouse on Android (which has a free and pro version)

See? simple :-)

I hope I’ve managed to capture all the steps I did to get that working. If you try it and find anything wrong, let me know in the comments and I’ll at least try to update these instructions.