Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg playback not working on MacOS #40

Closed
PePeHa opened this issue Jan 18, 2017 · 42 comments
Closed

ffmpeg playback not working on MacOS #40

PePeHa opened this issue Jan 18, 2017 · 42 comments

Comments

@PePeHa
Copy link

PePeHa commented Jan 18, 2017

i installed from your mac .dmg image, latest version 0.3.6, and in node, playback seems to be working (up to 320kbps, in mp3 - 500kbps mp3 not working either by the way), but if i select ffmpeg (and yes, i have installed full package with options as you described, via brew), MKCHROMECAST is not working, regardless of settings, mp3, flac, wav, anything - just no sound at all. what could be wrong ?

PS - i am using MacOS Sierra

@PePeHa
Copy link
Author

PePeHa commented Jan 20, 2017

Muammar, any idea ?

@muammar
Copy link
Owner

muammar commented Jan 21, 2017

Muammar, any idea ?

Can you try using the git repository with the --debug flag to see if your ffmpeg is detected, please?.

@PePeHa
Copy link
Author

PePeHa commented Jan 24, 2017

Hi Muammar. I installed the git, flask and everything. running in node.js it works, but again not working in ffmpeg. as per your request, i ran the following command in Terminal

python mkchromecast.py --encoder-backend ffmpeg --debug

and this was response ....

('ALSA device name:', None)
('Google Cast name:', None)
('backends: ', ['node', 'ffmpeg'])
The segment time has to be an integer number
Set to default of 2 seconds
('ALSA device name:', None)
('Google Cast name:', None)
('backends: ', ['node', 'ffmpeg'])
The segment time has to be an integer number
Set to default of 2 seconds
USER =pepeha
PATH =./bin:./nodejs/bin:/Users/pepeha/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/bin:/usr/games:/opt/local/bin:/opt/local/sbin:/Users/pepeha/.rvm/gems/ruby-2.4.0/bin:/Users/pepeha/.rvm/gems/ruby-2.4.0@global/bin:/Users/pepeha/.rvm/rubies/ruby-2.4.0/bin:/opt/local/bin:/opt/local/sbin:/Users/pepeha/.npm-packages/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/pepeha/.rvm/bin
mkchromecast v0.3.7
:::cast::: sockets method 192.168.1.8
Starting local streaming server
[Done]
(':::audio::: chunk_size: ', 1024)
Selected backend: ffmpeg
Selected audio codec: mp3
Default bitrate used: 192k
Default sample rate used: 44100Hz
:::audio::: command ['ffmpeg', '-f', 'avfoundation', '-audio_device_index', '0', '-i', '', '-acodec', 'libmp3lame', '-f', 'segment', '-segment_time', '2', '-f', 'mp3', '-ac', '2', '-ar', '44100', '-b:a', '192k', 'pipe:']
PID of main process: 9514
PID of streaming process: 9517

  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    Exception in thread zeroconf-Engine:
    Traceback (most recent call last):
    File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
    File "/usr/local/lib/python2.7/site-packages/zeroconf.py", line 946, in run
    rr, wr, er = select.select(rs, [], [], self.timeout)
    error: (9, 'Bad file descriptor')

self.cclist [u'ChromecastAudio1000']
if len(self.cclist) != 0 and self.select_cc == False:

List of Google Cast devices available in your network:

Index Friendly name
===== =============
0 ChromecastAudio1000

We will cast to first device in the list above!

ChromecastAudio1000

def get_cc(self):
Exception in thread zeroconf-Engine:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/site-packages/zeroconf.py", line 946, in run
rr, wr, er = select.select(rs, [], [], self.timeout)
error: (9, 'Bad file descriptor')

Information about ChromecastAudio1000

DeviceStatus(friendly_name=u'ChromecastAudio1000', model_name=u'Chromecast Audio', manufacturer=u'Google Inc.', api_version=(1, 0), uuid=UUID('01006qc7-402b-bgcd-14g8-111190e7aef4'), cast_type='audio')

Status of device ChromecastAudio1000

