vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
6.72k stars 257 forks source link

handshake with text and then pipe binary output to ffmpeg #166

Open cleoag opened 1 year ago

cleoag commented 1 year ago

Hello! Thanx for the great tool!

I have a question. I have following scenario to do:

  1. open wss connection
  2. send 'hello' text to socket
  3. receive some text from socket
  4. send 'start' text to socket
  5. start receiving binary data from socket and need to pipe this to FFmpeg

I tried all possible combinations ) but no luck. one message to socket work ok, but two is not working (

is it possible to achieve at all?

vi commented 1 year ago

You can have full control over text and binary WebSocket message by using --binary-prefix, --text-prefix and --base64 options.

You'll need strip the output from binary prefixes and filter the output though something like perl -pe 'use MIME::Base64; $_=decode_base64($_);' with --base64 though, prior to feeding it to FFmpeg.

You there is a publicly available endpoint that I can try myself, I can construct a command line for you.