muammar / mkchromecast

Cast macOS and Linux Audio/Video to your Google Cast and Sonos Devices
http://mkchromecast.com
Other
2.22k stars 140 forks source link

mkchromecast from source quits immediately on macOS with ffmpeg backend #245

Open AuroraWright opened 5 years ago

AuroraWright commented 5 years ago

Using mkchromecast from source quits immediately (with exit value 0, no errors) on macOS 10.13.6 if used with the ffmpeg backend like so: bin/mkchromecast --encoder-backend ffmpeg

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


Here's the output of a --debug invocation:

bin/mkchromecast --encoder-backend ffmpeg --debug ALSA device name: None. Google Cast name: None. backends: ['node', 'ffmpeg'] ALSA device name: None. Google Cast name: None. backends: ['node', 'ffmpeg'] USER =aurora PATH =./bin:./nodejs/bin:/Users/aurora/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/bin:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/usr/local/sbin:/Users/aurora/.gem/bin:/usr/local/opt/qt/bin:/opt/devkitpro/devkitPPC/bin:/opt/devkitpro/devkitARM/bin:/opt/devkitpro/devkitA64/bin:/Applications/010 Editor.app/Contents/CmdLine Mkchromecast v0.3.9 :::audio::: chunk_size, frame_size, buffer_size: 64, 2048, 8192 Selected backend: ffmpeg Selected audio codec: mp3 Default bitrate used: 192k Default sample rate used: 44100Hz. :::audio::: command ['ffmpeg', '-f', 'avfoundation', '-i', ':Soundflower (2ch)', '-f', 'mp3', '-acodec', 'libmp3lame', '-ac', '2', '-ar', '44100', '-b:a', '192k', 'pipe:'] PID of main process: 26116 PID of streaming process: 26119

List of Devices Available in Network:

Index Types Friendly Name ===== ===== ============= 0 Gcast Aury

Casting to first device shown above! Select devices by using the -s flag.

Aury

def get_devices(self):

Information about Aury

DeviceStatus(friendly_name='Aury', model_name='Chromecast', manufacturer='Google Inc.', uuid=UUID('915899a5-e6f1-e9f7-7d3b-8e885490a7bb'), cast_type='cast')

Status of device Aury

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.cac', 'urn:x-cast:com.google.cast.broadcast', 'urn:x-cast:com.google.cast.media'], session_id='ca6a91a1-4106-4492-acf0-2ad4d28d0a0d', transport_id='ca6a91a1-4106-4492-acf0-2ad4d28d0a0d', status_text='Default Media Receiver')

Switching to SoundFlower... [Done] def play_cast(self): The IP of Aury is: 192.168.0.35 Your local IP is: 192.168.0.2

The media type string used is: audio/mpeg

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.cac', 'urn:x-cast:com.google.cast.broadcast', 'urn:x-cast:com.google.cast.media'], session_id='ca6a91a1-4106-4492-acf0-2ad4d28d0a0d', transport_id='ca6a91a1-4106-4492-acf0-2ad4d28d0a0d', status_text='Default Media Receiver')

Ctrl-C to kill the Application at any Time

AuroraWright commented 5 years ago

OK I fixed this I think (although I'm not sure if my solution is proper). I replaced https://github.com/muammar/mkchromecast/blob/master/bin/mkchromecast#L273-L277 with:

            signal.sigwait([signal.SIGINT, signal.SIGTERM])
            self.terminate_app()

For some reason it seems it receives 3 extraneous signals which unpause the process and make it terminate, so waiting for only those two signals fixes it.

muammar commented 5 years ago

You are right. That is a bug. Would you be willing to create a pull request for this? Thanks.