CastStatus(is_active_input=None, is_stand_by=None, volume_level=0.5199999809265137, volume_muted=False, app_id=None, display_name=None, namespaces=[], session_id=None, transport_id=None, status_text='')

Switching to soundflower...
[Done]
def play_cast(self):
The IP of ChromecastAudio1000 is: 192.168.1.5
Your local IP is: 192.168.1.8

The media type string used is: audio/mpeg

Cast media controller status

CastStatus(is_active_input=None, is_stand_by=None, volume_level=0.5199999809265137, volume_muted=False, app_id=u'CC1ED846', display_name=u'Default Media Receiver', namespaces=[u'urn:x-cast:com.google.cast.broadcast', u'urn:x-cast:com.google.cast.media'], session_id=u'5e1601ef-12af-1e35-1e60-0a1a7fd3defd', transport_id=u'5e1601ef-12af-1e35-1e60-0a1a7fd3defd', status_text=u'Ready To Cast')

Ctrl-C to kill the application at any time

ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

@PePeHa
Copy link
Author

PePeHa commented Jan 25, 2017

any update on this issue, Muammar ?

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

any update on this issue, Muammar ?

I have been unable to reproduce this. As of writing this comment, I am casting from macOS with ffmpeg:

Last login: Sun Jan 29 12:46:27 on ttys003

muammar@zarathustra ~/github/mkchromecast [devel]
± % uname -a                                                                                                                                           !10118
Darwin zarathustra.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

muammar@zarathustra ~/github/mkchromecast [devel]
± % python3 mkchromecast.py --encoder-backend ffmpeg -c ogg -s                                                                                         !10116
The segment time has to be an integer number
Set to default of 2 seconds
The segment time has to be an integer number
Set to default of 2 seconds
mkchromecast v0.3.7
Starting local streaming server
[Done]
Selected backend: ffmpeg
Selected audio codec: ogg
Default bitrate used: 192k
Default sample rate used: 44100Hz
PID of main process: 8156
PID of streaming process: 8162
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

List of Google Cast devices available in your network:
------------------------------------------------------

Index   Friendly name
=====   =============
0       Monsi TV
1       CCA

Please, select the Index of the Google Cast device that you want to use:
0

Casting to: Monsi TV


Information about  Monsi TV

DeviceStatus(friendly_name='Monsi TV', model_name='Chromecast', manufacturer='Google Inc.', api_version=(1, 0), uuid=UUID('0b7cfbc6-ce97-dd97-b478-dd14604e5fed'), cast_type='cast')

Status of device  Monsi TV

CastStatus(is_active_input=False, is_stand_by=True, volume_level=1.0, volume_muted=False, app_id='E8C28D3C', display_name='Backdrop', namespaces=['urn:x-cast:com.google.cast.sse'], session_id='603535ee-5f37-4098-93ef-88e92e90b929', transport_id='603535ee-5f37-4098-93ef-88e92e90b929', status_text='')

Switching to soundflower...
[Done]
The IP of Monsi TV is: 192.168.1.173
Your local IP is: 192.168.1.154

The media type string used is: audio/ogg

Cast media controller status

CastStatus(is_active_input=False, is_stand_by=True, volume_level=1.0, volume_muted=False, app_id='CC1AD845', display_name='Default Media Receiver', namespaces=['urn:x-cast:com.google.cast.broadcast', 'urn:x-cast:com.google.cast.media'], session_id='375c425a-86ca-4ddc-a338-5403b49babdd', transport_id='375c425a-86ca-4ddc-a338-5403b49babdd', status_text='Ready To Cast')


Ctrl-C to kill the application at any time

192.168.1.173 - - [29/Jan/2017 12:44:26] "GET /stream HTTP/1.1" 200 -

You can try the following:

  1. Uninstall soundflower.
  2. Reboot.
  3. Install soundflower. See this issue here.
  4. Try again to cast with mkchromecast.

Can you let me know if it works?.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

dear Muammar. i re-installed Soundflower, nice clean re-install, proper removal, reboot and reinstall. however, still no sound via ffmpeg. unfortunately, i can't get it to work on MacOS Sierra, neither from Terminal nor from .dmg package.

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

