소수의 Google Chromecast 명령을 구현합니다. 기본 명령 외에 컴퓨터에서 미디어 파일을 개별적으로 또는 재생 목록으로 재생할 수도 있습니다. playlist
명령은 폴더의 모든 파일을 살펴보고 숫자별로 정렬하여 재생합니다. 또한 slideshow
명령을 사용하여 이미지 슬라이드쇼를 재생할 수도 있습니다.
다음 형식으로 로컬 미디어 파일이나 인터넷에서 호스팅되는 파일을 Chromecast에 로드할 수 있습니다.
Supported Media formats:
- MP3
- AVI
- MKV
- MP4
- WebM
- FLAC
- WAV
알 수 없는 비디오 파일이 발견되면 ffmpeg
사용하여 이를 MP4로 트랜스코딩하고 Chromecast로 스트리밍합니다.
미디어 파일을 Cast 장치로 스트리밍하는 http 서버를 생성하여 로컬 미디어 파일을 재생할 수 있습니다.
DNS 멀티캐스트는 Chromecast 및 Google Home 장치를 확인하는 데 사용됩니다.
전송 DNS 항목도 캐시됩니다. 즉, 기기 이름 -n <name>
또는 기기 uuid -u <uuid>
통과하면 결과가 캐시되고 Chromecast 기기에 즉시 연결됩니다. .
https://github.com/vishen/go-chromecast/releases
tar -xzf go-chromecast.tar.gz
사용하여 압축을 풀고 sudo install ./go-chromecast /usr/bin/
사용하여 설치합니다. $ go install github.com/vishen/go-chromecast@latest
$ go get -u github.com/vishen/go-chromecast
Control your Google Chromecast or Google Home Mini from the
command line.
Usage:
go-chromecast [flags]
go-chromecast [command]
Available Commands:
help Help about any command
httpserver Start the HTTP server
load Load and play media on the chromecast
load-app Load and play content on a chromecast app
ls List devices
mute Mute the chromecast
next Play the next available media
pause Pause the currently playing media on the chromecast
playlist Load and play media on the chromecast
previous Play the previous available media
restart Restart the currently playing media
rewind Rewind by seconds the currently playing media
seek Seek by seconds into the currently playing media
seek-to Seek to the <timestamp_in_seconds> in the currently playing media
slideshow Play a slideshow of photos
status Current chromecast status
stop Stop casting
transcode Transcode and play media on the chromecast
tts text-to-speech
ui Run the UI
unmute Unmute the chromecast
unpause Unpause the currently playing media on the chromecast
volume Get or set volume
watch Watch all events sent from a chromecast device
Flags:
-a, --addr string Address of the chromecast device
-v, --debug debug logging
-d, --device string chromecast device, ie: 'Chromecast' or 'Google Home Mini'
-n, --device-name string chromecast device name
--disable-cache disable the cache
--dns-timeout int Multicast DNS timeout in seconds when searching for chromecast DNS entries (default 3)
--first Use first cast device found
-h, --help help for go-chromecast
-i, --iface string Network interface to use when looking for a local address to use for the http server or for use with multicast dns discovery
-p, --port string Port of the chromecast device if 'addr' is specified (default "8009")
-u, --uuid string chromecast device uuid
--verbose verbose logging
--version display command version
--with-ui run with a UI
Use "go-chromecast [command] --help" for more information about a command.
# View available cast devices.
$ go-chromecast ls
Found 2 cast devices
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
# Status of a cast device.
$ go-chromecast status
Found 2 cast dns entries, select one:
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
Enter selection: 1
Idle (Backdrop), volume=1.00 muted=false
# Specify a cast device name.
$ go-chromecast status -n "Living Room Speaker"
Idle, volume=0.17 muted=false
# Specify a cast device by ip address.
$ go-chromecast status -a 192.168.0.52
Idle, volume=0.17 muted=false
# Specify a cast device uuid.
$ go-chromecast status -u b87d86bed423a6feb8b91a7d2778b55c
Idle (Default Media Receiver), volume=0.17 muted=false
# Play a file hosted on the internet
$ go-chromecast load https://example.com/path/to/media.mp4
# Load a local media file (can play both audio and video).
$ go-chromecast load ~/Downloads/SampleAudio_0.4mb.mp3
Found 2 cast dns entries, select one:
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
Enter selection: 2
# Status of cast device running an audio file.
$ go-chromecast status
Found 2 cast dns entries, select one:
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="Default Media Receiver" uuid="b87d86bed423a6feb8b91a7d2778b55c"
Enter selection: 2
Default Media Receiver (PLAYING), unknown, time remaining=8s/28s, volume=1.00, muted=false
# Play a playlist of media files.
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker"
Attemping to play the following media:
- /home/jonathan/playlist_test/SampleAudio_0.4mb.mp3
- /home/jonathan/playlist_test/sample_1.mp3
# Select where to start a playlist from.
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --select
Will play the following items, select where to start from:
1) /home/jonathan/playlist_test/SampleAudio_0.4mb.mp3: last played "2018-11-25 11:17:25 +0000 GMT"
2) /home/jonathan/playlist_test/sample_1.mp3: last played "2018-11-25 11:17:28 +0000 GMT"
Enter selection: 2
Attemping to play the following media:
- /home/jonathan/playlist_test/sample_1.mp3
# Start a playlist from the start, ignoring if you have previously played that playlist.
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --continue=false
# Start a playlist and launch the terminal ui
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --with-ui
# Start a slideshow of images
$ go-chromecast slideshow slideshow_images/*.png --repeat=false
# Pause the playing media.
$ go-chromecast pause
# Continue playing the currently playing media.
$ go-chromecast play
# Play the next item in a playlist.
$ go-chromecast next
# Play the previous item in a playlist.
$ go-chromecast previous
# Rewind the currently playing media by x seconds.
$ go-chromecast rewind 30
# Go forward in the currently playing media by x seconds.
$ go-chromecast seek 30
# Get the current volume level
$ go-chromecast volume
# Set the volume level
$ go-chromecast volume 0.55
# View what messages a cast device is sending out.
$ go-chromecast watch
# Use a terminal UI to interact with the cast device
$ go-chromecast ui
다음 컨트롤을 지원하는 기본 터미널 사용자 인터페이스가 제공됩니다.
다음과 같은 방법으로 실행할 수 있습니다.
이미 재생 중인 Chromecast를 원격으로 제어하려면 다음 단계를 따르세요.
$ go-chromecast ui
playlist
명령과 함께 UI를 사용합니다(위에서 자세히 설명).
$ go-chromecast --with-ui playlist /path/to/directory
load
명령과 함께 UI를 사용합니다(위에 자세히 설명되어 있음).
$ go-chromecast --with-ui load /path/to/file.flac
다음 API가 있는 HTTP API 서버가 제공됩니다.
GET /devices?interface=<network_interface>&wait=<seconds>
POST /connect?uuid=<device_uuid>&addr=<device_addr>&port=<device_port>&interface=<network_interface>&wait=<seconds>
POST /disconnect?uuid=<device_uuid>&stop=<bool>
POST /disconnect-all?stop=<bool>
POST /status?uuid=<device_uuid>
POST /pause?uuid=<device_uuid>
POST /unpause?uuid=<device_uuid>
POST /mute?uuid=<device_uuid>
POST /unmute?uuid=<device_uuid>
POST /stop?uuid=<device_uuid>
GET /volume?uuid=<device_uuid>
POST /volume?uuid=<device_uuid>&volume=<float>
POST /rewind?uuid=<device_uuid>&seconds=<int>
POST /seek?uuid=<device_uuid>&seconds=<int>
POST /seek-to?uuid=<device_uuid>&seconds=<float>
POST /load?uuid=<device_uuid>&path=<filepath_or_url>&content_type=<string>
$ go-chromecast httpserver
Start the HTTP server which provides an HTTP
api to control chromecast devices on a network.
Usage:
go-chromecast httpserver [flags]
Flags:
-h, --help help for httpserver
--http-addr string addr for the http server to listen on (default "0.0.0.0")
--http-port string port for the http server to listen on (default "8011")
미디어 항목을 재생 목록으로 재생하는 기능이 지원됩니다.
재생 목록에서 재생하는 경우 --select
플래그를 통해 전달할 수 있으며 이를 통해 재생을 시작할 미디어를 선택할 수 있습니다. 이는 일부 미디어를 이미 재생했지만 아직 재생하지 않은 미디어부터 시작하려는 경우에 유용합니다.
재생된 미디어는 캐시에 보관되므로 재생 목록의 미디어를 재생하는 경우 최근에 재생한 미디어 파일이 무엇인지 확인하고 재생 목록의 다음 미디어 파일을 재생합니다. --continue=false
전달할 수 있으며 이렇게 하면 재생 목록이 처음부터 시작됩니다.
장치가 보내는 내용을 보려면 장치에서 전송되는 protobuf 메시지를 watch
수 있습니다.
$ go-chromecast watch
실험적인 텍스트 음성 변환 지원이 추가되었습니다. 이는 Google Cloud의 Text-to-Speech를 사용하여 텍스트를 mp3 오디오 파일로 변환한 다음 기기로 스트리밍합니다.
텍스트 음성 변환 API는 https://console.cloud.google.com/flows/enableapi?apiid=texttospeech.googleapis.com을 활성화해야 하며 Google 서비스 계정은 https://console.cloud.google이 필요합니다. com/apis/credentials/serviceaccountkey
$ go-chromecast tts <message_to_say> --google-service-account=/path/to/service/account.json
en-US 언어가 아닌 경우
$ go-chromecast tts <message_to_say> --google-service-account=/path/to/service/account.json
--voice-name en-US-Wavenet-G --speaking-rate 1.05 --pitch 0.9
사용 가능한 음성 목록(음성 이름)은 여기에서 확인할 수 있습니다: https://cloud.google.com/text-to-speech/
SSML 사용
$ go-chromecast tts '<speak>Hello<break time="500ms"/>world.</speak>'
--google-service-account=/path/to/service/account.json
--ssml