LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-09-2019, 03:41 AM   #1
kzo81
Member
 
Registered: Aug 2014
Location: Hungary
Distribution: Mint
Posts: 88

Rep: Reputation: Disabled
audio redirection into fifo


Hi,

I'd like to stream and record at the same time on my laptop, first I'd devide the audio to 2 fifos:

Code:
#!/bin/bash

rm -rf /tmp/streaming 2 >/dev/null && mkfifo /tmp/recording 2 >/dev/null
rm -rf /tmp/recording 2 >/dev/null &&mkfifo /tmp/recording 2 >/dev/null

arecord -c 2 -f S16_LE -r 48000 | ffmpeg -i - -f wav pipe:3 -f wav pipe:4 3> /tmp/recording 4> /tmp/streaming &
Here is my only working solution, but it has way to much overhead, it consumes the CPU cores:
https://pastebin.com/mub4HCjM

and than I would test the fifos one-by-one:
Code:
cat /tmp/recording_fifo > arecord -c 2 -f S16_LE -r 48000 -d 10 /mnt/data/recordings/2019-10-09/recording_fifo_test.wav
I got this error: -sh: arecord: Text file busy

Could you please help me a bit?

Last edited by kzo81; 10-09-2019 at 04:48 AM. Reason: additional info
 
Old 10-09-2019, 03:55 AM   #2
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 3,928
Blog Entries: 1

Rep: Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832
Why? There's snd-aloop that creates a dummy soundcard who's output is it's input.

There's also tee.

$ arecord | tee file.raw | ffmpeg .....

With whatever parameters you desire.
 
Old 10-09-2019, 03:58 AM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 3,928
Blog Entries: 1

Rep: Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832
I've used the tee method to record a high quality wav file and an mp3 file to another device at the same time. Hand the crappy mp3 on a usb stick to the event organizer on the way out the door, take my "good" recording home.
 
Old 10-09-2019, 04:13 AM   #4
kzo81
Member
 
Registered: Aug 2014
Location: Hungary
Distribution: Mint
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Shadow_7 View Post
Why? There's snd-aloop that creates a dummy soundcard who's output is it's input.

There's also tee.

$ arecord | tee file.raw | ffmpeg .....

With whatever parameters you desire.
Interesting. This way file.raw will grow and eventually fill the disk.

I'd like 5 minutes segment recording to wav and in the meantime, stream with ffmpeg or vlc via http
 
Old 10-09-2019, 04:42 AM   #5
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 3,928
Blog Entries: 1

Rep: Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832
Well yes, files tend to do that. Disks are relatively cheap. It doesn't have to be .raw, it could be .mp3 or other compressed formats. It doesn't have to be arecord, it could be rec from sox, or other options. Even if you're making a high quality recording of about 1GB a minute, a 2TB HDD would give you 2000 minutes, well past 24 hours of audio. Perhaps not good enough for a security system where you need 24/7 recording of at least a 30 day loop. But even that is just a storage limitation. Throw enough $$$ at the issue and you could have petabyte(s) of space.

Sox has a trim option to break segments into specified duration's as it records. Or tail -f file.raw in another thread to do that. Lots of options.
 
  


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
Question about reading/writing into a Named Pipes(FIFO) Sathya Programming 21 05-05-2008 08:39 AM
Linux 2.6 FIFO vs Linux 2.4 FIFO gjpc Programming 4 03-19-2008 07:26 PM
FIFO question gauge73 Linux - Newbie 1 02-28-2003 11:39 PM
nfs FIFO??? granny Linux - Newbie 1 12-16-2002 03:38 PM
How do i change FIFO-Buffer on SuSE 7.0 ?? Problemer Linux - Networking 0 01-10-2002 08:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:20 PM.

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