dear Muammar. i re-installed Soundflower, nice clean re-install, proper removal, reboot and reinstall. however, still no sound via ffmpeg. unfortunately, i can't get it to work on MacOS Sierra, neither from Terminal nor from .dmg package.

Arrg. I have no idea at this point on what's going on in your case. When using node, you have no problem, isn't it?. Can you confirm that?.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

thnks Muammar. dont worry about it, thnx for your help. yes, when using node.js, it works. only with ffmpeg no sound coming out at all. i was interested in ffmpeg, to stream hi-res audio to chromecast (Tidal, 44.1kHz / 88.2kHhz and 96kHz, both 16-bit as well as 24-bit, using wav or flac via ffmpeg/Soundflower)

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

PS - i would even be more than happy to pay for a working solution to get Mac Desktop audio to Chromecast Audio at high sampling-rates and bit-depth. all commercial solutions dont offer this for Mac (e.g. Airfoil only does 16-bit / 44.1kHz, as it is Airplay-protocol-based). as Tidal is now offering MQA file-streaming, there is obviously a large market for streaming un-folded MQA at 24-bit / 44.1 / 48 / 88.2 and 96 kHz to Chromecast, given Tidal only offers Chromecast support on mobile apps, and there it only goes up to 16-bit / 44.1kHz. so there is huge market for people looking to stream software-unfolded MQA from Tidal desktop App to Chromecast Audio. unfortunately there is nothing available to do this, right now.

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

thnks Muammar. dont worry about it, thnx for your help. yes, when using node.js, it works. only with ffmpeg no sound coming out at all. i was interested in ffmpeg, to stream hi-res audio to chromecast (Tidal, 44.1kHz / 88.2kHhz and 96kHz, both 16-bit as well as 24-bit, using wav or flac via ffmpeg/Soundflower)

Yes, I understand. Try the following:

  1. Start casting using ffmpeg.

  2. Open a new terminal and execute this:

ffmpeg -f avfoundation -audio_device_index  0 -i " " -f wav  output.wav
  1. Stop casting, and open output.wav. Is it recording/playing anything?.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

i get an error: "[AVFoundation input device @ 0x7ff8c740f5c0] Video device not found"

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

ffmpeg -f avfoundation -list_devices true -i ""

what's the list you get when executing the above?

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

ffmpeg -f avfoundation -list_devices true -i ""
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[AVFoundation input device @ 0x7ff46bc00dc0] AVFoundation video devices:
[AVFoundation input device @ 0x7ff46bc00dc0] [0] FaceTime HD-camera (beeldscherm)
[AVFoundation input device @ 0x7ff46bc00dc0] [1] FaceTime-camera (ingebouwd)
[AVFoundation input device @ 0x7ff46bc00dc0] [2] Capture screen 0
[AVFoundation input device @ 0x7ff46bc00dc0] AVFoundation audio devices:
[AVFoundation input device @ 0x7ff46bc00dc0] [0] Soundflower (64ch)
[AVFoundation input device @ 0x7ff46bc00dc0] [1] Built-in Microphone
[AVFoundation input device @ 0x7ff46bc00dc0] [2] Soundflower (2ch)
[AVFoundation input device @ 0x7ff46bc00dc0] [3] Display Audio
: Input/output error

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

I think in your case the command should be:

ffmpeg -f avfoundation -audio_device_index  2 -i " " -f wav  output.wav

Because we want to capture this:

[AVFoundation input device @ 0x7ff46bc00dc0] [2] Soundflower (2ch)

Try again and tell me if it records something.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

i still get the same error - "[AVFoundation input device @ 0x7fe58fd02560] Video device not found
: Input/output error"

also noticed that the device address is changing everytime i run an ffmpeg command, but maybe that's normal, i dont know

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

Let's do things in a cleaner way. Without casting anything (just play anything you like in your browser or media player), open the sound preferences of your macbook pro and change input and output to soundflower (2ch):

http://cdn.osxdaily.com/wp-content/uploads/2013/02/redirect-system-audio-input-from-soundflower.jpg

Then, list your devices with:

ffmpeg -f avfoundation -list_devices true -i ""

And use the index of your soundflower here:

ffmpeg -f avfoundation -audio_device_index  MY_SOUNDFLOWER_INDEX -i " " -f wav  output.wav

I am suspecting that the default device I have set in the code is not working for you. What we need is to confirm that it is the case, so then, I can implement a solution for your problem.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

i tried, but still not working ! maybe also important to note, is that there is more than 1 device with same index !!! the Facetime camera's and (i don't know what this is, but still) Capture Screen, also have indices from 0 to 2, so maybe choosing 2 (as i did per your request), point to whatever Capture screen is, and not to Soundflower ?

[AVFoundation input device @ 0x7f87e5500300] AVFoundation video devices:
[AVFoundation input device @ 0x7f87e5500300] [0] FaceTime HD-camera (beeldscherm)
[AVFoundation input device @ 0x7f87e5500300] [1] FaceTime-camera (ingebouwd)
[AVFoundation input device @ 0x7f87e5500300] [2] Capture screen 0
[AVFoundation input device @ 0x7f87e5500300] AVFoundation audio devices:
[AVFoundation input device @ 0x7f87e5500300] [0] Soundflower (64ch)
[AVFoundation input device @ 0x7f87e5500300] [1] Built-in Microphone
[AVFoundation input device @ 0x7f87e5500300] [2] Soundflower (2ch)
[AVFoundation input device @ 0x7f87e5500300] [3] Display Audio

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

i tried, but still not working ! maybe also important to note, is that there is more than 1 device with same index !!! the Facetime camera's and (i don't know what this is, but still) Capture Screen, also have indices from 0 to 2, so maybe choosing 2 (as i did per your request), point to whatever Capture screen is, and not to Soundflower ?

Yes, I think you are correct.

Another way would be this one:

ffmpeg -f avfoundation -i ":MY_SOUNDFLOWER_INDEX " -f wav  output.wav

Note that there is an appended : that's to tell ffmpeg that we want to set the index of audio devices and nothing for the video. Hopefully that works?.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

yes, it worked ! so what is that capture screen device that i have at same device number as soundflower, namely both on 2 ? i don't know what it is ! :-) and how do we get mkchromecast to work properly now we know this ?

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

Holy s***! finally. I think this is very easy to fix. The thing is that the order of your devices is different. I may just try setting the device explicitly using its name?.

Can you try this and tell me if it records something?

ffmpeg -f avfoundation -i ":Soundflower (2ch)" -f wav  output.wav

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

yes, it worked also with referring to soundflower explicitly.

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

yes, it worked also with referring to soundflower explicitly.

Thank you for your patience and feedback. Let me change the code in devel and I will write you back in some minutes.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

ok, great teamwork, Muammar !!! thanks so much, i appreciate your work !

muammar added a commit that referenced this issue Jan 29, 2017
@muammar
Copy link
Owner

muammar commented Jan 29, 2017

ok, great teamwork, Muammar !!! thanks so much, i appreciate your work !

Thank you :). Hopefully this commit 23fab81 solves the problem. Can you test it, please?. You need to checkout in devel and pull the changes.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

ok, how do i install the development version of mkchromecast from terminal ?

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

If I remember correctly, you had installed git and you had also downloaded the git repository. So you will need to get inside the mkchromecast directory you cloned and do the following:

git pull
git fetch
git checkout devel

If you deleted the repository you cloned, you can from scratch do the following:

git clone https://github.com/muammar/mkchromecast
cd mkchromecast
git fetch
git checkout devel

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

ok, didn't delete directory :-) so did first 3 command in directory, and tried

  1. python mkchromecast.py : check, worked (as previously, using node);
  2. python mkchromecast.py --encoder-backend ffmpeg : still not working, unfortunately

@muammar
Copy link
Owner

muammar commented Jan 29, 2017

Can you do a git log and copy/paste the first commit you see in the list, please?.

@PePeHa
Copy link
Author

