ffmpeg, stream audio from server via ssh and save to file together
--stream-record
Use --stream-record
in mpv
:
ssh -p 22 SERVER "ffmpeg -f pulse -i default -b:a 32k -f mp3 -" | mpv --stream-record=output.mp3 -
From the documentation:
There are some glitches with this because it uses FFmpeg's libavformat for writing the output file. For example, it's typical that it will only work if the output format is the same as the input format. This is the case even if it works with the ffmpeg tool. One reason for this is that ffmpeg and its libraries contain certain hacks and workarounds for these issues, that are unavailable to outside users.
tee muxer
Or the tee muxer:
ssh -p 22 SERVER "ffmpeg -f pulse -i default -b:a 32k -f mp3 -" | ffmpeg -y -i - -map 0 -c copy -f tee "output.mp3|[f=mp3]pipe:" | mpv pipe:
Less convenient, but possibly more robust and flexible than using --stream-record
.
I did not test these commands.