Thanks Mark. I will send you an example .m4a file privately.
For info, .m4a is a container which may contain lossy Apple AAC data, or can contain Apple Lossless ALAC data. ALAC is similar to FLAC, except FLAC is open source but not supported by Apple devices or itunes. Both are supported, even encouraged, by Sonos natively.
I've tried the following, keyed to your questions
1. Don't have a Linux PC unfortunately, but ffmpeg on my pi should be fine -- see output below.
pi@chickadee ~/LucyStorage/chickadee/sspy $ ls -l `which ffmpeg`
-rwxr-xr-x 1 pi pi 15009696 Dec 22 13:57 /usr/local/bin/ffmpeg
pi@chickadee ~/LucyStorage/chickadee/sspy $ ffmpeg -formats | grep -e "m4a\|mp3"
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8.3 (crosstool-NG linaro-1.13.1-4.8-2014.01 - Linaro GCC 2013.11) 20140106 (prerelease)
configuration: --enable-cross-compile --cross-prefix=/home/pi/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- --arch=armhf --target-os=linux --prefix=/home/pi/ffmpeg/build --enable-gpl --enable-libx264 --enable-libmp3lame --enable-libfdk-aac --enable-nonfree --enable-libaacplus --extra-cflags=-I/home/pi/ffmpeg/build/include --extra-ldflags=-L/home/pi/ffmpeg/build/lib --extra-libs=-ldl
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
D mov,mp4,m4a,3gp,3g2,mj2 QuickTime / MOV
DE mp3 MP3 (MPEG audio layer 3)
2. Tried that (adding a .m4a.flac mapping and copying over and modifying the block around l.150 in transcode.py) -- no change (from debug it is correctly going down the .m4a.flac tree but Sonos doesn't like the output).
3. Also no luck. Removed it so sonospy tried to serve it natively; the Sonos controller greyed out the track as being an invalid format. (Though Sonos can read it natively from the NAS without sonospy, or with sonospy -w)
4. Sending to you, but here's the (edited) output of a manual ffmpeg run on one file:
pi@chickadee ~/LucyStorage/chickadee/sspy $ time ffmpeg -i /home/pi/LucyStorage/music/Adele/19/01\ Adele\ -\ Daydreamer.m4a -q:a 0 -map a -f mp3 test.mp3
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/pi/LucyStorage/music/Adele/19/01 Adele - Daydreamer.m4a':
Metadata:
Source : CD (Lossless)
Encoder : Apple Lossless
Duration: 00:03:40.51, start: 0.000000, bitrate: 739 kb/s
Stream #0:0(eng): Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16p, 731 kb/s (default)
Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 750x750 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Output #0, mp3, to 'test.mp3':
Stream mapping:
Stream #0:0 -> #0:0 (alac (native) -> mp3 (libmp3lame))
size= 6423kB time=00:03:40.52 bitrate= 238.6kbits/s
video:0kB audio:6422kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.013108%
real 1m1.594s
user 1m9.320s
sys 0m0.760s
*** Not sure if that's a decent processing speed for streaming to Sonos?
*** Finally, here's debugging output From pycpoint.log (running with -mtranscode -mproxy -mmediaserver)
DEBUG transcode : 111: transcode() /home/pi/LucyStorage/music/Adele/19/01 Adele - Daydreamer.m4a
DEBUG transcode : 112: transcode() m4a.mp3
DEBUG mediaserver :2815: processQueryTrack() row: (u'834607b567d453744b3d3db91683011d', u'a47f4cdce3efe9501d407b3b26700fa9', 0, u'Rolling in the Deep', u'Adele', u'Adele', u'21', u'Singer', 1, 734161, u'Adele', u'Adele', u'', u'', u'MPEG-4 audio', 229, 27695058, 1393695533, u'/home/pi/LucyStorage/music/Adele/21', u'01 Adele - Rolling in the Deep.m4a', 1, u'', u'/home/pi/LucyStorage/music/Adele/21/Folder.jpg', None, 0, 0, 0, 0, u'audio/mp4', 1409969930, 53, 0, 1456187551, u'', u'', 1456187551, u'', u'')
DEBUG transcode : 59: checksmapitranscode() m4a
DEBUG transcode : 60: checksmapitranscode() 0
DEBUG transcode : 61: checksmapitranscode() 0
DEBUG transcode : 62: checksmapitranscode() 0
DEBUG transcode : 63: checksmapitranscode() 0
DEBUG transcode : 64: checksmapitranscode() MPEG-4 audio
DEBUG mediaserver :4373: querymetadata() end: 1456339094.171
DEBUG proxy : 865: processMediaMetadata() 1
DEBUG proxy : 866: processMediaMetadata() [('Tsingletrack__0_0_0__834607b567d453744b3d3db91683011d', u'Rolling in the Deep', 'audio/mpeg', u'http://10.0.0.17:10243/WMPNSSv3/Nonclassical.db.834607b567d453744b3d3db91683011d.m4a.mp3', 'track', 'track', ('', u'Adele', '', '', '', u'21', u'http://10.0.0.17:10243/wmp/Nonclassical.db.53.jpg', '', u'Adele', '', '', 229))]
After this gives an error message on Sonos, I noticed ffmpeg does seem to (have been) running:
pi@chickadee ~/LucyStorage/chickadee/sspy $ ps -f
UID PID PPID C STIME TTY TIME CMD
pi 22962 22961 0 13:08 pts/0 00:00:01 -bash
pi 23514 1 1 13:37 pts/0 00:00:08 python pycpoint.py -p -sSonospy=
pi 23610 23514 0 13:38 pts/0 00:00:00 [ffmpeg] <defunct>
pi 23746 22962 0 13:51 pts/0 00:00:00 ps -f