PePeHa commented Jan 29, 2017

hmmm, yeah, your change is showing up, so git install devel went ok, see below. so there must be something else going on ...

commit 23fab81
Author: Muammar El Khatib muammarelkhatib@gmail.com
Date: Sun Jan 29 17:45:39 2017 -0500

This commit is related to #40. Device names are not ordered the same in
different systems.

@muammar
Copy link
Owner

muammar commented Jan 30, 2017

@PePeHa I wasn't at home. And you are right, it wasn't working. Now I have tested it. Do a git pull and try again. The error was this -> e3c3627.

@PePeHa
Copy link
Author

PePeHa commented Jan 30, 2017

thanks Muammar ! i had gone to sleep :-) but just tried, and it works ! great work, Muammar !
just one more thing i wondered - does mkchromecast make some cache file somewhere on disk before sending out to chromecast, and where can i find it ? also, i wondered if ffmpeg is using lossless encoding from soundflower input, so is it using libx264 and outputting into lossless wav or flac stream / file ? if there is no intermediate caching file made, how can i check the details around the encoding procedure, bit-depth, sample rates etc. from terminal ? again, thanks Muammar, this is a great project. streaming Tidal un-folded MQA from desktop to Chromecast via mkchromecast !

@muammar
Copy link
Owner

muammar commented Jan 30, 2017

thanks Muammar ! i had gone to sleep :-) but just tried, and it works ! great work, Muammar !

I am glad to know it works for you now!.

just one more thing i wondered - does mkchromecast make some cache file somewhere on disk before sending out to chromecast, and where can i find it ?

No cache file here. Everything is piped to the webserver.

also, i wondered if ffmpeg is using lossless encoding from soundflower input, so is it using libx264 and outputting into lossless wav or flac stream / file ? if there is no intermediate caching file made, how can i check the details around the encoding procedure, bit-depth, sample rates etc. from terminal ? again,

What I do is to take the redirected input from soundflower (note that soundflower has a maximum of 48khz sample rate https://github.com/muammar/mkchromecast/wiki/Sample-rates). If I understand correctly soundflower maxium bit-depth is 32bits?. You can check more details in ffmpeg if you pass the --debug flag.

thanks Muammar, this is a great project. streaming Tidal un-folded MQA from desktop to Chromecast via mkchromecast !

You are welcome, and thanks for reporting and making better the app. I am interested on understanding if the bit-depth is sent as I think.

@PePeHa
Copy link
Author

PePeHa commented Jan 30, 2017

i don't really understand - if i go to audio/midi settings, i can choose the sample rates for SoundFlower (both input as well as output) to 44.1 / 48 / 88.2 / 96 / 176.4 and 192 kHz, always at 32-bit. so that leaves 3 questions:

  1. how is it that your soundflower install only goes up to 48kHz, where mine goes up to 192kHz ?;
  2. if you say, you take the redirected soundflower input, you mean no re-sampling & re-encoding is applied, you just take the raw stream and send that out to whatever one chooses, e.g. wav, flac etc. ?
  3. in relation to (2), what happens specifically if Tidal sends out 88.2kHz to SoundFlower , as i can currently not choose 88.2kHz in the mkchromecast Tray - ffmpeg settings. is it re-sampled to 96kHz en re-encoded, and if so, by which method ?

lastly, i checked, launching with --debug parameter, and found something interesting (see full output below); here a summary:

  • output bit-depth seems to be 24-bit, which is all we need, so this seems fine;
  • input stream sample rate is 88.2kHz, streaming at 5644 kb/s;
  • output streams at only approximately half of the input bit-rate (but looking more specifically, it also mentions 128kbps and the used codec) - i also looked at Network Activity via Activity Monitor, and it show Python sending out to network effectively only approx. 300KB / second to the Chromecast Audio;
  • capturing soundflower & encoding and chromecasting does not seem to be lossless ! maybe mkchromecast is not choosing to use the proper encoder for lossless capture;
  • i would really like to get lossless capture and transfer to Chromecast Audio working :-)

