LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2019, 05:28 AM   #1
kzo81
Member
 
Registered: Aug 2014
Location: Hungary
Distribution: Mint
Posts: 100

Rep: Reputation: Disabled
ffmpeg stream and record at the same time


Hi,

I'd like to stream and record my laptop's audio input at the same time.

Streaming works perfectly with this ffserver config file:
Code:
HTTPPort 4444
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 10
MaxClients 10
MaxBandwidth 1024
CustomLog -

<Feed audio.ffm>
File /tmp/audio.ffm
FileMaxSize 100M
</Feed>

##################################################################

<Stream audio>
Feed audio.ffm
Format mp2
Audiocodec libmp3lame
AudioBitRate 56
AudioChannels 2
AudioSampleRate 44100
NoVideo
#StartSendOnKey
</Stream>


<Stream stat.html>
Format status

#ACL allow localhost

FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico
</Stream>
Than I start ffserver:
Code:
ffserver -f /etc/ffserver.conf &
And start ffmpeg:

Code:
ffmpeg -f alsa -i hw:0,0 http://localhost:4444/audio.ffm | tee arecord -f cd -r 44100 -d 10 test1.wav
The streaming works nicely but tge test.wav file never gets created for some reason.

Last edited by kzo81; 01-27-2019 at 02:30 AM.
 
Old 01-21-2019, 05:55 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,702

Rep: Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801Reputation: 4801
you cannot tee into arecord that way. And also I cannot think arecord can handle stdin like this.
 
1 members found this post helpful.
Old 01-21-2019, 06:44 AM   #3
kzo81
Member
 
Registered: Aug 2014
Location: Hungary
Distribution: Mint
Posts: 100

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
you cannot tee into arecord that way. And also I cannot think arecord can handle stdin like this.
I know, that's an issue, thanks.
There must be a workaround for this. I'm testing with a 2 fifos now:
Code:
#!/bin/bash

s="streaming"
r="recording"

cd /tmp/ || exit 1

if [ -p "$s" ]; then
	rm "$s"
fi
mkfifo "$s"

if [ -p "$r" ]; then
	rm "$r"
fi
mkfifo "$r"

ffmpeg -f alsa -i hw:0,0 -f wav pipe:1 > "$s" -f wav pipe:1 > "$r"

exit 0
And then I would record and stream from the 2 fifos:

Code:
ffmpeg -i /tmp/recording -t 00:00:10 /tmp/test.wav
Code:
ffmpeg -i /tmp/streaming http://localhost:4444/audio.ffm
Here is the output of ffprobe for the 2 fifos:
https://pastebin.com/6MU6mYsA

Last edited by kzo81; 01-27-2019 at 02:47 AM. Reason: update
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Record and watch TV at the same time annonyxxxx Linux - Software 2 05-30-2013 03:06 PM
Install FFMPEG and FFMPEG-PHP on fedora10 & 12 cks Linux - Server 2 09-17-2010 01:55 PM
Using 4 same type webcams at the same time to stream video/audio to uStream Dafydd Linux - Hardware 2 05-24-2010 10:56 AM
How to record a stream and start a new outputXXX.avi/mp3 for each new stream title ? frenchn00b Linux - General 4 08-04-2008 05:40 AM
prevent users to run the same script at the same time, on the same machine pvpnguyen Programming 2 09-05-2007 08:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration