Bleuzen / SpotRec

Spotify desktop client recorder for PulseAudio
MIT License
75 stars 17 forks source link
pulseaudio spotify-desktop-client

SpotRec

Python script to record the audio of the Spotify desktop client using FFmpeg and PulseAudio

AUR: https://aur.archlinux.org/packages/spotrec/

Usage

If you use the AUR package, you can simply run:

spotrec

If you have a GNU/Linux distribution with a different package manager system, run:

python3 spotrec.py

Example

First of all run spotify.

Then you can run the python script which will record the music:

./spotrec.py -o ./my_song_dir --skip-intro

Check the pulseaudio configuration:

pavucontrol

Pay attention to the red circles, everything else is muted and with volume set to 0%

playback tab

Note: actually "Lavf..." will appear after you start playing a song

recording tab

output devices tab

input devices tab

configuration tab

Finally start playing whatever you want

Hints

Troubleshooting

Start the script with the debug flag:

./spotrec.py --debug

If one of the following scenarios happens:

# what you should see when ffmpeg is recording ...
size=56400kB time=00:00:04.15 bitrate= 130.7kbits/s speed=1x
ValueError: invalid literal for int() with base 10: 'nput'

I would suggest you to:

Note: sometimes spotify detects when the user does not interact with the application for a long time (more or less an hour) and starts looping over a song, to avoid this scenario I would suggest to keep interacting with the spotify client.