Stream PCM audio File via ezstream to icecast - audio

I would like to know if i can stream i PCM audio file via ezstream to icecast :
My ezstream config file :
<ezstream>
<url>http://127.0.0.1:8000/myRadio</url>
<sourcepassword>hackme</sourcepassword>
<format>MP3</format>
<filename>C:\Users\HP\Downloads\ezstream-0.5.6-win32\test\playlist.txt</filename>
<stream_once>1</stream_once>
<svrinfoname>AAA</svrinfoname>
<svrinfourl>http://test.ma</svrinfourl>
<svrinfogenre>Software Developpement</svrinfogenre>
<svrinfodescription>DDDD</svrinfodescription>
<svrinfobitrate>128</svrinfobitrate>
<svrinfochannels>2</svrinfochannels>
<svrinfosamplerate>44100</svrinfosamplerate>
<svrinfopublic>1</svrinfopublic>
<reencode>
<enable>1</enable>
<encdec>
<format>MP3</format>
<match>.mp3</match>
<encode>lame -r -s 44.1 - -</encode>
</encdec>
</reencode>
</ezstream>
Thank you

As of version 0.5.6 ezstream supports MP3, Ogg Vorbis and Ogg Theora

Related

How do I decode opus file to pcm file using libavcodec from ffmpeg?

