Pitahaya
home | info | audio | audiodesktop
Live streaming audio from the desktop
If you want to live stream audio playing on your desktop rather than from a file, there are a few different ways to do this..
Encoding
Requires: ffmpeg, node.js
If running windows, install cygwin to run the commands on this page.

Windows Requires: Once installed, run the command ffmpeg -list_devices true -f dshow -i dummy and ensure the device virtual-audio-capturer appears.  

To live stream, run the following command, replacing abcd-efgh-ijkl-mnop-qrst with your youtube live streaming key found on your live dashboard page.

ffmpeg -nostats -loglevel 0 \
-f dshow \
-i audio="virtual-audio-capturer" \
-f s16le -acodec pcm_s16le -ar 44100 -ac 2 - \
| ffmpeg -nostats -loglevel 0 \
-f s16le -ar 44100 -ac 2 -i - \
-acodec libmp3lame \
-b:a 128k -f mp3 - \
| pitahaya --tx mp3 \
| ffmpeg -nostats -loglevel 0 \
-f lavfi \
-i anullsrc=channel_layout=stereo:sample_rate=11025 \
-framerate 8 -f rawvideo \
-pixel_format rgba -video_size 640x360 \
-i - -shortest -c:v libx264 \
-crf 32 -pix_fmt yuv420p -preset slow \
-r 8 -g 16 -f flv \
"rtmp://a.rtmp.youtube.com/live2/abcd-efgh-ijkl-mnop-qrst"

Mac/Linux Please refer to the ffmpeg documentation page for capturing audio recordings. The -f dshow -i audio="virtual-audio-capturer" paramters in the above command can be tweaked as necessary to support inputs for linux/mac, and the rest of the command will work the same. alsa
ffmpeg -nostats -loglevel 0 \
-f alsa -ac 2 -i hw:0 \
-f s16le -acodec pcm_s16le -ar 44100 -ac 2 - \
| ffmpeg -nostats -loglevel 0 \
-f s16le -ar 44100 -ac 2 -i - \
-acodec libmp3lame \
-b:a 128k -f mp3 - \
| pitahaya --tx mp3 \
| ffmpeg -nostats -loglevel 0 \
-f lavfi \
-i anullsrc=channel_layout=stereo:sample_rate=11025 \
-framerate 8 -f rawvideo \
-pixel_format rgba -video_size 640x360 \
-i - -shortest -c:v libx264 \
-crf 32 -pix_fmt yuv420p -preset slow \
-r 8 -g 16 -f flv \
"rtmp://a.rtmp.youtube.com/live2/abcd-efgh-ijkl-mnop-qrst"
pulse
ffmpeg -nostats -loglevel 0 \
-f pulse -ac 2 -i default \
-f s16le -acodec pcm_s16le -ar 44100 -ac 2 - \
| ffmpeg -nostats -loglevel 0 \
-f s16le -ar 44100 -ac 2 -i - \
-acodec libmp3lame \
-b:a 128k -f mp3 - \
| pitahaya --tx mp3 \
| ffmpeg -nostats -loglevel 0 \
-f lavfi \
-i anullsrc=channel_layout=stereo:sample_rate=11025 \
-framerate 8 -f rawvideo \
-pixel_format rgba -video_size 640x360 \
-i - -shortest -c:v libx264 \
-crf 32 -pix_fmt yuv420p -preset slow \
-r 8 -g 16 -f flv \
"rtmp://a.rtmp.youtube.com/live2/abcd-efgh-ijkl-mnop-qrst"
avfoundation
ffmpeg -nostats -loglevel 0 \
-f avfoundation -i ":0" \
-acodec libmp3lame \
-b:a 128k -f mp3 - \
| pitahaya --tx mp3 \
| ffmpeg -nostats -loglevel 0 \
-f lavfi \
-i anullsrc=channel_layout=stereo:sample_rate=11025 \
-framerate 8 -f rawvideo \
-pixel_format rgba -video_size 640x360 \
-i - -shortest -c:v libx264 \
-crf 32 -pix_fmt yuv420p -preset slow \
-r 8 -g 16 -f flv \
"rtmp://a.rtmp.youtube.com/live2/abcd-efgh-ijkl-mnop-qrst"