Input #0, avfoundation, from ':Soundflower (2ch)':
Duration: N/A, start: 72753.491780, bitrate: 5644 kb/s
Stream #0:0: Audio: pcm_f32le, 88200 Hz, stereo, flt, 5644 kb/s
[flac @ 0x7fad6284a000] encoding as 24 bits-per-sample
Output #0, flac, to 'pipe:':
Metadata:
encoder : Lavf57.56.100
Stream #0:0: Audio: flac, 96000 Hz, stereo, s32 (24 bit), 128 kb/s
Metadata:
encoder : Lavc57.64.101 flac
Stream mapping:
Stream #0:0 -> #0:0 (pcm_f32le (native) -> flac (native))
Press [q] to stop, [?] for help
192.168.1.5 - - [30/Jan/2017 18:59:50] "GET /stream HTTP/1.1" 200 -
size= 74299kB time=00:03:47.78 bitrate=2672.1kbits/s speed= 1x


PS - i checked before, using JRiver to send audio to Chromecast Audio, and maximum quality it accepts without troubles is 192kHz sampling rate at 24-bit depth, both PCM / wav as well as flac files

muammar added a commit that referenced this issue Jan 31, 2017
…devel

* 'devel' of https://github.com/muammar/mkchromecast:
  Updated README>
  Quotations are not needed for setting the name of devices.
  This commit is related to #40. Device names are not ordered the same in different systems.
@muammar
Copy link
Owner

muammar commented Jan 31, 2017

i don't really understand - if i go to audio/midi settings, i can choose the sample rates for SoundFlower (both input as well as output) to 44.1 / 48 / 88.2 / 96 / 176.4 and 192 kHz, always at 32-bit. so that leaves 3 questions:

how is it that your soundflower install only goes up to 48kHz, where mine goes up to 192kHz ?;

I have just checked again. I read elsewhere that last year the chromecast audio was resampling everything to 48khz. Now I believe it is not the case. That's why I was just talking about 48khz. I have just checked my laptop and I have the same options as you.

if you say, you take the redirected soundflower input, you mean no re-sampling & re-encoding is applied, you just take the raw stream and send that out to whatever one chooses, e.g. wav, flac etc. ?

Yes, look at this line of code the command is taking the Soundflower input and then the resampling (or whatever is set) is done in the output part.

in relation to (2), what happens specifically if Tidal sends out 88.2kHz to SoundFlower , as i can currently not choose 88.2kHz in the mkchromecast Tray - ffmpeg settings. is it re-sampled to 96kHz en re-encoded, and if so, by which method ?

Yes, that's what would happen. In such a case, I believe I should add 88.2kHz as an option. The method is the method implemented in ffmpeg. I have no idea about those details to be honest.

lastly, i checked, launching with --debug parameter, and found something interesting (see full output below); here a summary:

output bit-depth seems to be 24-bit, which is all we need, so this seems fine;
input stream sample rate is 88.2kHz, streaming at 5644 kb/s;
output streams at only approximately half of the input bit-rate (but looking more specifically, it also mentions 128kbps and the used codec) - i also looked at Network Activity via Activity Monitor, and it show Python sending out to network effectively only approx. 300KB / second to the Chromecast Audio;

capturing soundflower & encoding and chromecasting does not seem to be lossless ! maybe mkchromecast is not choosing to use the proper encoder for lossless capture;
i would really like to get lossless capture and transfer to Chromecast Audio working :-)

I think that the output of the ffmpeg has to be modified to accomplish this. If you don't mind to test the changes I can try to fix it :).

@muammar
Copy link
Owner

muammar commented Jan 31, 2017

I think that WAV code is fine? Problem seems to be only with flac. I agree with you on that one.

ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, avfoundation, from ':Soundflower (2ch)':
  Duration: N/A, start: 1427.036615, bitrate: 6144 kb/s
    Stream #0:0: Audio: pcm_f32le, 96000 Hz, stereo, flt, 6144 kb/s
Output #0, wav, to 'pipe:':
  Metadata:
    ISFT            : Lavf57.56.100
    Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 96000 Hz, stereo, s32, 4608 kb/s
    Metadata:
      encoder         : Lavc57.64.101 pcm_s24le
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_f32le (native) -> pcm_s24le (native))

@muammar
Copy link
Owner

muammar commented Jan 31, 2017

I have modified the FLAC part to support the bitrate:

python3 mkchromecast.py --debug --encoder-backend ffmpeg -c flac -b 3000 --sample-rate 96000

Now the output looks like:

Ctrl-C to kill the application at any time

ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.2.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, avfoundation, from ':Soundflower (2ch)':
  Duration: N/A, start: 4566.855990, bitrate: 6144 kb/s
    Stream #0:0: Audio: pcm_f32le, 96000 Hz, stereo, flt, 6144 kb/s
[flac @ 0x7f86b0067a00] encoding as 24 bits-per-sample
Output #0, flac, to 'pipe:':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #0:0: Audio: flac, 96000 Hz, stereo, s32 (24 bit), 3000 kb/s
    Metadata:
      encoder         : Lavc57.64.101 flac
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_f32le (native) -> flac (native))

Let me know if this is ok.

@PePeHa
Copy link
Author

PePeHa commented Feb 1, 2017

Great work Muammar - both wav as well as flac encoding now streaming at full bit-rate !

@PePeHa
Copy link
Author

PePeHa commented Feb 1, 2017

such incredible value-for-money - streaming un-folded MQA at 24-bit / 88.2 / 96kHz with Chromecast Audio for $35 dollar in combination with mkchromecast !

@muammar
Copy link
Owner

muammar commented Feb 1, 2017

@PePeHa Nice! I will close this bug report. But before doing so, do you think I should add 88.2kHz to the system tray options?

@PePeHa
Copy link
Author

PePeHa commented Feb 1, 2017

if it's not too much extra work for you, i would add 88.2 as well as 176.4kHz. better would even be, if mkchromecast could automatically take over the Soundflower sample rate settings. in that latter case, Tidal could exclusively force the appropriate sample rate upon Soundflower, depending on the source file (so to 44.1, 48, 88.2 or 96kHz) and mkchromecast would automatically switch its ffmpeg sample rate accordingly. at the moment, i noticed that if sample rate is changed in Soundflower after mkchromecast is launched (so mkchromecast already running), for example when changing to a track with a different sample rate, i have to re-connect Chromecast from the mkchromecast panel or otherwise there is no sound any longer. would be nice if mkchromecast could do this automatically. if it would be easy to implement, that would be a very nice feature, but if it is too complex, i can live with this limitation and am more than happy with the way it works currently !!! thanks for all this great work Muammar ! i say, Nobel Prize for Music Chromecast Audio for you !!!

@muammar
Copy link
Owner

muammar commented Feb 1, 2017 via email

@PePeHa
Copy link
Author

PePeHa commented Feb 1, 2017

glad you LOL'd - Stockholm is waiting for you ;-)

muammar added a commit that referenced this issue Feb 1, 2017
* master: (96 commits)
  FLAC does support bitrate. This is related to #40.
  Fixed aac codec in macOS.
  Updated brew command for macOS.
  Updated README>
  Quotations are not needed for setting the name of devices.
  This commit is related to #40. Device names are not ordered the same in different systems.
  Qt 5.8.0.
  This commit is another attempt to issues #41, and #43.
  - Added support to 192000Hz sampling rate support. This commit closes   #39. - Fixed a minimal problem with size of preferences pane.
  Update README.md
  - Updated to node 7.4.0. - Updated ChangeLog.
  Updated Makefile.
  Update README.md
  Updated README.
  A lambda function that passes clicked_item as an argument to the self.clicked_cc() method was added to cast_list(). This last method, sets the correct index and name of the chromecast to be used by self.play_cast() when a user click on the menu item. This issue was reported by Térence Clastres.
  --resolution flag is now working.
  First steps towards `--resolution` flag.
  Catching TypeError introduced by pull #38.
  - Fixed some if statements.
  - Some cleaning in the code. - Renamed flag from -f to -i.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants