Capturing audio with ffmpeg and ALSA is pretty much straightforward

According to https://trac.ffmpeg.org/wiki/Capture/ALSA .....

Capturing audio with ffmpeg and ALSA is pretty much straightforward:
Code:
ffmpeg -f alsa <input_options> -i <input_device> ... output.wav
Apparently that is all you need...

How do you do this on FreeBSD? I've been trying for almost a week and have not got anywhere... Seems like getting sound set up on FreeBSD can be troublesome. The Handbook is not really very useful in this regard....

How does ALSA, OSS, Pulseaudio etc fit into the whole picture?
 
Huh? As simple as
Code:
ffmpeg -f oss -i /dev/dsp output.wav

How does ALSA, OSS, Pulseaudio etc fit into the whole picture?
ALSA: Linux changed the whole interface to something a lot more complex because they couldn't get OSS right with "modern" requirements. Don't even start with pulseaudio.

On FreeBSD, you have a nice and simple OSS interface, /dev/dsp will map to your default devices and support software mixing etc. If you think you need a sound daemon, look for something clean and simple like sndiod. You definitely don't need it just to record something.
 
Huh? As simple as
Code:
ffmpeg -f oss -i /dev/dsp output.wav


ALSA: Linux changed the whole interface to something a lot more complex because they couldn't get OSS right with "modern" requirements. Don't even start with pulseaudio.

On FreeBSD, you have a nice and simple OSS interface, /dev/dsp will map to your default devices and support software mixing etc. If you think you need a sound daemon, look for something clean and simple like sndiod. You definitely don't need it just to record something.

So OSS is already installed in the base OS?...

Running
Code:
ffmpeg -f oss -i /dev/dsp output.wav
gave me:-
[wav @ 0x805e37600] Non-monotonous DTS in output stream 0:0; previous: 688068, current: 687813; changing to 688068. This may result in incorrect timestamps in the output file.
[wav @ 0x805e37600] Non-monotonous DTS in output stream 0:0; previous: 689613, current: 689358; changing to 689613. This may result in incorrect timestamps in the output file.
[wav @ 0x805e37600] Non-monotonous DTS in output stream 0:0; previous: 691158, current: 690904; changing to 691158. This may result in incorrect timestamps in the output file.
[wav @ 0x805e37600] Non-monotonous DTS in output stream 0:0; previous: 692703, current: 692449; changing to 692703. This may result in incorrect timestamps in the output file.
[wav @ 0x805e37600] Non-monotonous DTS in output stream 0:0; previous: 694247, current: 693994; changing to 694247. This may result in incorrect timestamps in the output file.
[wav @ 0x805e37600] Non-monotonous DTS in output stream 0:0; previous: 695792, current: 695539; changing to 695792. This may result in incorrect timestamps in the output file.
size= 2358kB time=00:00:14.53 bitrate=1328.7kbits/s speed=1.19x
video:0kB audio:2358kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.003231%
Exiting normally, received signal 2.
So it's not quite that simple....

cat /dev/sndstat shows:
Code:
Installed devices:
pcm0: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm1: <Realtek ALC269 (Internal Analog Mic)> (rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm5: <USB audio> (rec) default
No devices installed from userspace.

so am not really sure what /dev/dsp refers to.
 
So OSS is already installed in the base OS?...
There's nothing that could be "installed" here, OSS is the interface for sound devices on FreeBSD (traditionally on many "unixy" systems), so the kernel implements it. Linux decided to invent a totally different interface that comes with an overly complex userspace library and lots of tools -- FreeBSD didn't.

So it's not quite that simple....
did you even bother to check your output file? The console output looks pretty normal to me, the command probably worked just fine.

so am not really sure what /dev/dsp refers to.
As I told you, it uses whatever you configured as default devices. You already have the relevant section of the handbook ...

I've already installed audio/alsa-utils and audio/xfce4-pulseaudio-plugin hoping that might help sort out my problems. Should I delete them?
Shouldn't matter, but you definitely don't need them. So, yes, maybe better delete them to be sure there are no unexpected effects.
 
I'd like to chime in. I personally keep all pulseaudio-related ports far away from my system, it messes up things in ways that are hard to debug or predict.
An example of this is that SDL2 will use pulseaudio output by default if the library exists, before trying out OSS. If pulseaudio isn't configured in that case, it means no sound.

So, OSS is always the way to go on FreeBSD unless it's a piece of software that doesn't support OSS. There aren't many of that, in fact I don't have any installed at all.
 
The output file consists of a 80-byte header followed by 4.5MB of binary zeroes.
Which means it DID record, just silence. Well, should be straight-forward from here, check whether you picked the correct device as default (like described in the handbook, hw.snd.default_unit -- the output you showed earlier suggests your system is configured to record from an USB device), and check your mixer settings (the recording channel might be muted).
 
cat /dev/sndstat:
Code:
Installed devices:
pcm0: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC269 (Internal Analog Mic)> (rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm5: <USB audio> (rec)
No devices installed from userspace.
sysctl hw.snd.default_unit=5
cat /dev/sndstat:
Code:
Installed devices:
pcm0: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
pcm1: <Realtek ALC269 (Internal Analog Mic)> (rec)
pcm2: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm3: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm4: <Intel Panther Point (HDMI/DP 8ch)> (play)
pcm5: <USB audio> (rec) default
No devices installed from userspace.

check your mixer settings (the recording channel might be muted).

Not sure how to do that..... mixer shows:
Code:
Mixer vol      is currently set to  75:75
Mixer pcm      is currently set to  75:75
Mixer line     is currently set to  75:75
 
Since both ALSA and PulseAudio on FreeBSD are routed through OSS, if the sound capture doesn't work with OSS you are screwed either way.
https://linuxtv.org/wiki/index.php/Easycap#Empia_EasyCAP
shows:-
Empia EasyCAP
The Empia EasyCAP is based on the EM2860 chip from Empia.

Components Used
  • Empia EM2860 (EM2861 ?) (USB video bridge)
  • Silan SC8113 (Philips SAA7113 compatible video decoder)
  • AC'97 audio processor
Indentification
# lsusb
Bus XXX Device XXX: ID eb1a:2861 eMPIA Technology, Inc.

Making it work
EM2860 (EM2861) based devices are supported in Linux by the em28xx kernle module. More information on this wiki: Em28xx_devices

Audio support
The em28xx kernel module should create a Em28xx Audio ALSA soundcard which can be used for sound capturing.

I don't see this explicitly supported but the device is recognised and there is no problem capturing Video.

Is there any way to tell if anyone has ever successfully used Audio capture under FreeBSD with this device?
 
Try with:
# mixer -f /dev/mixer5 mic 100:100
Assuming there is one "mic" device in the output of "mixer -f /dev/mixer5"
Then attempt to record:
# ffmpeg -f oss -i /dev/dsp5 -filter:a "asetpts=N/SR/TB" test.wav
The audio filter only sets the presentation timestamp of each frame to the frame number, don't expect perfect synchronization (it will still be better than the "Non-monotonous DTS" error)
 
I can't honestly tell if that is an appropriate thread for merging, because I don't understand balanga's questions in the first place. As for the non-microphone sound capture (not sure what's the correct term), last time I answered this very question was only two weeks ago. Is the forum search function broken or something?
 
Back
Top