Score:0

ffmpeg, stream audio from server via ssh and save to file together

ss flag

I need stream audio from server and save to file in one time.

I tried this.

ssh -p 22 SERVER "ffmpeg -f pulse -i default -b:a 32k -f avi -" | mpv - &>/dev/null 1> file.mp3

But it run stream and saves only info from mpv, not stream output.

How can I do this?

Thanks.

genderbee avatar
ss flag
Maybe some way first save to file and play this file due the saving?
Score:1
jp flag

--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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.