I am trying to decode opus to pcm file using libavcodec.So,I use ffmpeg example from https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html .And I change AV_CODEC_ID_MP2 to AV_CODEC_ID_OPUS.But I get an error.
codec = avcodec_find_decoder((AV_CODEC_ID_MP2);
codec = avcodec_find_decoder(AV_CODEC_ID_OPUS);
error:
codec ./decode_audio ./out.opus ./out.pcm
[opus # 0x7ff361800000] Error parsing Opus packet header.
[opus # 0x7ff361800000] Error parsing Opus packet header.
[opus # 0x7ff361800000] Error parsing Opus packet header.
[opus # 0x7ff361800000] Error parsing Opus packet header.
[opus # 0x7ff361800000] Error parsing Opus packet header.
[opus # 0x7ff361800000] Error parsing Opus packet header.
So I try to change opus AV_CODEC_ID_OPUS to AV_CODEC_ID_MP3 and try again.
codec ./decode_audio ./out.mp3 ./out.pcm
[mp3float # 0x7fe564002000] Header missing
Error submitting the packet to the decoder
Why does the example from ffmpeg get error?What should I do ?
You can't decode opus this way. Mp3 packets are self-delimiting, opus is not. Which means that opus requires a container (usually ogg). That container must be parsed to determine the start and end of an opus packet that you can then decode. libavformat can be used to read AVPackets from the file.

Sink to the virtual v4l2 device

I have tried an example on Ubuntu 19.04
gst-launch-1.0 videotestsrc ! v4l2sink device=/dev/video10
But gstreamer fails
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Cannot identify device '/dev/video10'.
Additional debug info:
v4l2_calls.c(609): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
system error: No such file or directory
Setting pipeline to NULL ...
Freeing pipeline ...
Why it doesn't work? I haven't found this in the documentation, do I need to create /dev/video10 somehow?
I did the same for the default device /dev/video1, but it is an input camera device on my laptop:
sudo gst-launch-1.0 videotestsrc ! v4l2sink
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video1' is not a output device.
Additional debug info:
v4l2_calls.c(639): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x4a00000
Setting pipeline to NULL ...
Freeing pipeline ...
Thank in advance.
The title of your questions suggests you would like to write to a virtual video device. v4l2 devices can be both input and output video devices. Your camera is a video input (capture) device. Directing a v4l2sink (so an endpoint of the pipeline) in gstreamer will likely fail.
You can however generate a virtual output device. What you are looking for is something like the v4l2-loopback device. It allows you to generate a virtual /dev/video10 device like this:
modprobe v4l2loopback video_nr=10
Another possible solution for the same error message: recreate the v4l2loopback interface:
sudo rmmod -f v4l2loopback
sudo modprobe v4l2loopback
This might apply to others experiencing the error message from the original question, but who are already aware they need a v4l2loopback device as gstreamer sink.
When trying to stream a video to the existing v4l2loopback device I streamed to using ffmpeg before, I got the same error message
Device '/dev/video0' is not a output device.
Investigation
When comparing the state of a working loopback video device and a non-working one (i.e. after writing to it with ffmpeg) with v4l2-ctl --all -d 0 using diff, I found the following difference :
--- working 2020-11-19 18:03:52.499440518 +0100
+++ non-working 2020-11-19 18:03:57.472802868 +0100
## -3,21 +3,18 ##
Card type : GPhoto2 Webcam
Bus info : platform:v4l2loopback-000
Driver version : 5.9.8
- Capabilities : 0x85208002
- Video Output
+ Capabilities : 0x85208000
Video Memory-to-Memory
Read/Write
Streaming
Extended Pix Format
Device Capabilities
- Device Caps : 0x05208002
- Video Output
+ Device Caps : 0x05208000
Video Memory-to-Memory
Read/Write
Streaming
Extended Pix Format
Priority: 0
-Video output: 0 (loopback in)
Format Video Output:
Width/Height : 960/640
Pixel Format : 'YU12' (Planar YUV 4:2:0)
Somehow that "Video Output" capability is required for gstreamer to work successfully and taken away by my previous ffmpeg call.
The behaviour only occured when I loaded the v4l2loopback module with the exclusive_caps=1 option, see 1.
The solution was to unload / load the v4l2loopback kernel commands, forcefully removing the v4l2loopback kernel module and adding it again using rmmod / modprobe (see above).

Jack server Cannot create new client on Raspbian Jessie Lite

I have installed Jack 2 on Raspberry Pi 3 with Raspbian Jessie Lite following the instructions from here https://github.com/iani/RPI-first-steps#step-3-get-and-install-jack-audio-drivers and added user to "realtime" group like this http://jackaudio.org/faq/linux_rt_config.html.
When I start Jack server with following command:
$ jackd -P75 -dalsa -dhw:0 -p1024 -n3 -s -r44100
everything seems fine and Jack server output is:
jackdmp 1.9.12
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2017 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 75
self-connect-mode is "Don't restrict self connect requests"
creating alsa driver ... hw:0|hw:0|1024|3|44100|0|0|nomon|swmeter|soft-mode|32bit
configuring for 44100Hz, period = 1024 frames (23.2 ms), buffer = 3 periods
ALSA: final selected sample format for capture: 24bit little-endian in 3bytes format
ALSA: use 3 periods for capture
ALSA: final selected sample format for playback: 24bit little-endian in 3bytes format
ALSA: use 3 periods for playback
But when I try to run for instance Pure Data as jack client I get this output from Pure Data:
Connect: can't connect named semaphore name = jack_sem.1000_default_system err = No such file or directory
Cannot read socket fd = 9 err = No such file or directory
CheckRes error
JackSocketClientChannel read fail
Cannot open pure_data_0 client
error: JACK: server returned status 33
while Jack server is complaining:
ClientNotify fails name = system notification = 0 val1 = 0 val2 = 0
NotifyAddClient new_client fails name = pure_data_0
Cannot notify add client
Cannot create new client
I tried to play mp3 with mplayer using jack but it seems to behave similarly. Mplayer looks like it is playing the mp3 but there's no audio output and the console output is:
Selected audio codec: MPEG 1.0/2.0/2.5 layers I, II, III [mpg123]
AUDIO: 44100 Hz, 2 ch, s16le, 160.0 kbit/11.34% (ratio: 20000->176400)
AO: [pulse] Init failed: Connection refused
[AO_ALSA] alsa-lib: pcm_hw.c:1557:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Device or resource busy
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
Connect: can't connect named semaphore name = jack_sem.1000_default_system err = No such file or directory
Cannot open MPlayer [939] client
Cannot read socket fd = 9 err = No such file or directory
CheckRes error
JackSocketClientChannel read fail
[JACK] cannot open server
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO_ALSA] alsa-lib: pcm_hw.c:1557:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
[AO SDL] Unable to open audio: No available audio device
AO: [null] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 20.1 (20.0) of 269.6 (04:29.6) 2.9%
Jack server's output is similar to the prior case:
ClientNotify fails name = system notification = 0 val1 = 0 val2 = 0
NotifyAddClient new_client fails name = MPlayer [939]
Cannot notify add client
Cannot create new client
I am really new to working with sound on linux and although I have read something about linux audio architecture I'm getting lost. I tried to google all different error messages from console outputs but didn't manage to find answer. Maybe I'm missing something really basic here.
Any suggestions are appreciated.
Thanks in advance.

Play sound in octave with pulseaudio

I would like to play sound in octave with pulseaudio. I saw this post but the octave audio management is changed in the new releases and it is not longer possible to use paplay like say that post, I have the version 4.2.1-4
Now when I try to use sound or audiolayer functions I get these errors:
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
And no sound is played, next, if I retry to use sound I don't get error and it waits for the sound duration, however it keep to not play sound.
It seems it would like to use ALSA, but I'm using pulseaudio what can i do?
EDIT:
I notice that sometimes the error message change and it say:
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1735
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1902
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2170
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2835
error: audioplayer: unable to open audio playback stream
error: called from
playblocking at line 36 column 3
sound at line 59 column 3

speechRecognition: jack server is not running

I'm setting up a sound recognizer with the speechRecognition python library.
This is my code so far:
#!/usr/bin/env python3
import speech_recognition as sr
r = sr.Recognizer('es-MX')
with sr.Microphone() as mic:
audio = r.listen(mic)
print(r.recognize(audio))
On running I get
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_l$
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
I'm using SpeechRecognition version 1.3.1 running on Linux LXLE 14.04 x64 with python 3.4
It tells you it can not record audio on your device. It is not related to a jack server, it also tries to open alsa device and bluetooth audio device. Make sure that audio is properly set on your device. See also
PyAudio does not work and bricks sound on ubuntu
PyAudio working, but spits out error messages each time
I am having this same error. If you would like a work around you can use my code I wrote. I used the sounddevice library to record audio while there is audio it saves into one file, then convert it to text using the speech recognition library. The error comes when microphone is called in as it is using PyAudio.
https://shepai.github.io/code/PetSHEP/soundLib.py
The following lines should replace your "with microphone" bit
with sr.AudioFile(filename) as source:
Audio=r.record(source)
This is how I got round the problem, hope it helps :)

Resources