How can I stream audio without latency? - linux

I've been playing around with ffmpeg for sending audio to an endpoint and listening to it. This is the command I've used.
ffmpeg -f pulse -i 1 -f pulse 1
Where the two "1's" are the indices of my mic and output device as reported by pacmd list-sources and pacmd list-sinks.
This command allows me to speak into my microphone and hear it back in my speakers, but there's latency. Other parameters like -tune zerolatency and stuff don't help.
I know that low latency audio streaming is possible on Linux since apps like Discord work on it. Why is there latency in my command, and what protocol, program, or library should I use to transmit an audio stream?

Related

Popping noise when piping audio into a vitual mic debian

I have a pipe module with the command pactl load-module module-pipe-source source_name=VirtualMic file=/tmp/virtualmic format=wav rate=44100 channels=2
I want to use SoX to play a sound file into it. I am doing this with sox "example.wav" -t wav - > /tmp/virtualmic
I have tried piping the audio using ffmpeg, to the same result, and to confirm that it is not my computer speakers or the file, playing the file in audio programs such as vlc does not include a popping sound.
The number of channels and the sample rate are both identical, and other then the pop the audio plays normally

Can FFMPEG pause a live audio recording when db levels fall below threshold?

I am in the process of converting 100's of audio cassettes to FLAC files. I have used Audacity and RecordPad by NCH Software to set decibel (dB) thresholds. so that when my devices stop and require a tape flip, the recording also pauses.
I would like to move my tape playing devices (USB-based) to ubuntu 18.04 and run them on FFMPEG, but was wondering if FFMPEG had the ability to pause the recording when the audio signal falls below a configurable threshold.
This helps me reduce the storage waste. Soon I have to convert some older audio reels as well in which the problem will get worse.
The probe with Audacity is limited # of instances. If Audacity allowed me to instantiate multiple instances (1 for each playback device), I wouldn't be asking this question.
I'm a bit of a noob to shell scripting...here is the end of my current shell script:
nohup ffmpeg -nostdin -f alsa -i hw:"$DEVICE" -t $DURATION -filter:a volumedetect -ar 48000 -ac 2 -b:a 320k "$TITLE".flac 2> "$TITLE".log &
Thanks in advance!
Deep

Is it possible to capture audio from an ASIO device with ffmpeg?

We have a setup with a Windows 7 machine where we installed Dante Virtual Soundcard and start that soundcard with ASIO capabilities. The soundcard will receive audio over the network from a Tesira server. We want to capture the audio to files (highly preferring each channel to a separate file). The files will be played back on a later moment. There will likely be 6 channels or more.
In the same setup we use ffmpeg to capture some video which is working fine, with Direct Show. So for audio we wanted to use the same setup, since ffmpeg is able to record audio as well. However, there seems to be no option to select the ASIO devices which the virtual soundcard probably creates. So the question is what command line to use for ffmpeg, or what to install? Or which other program can record ASIO from command line?
I already tried installing:
Asio4all (actually wrong way around)
sox (don't know why actually)
HiFi Cable Asio Bridge (from VB-audio, not enough channels even with donate version)
Voicemeeter (from VB-Audio, not enough channels and actually mixes down)
O Deus Asio link, this might be an interesting option but it did not let me configure any route, any suggestions?
One thing I noticed is that the virtual soundcard can also be set to use WDM. Then I can see the devices with ffmpeg -list_devices true -f dshow -i duymmy, but recording does not yield any result, I have to ctrl-c to make it stop instead of q, and the file is zero bytes. Supposedly this is because the data over the network is all ASIO formatted and the Tesira Server cannot send "WDM data". FFmpeg stops at selecting the capture pin for audio only
EDIT:
I ran ffmpeg with high verbosity and when selecting the WDM soundcard it stops at Selecting pin Capture on audio only. Also when requesting the options it gives the same line for 22 times: min ch=1 bits=8 rate= 11025 max ch=2 bits=16 rate= 44100
You might use Voicemeeter instead of HIFI-Cable / ASIO-Bridge. Voicemeeter is a virtual audio device mixer able to connect everything together, any audio point, in any interface and any app together (including ASIO DAW)... Download & User Manual on www.voicemeeter.com
To answer my own question: it is not possible to capture sound from an ASIO device with ffmpeg. Maybe I will write the code for it if I need it...
I could however solve my issues by separating the two streams of audio data we have (AVB and Dante). These where on the same switch and maybe it is a bug in the firmware, maybe misconfiguration.
Thanks for your help!
How do I get the output from an ASIO device to IceCast2 or FFMpeg?
Duplicate?
And if not, Place the output for ffmpeg -f dshow -i "audio=your_device_name_in_dshow" -list_options

Broadcast a program's audio to a media server

I'm trying to broadcast an application's audio output to a media server like Adobe FMS, Red5, or IceCast.
Is there a tool that can help me accomplish this, or a library that can help with building a custom solution in linux/windows?
Thanks.
ffmpeg is an excellent option for this, transcoding and feeding into other streaming servers is where it shines, currently I'm using the following command to transcode an RTMP stream to 16x9 pixels in raw RGB24 format while also deleting the audio channel[s]:
ffmpeg -re -i http://192.168.99.148:8081/ -an -vf scale=16:9 -pix_fmt rgb24 -f rawvideo udp://127.0.0.1:4000
Of course the possibilities are limitless, if you can give more specific info about your case I might be able to help you construct the needed commands.

How to capture voice PCM data over a serial port and process?

I have a telephony modem (SIM5320EVB) which gives voice data on ttyUSB0 as PCM with 1600 bytes each 100ms.Iam able to see the data on minicom. How to capture the PCM data in linux (i use ubuntu)and hear it live on the fly or atleast save and play the data? Is there any application available or API? If the approach atleast is suggested I will try developing one..
cat /dev/ttyUSB0 > my_cap_file
# make some noise for 5s for example, then hit ^C
then get Audacity and try to open your file with it, trying different input formats. You should be able to hear the sound you produced if you will guess the right format.
Install sox for the play command and use: play -r 8000 -c 1 -t raw -e signed-integer -b 16 /dev/ttyUSB0. That is: bit rate 8KHz, 1 channel (mono), raw data (PCM), format is signed integer 16 bits wide, and data can be read from ttyUSB0.
That requires sox to be able to play audio on your system; I've had success with pulseaudio for the underlying sound system.
You may need to modify the buffer size for play. By default, it buffers data which creates a small but very noticeable delay.

Resources