ffmpeg x11grab and v4l2-ctl

Hi everybody,

I am trying to port https://github.com/cytopia/ffscreencast over to FreeBSD.

As I am kind of a newbie to FreeBSD on a desktop I am looking for some FreeBSD equivalents to the following Linux tools.

* ffmpeg with x11grab to capture the desktop
* v4l2-ctl to list all attached camera devices
* arecord to list all sound devices
* xdpyinfo to list all connected monitors

Maybe some tools like xdpyinfo are available on FreeBSD anyway, but I am also looking for the best native solutions that can do the above jobs.

Could you guys and girls provide me with some input here.

Thank you
 
From your first link I see they include sound like this
ffmpeg -f oss -i /dev/dsp0.0

Unfortunately I do not have any /dev/dsp* devices. dev/sndstat however seems to recognize list my sound cards.

Code:
$ cat /dev/sndstat
Installed devices:
pcm0: <NVIDIA GT21x (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA GT21x (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA GT21x (HDMI/DP 8ch)> (play)
pcm3: <NVIDIA GT21x (HDMI/DP 8ch)> (play)
pcm4: <Realtek ALC889 (Rear Analog 7.1/2.0)> (play/rec) default
pcm5: <Realtek ALC889 (Front Analog)> (play/rec)
pcm6: <Realtek ALC889 (Rear Digital)> (play)
pcm7: <Realtek ALC889 (Onboard Digital)> (play)
 
Yeah, that throws people off. If you look further down it mentions that /dev/dsp doesn't get created till it's used. In other words, you won't see a /dev/dsp anything, but if you then cat anything to it (doesn't even have to be an audio file) you will see that it's appeared. There's an old post of mine on these forums somewhere asking about that, where someone explained it to me.
 
Hi everybody,

I am trying to port https://github.com/cytopia/ffscreencast over to FreeBSD.

As I am kind of a newbie to FreeBSD on a desktop I am looking for some FreeBSD equivalents to the following Linux tools.

* ffmpeg with x11grab to capture the desktop
* v4l2-ctl to list all attached camera devices
* arecord to list all sound devices
* xdpyinfo to list all connected monitors

Maybe some tools like xdpyinfo are available on FreeBSD anyway, but I am also looking for the best native solutions that can do the above jobs.

Could you guys and girls provide me with some input here.

Thank you
The following ports should cover your list of requirements:
To get a listing of all the available sound devices on the system, as you've already done, you can run cat /dev/sndstat.

scottro is correct. The /dev/dsp* device nodes are created by the kernel on demand the when a sound device is accessed. Until then, they won't exist. The device nodes will persist until the system is rebooted in which case there will be no existing device nodes again until a sound device is accessed.
 
Thanks for the list that covers all sofware.

There is still one question remaining with the appropriate sound recording device:

Code:
$ cat /dev/sndstat | grep '(play/rec)'
pcm4: <Realtek ALC889 (Rear Analog 7.1/2.0)> (play/rec) default
pcm5: <Realtek ALC889 (Front Analog)> (play/rec)

Now how do I know to which dsp device pcm4 and pcm5 belong?
 
Your output lists pcm4 as the rear analog sound device and pcm5 as the front analog sound device with the rear analog device as the default device. So the sound card ports on the back of the computer are for the rear analog(default) device or pcm4, and the sound ports in the front(sometimes top depending on the computer's case design) are for the the front analog sound device or pcm5.

Oops! I read your post wrong. Sorry about that. The dsp* device nodes start with a numbering of 0 as do the corresponding pcm* devices.
 
So that means that pcmX will always be /dev/dspX.0 or /dev/dsp0.X?
And what is the difference between dsp0.0 and dsp0.1 or dsp1.0 or dsp1.1?
 
By the way (I just happened to notice this while upgrading multimedia/ffmepg the screen grab is an option--I'm not sure if it's off or on by default. You may want to look through the options. For example, libass support is off by default, not sure about libx264 and libx265. (I was looking at a config file that I made some time ago, so I'm not sure what the original defaults were.)

Depending upon your needs, the defaults may be fine, but you might want to be sure that nothing you need is off by default. To check, you can just cd into /usr/ports/multimedia/ffmpeg and type make config. That opens up a curses based dialog, where you can see what is included.

(You might know all of this already, in which case, I apologize for wasting your time, but I do remember, for example, being somewhat annoyed when when I need to burn subtitles into something and getting the error subtitles: no such filter, or similar.)
 
So that means that pcmX will always be /dev/dspX.0 or /dev/dsp0.X?
pcm%n = dsp%n.v% where %n is the device number and %v is a virtual channel.
And what is the difference between dsp0.0 and dsp0.1 or dsp1.0 or dsp1.1?
FreeBSD's sound system includes in-kernel virtual mixing support for sound devices. Some higher end sound cards do this in the hardware but most lower end consumer sound cards and onboard audio do not. This allows a device to input and output from multiple sources at the same time. If your familiar with Linux, it's similar to what dmix does for ALSA sound devices or more recently PulseAudio.

Say for example you have a sound device. We'll label it pcm0. The corresponding dsp device would then be dsp0.0 which would be created when the device is accessed for the first time after the system starts. Let's now say your playing a music file, but you want to also play a video in another program at the same time that would output sound to the same(default) device. Once the program you open to play video accesses the sound card dsp0.1 will be created. Each time a new sound source accesses the sound card a new virtual channel will be created. This is automatically handled by the kernel so any sound source only needs to point to dsp0 as the virtual channels will be handled automatically. This also prevents the sound device from being locked to one input or output source at a time.
 
One other thing I'll mention, though I have no idea if it will be important to you. Casual tests show that Linux re-encodes a bit faster than FreeBD As I said, these were casual, along the lines of l
ffmpeg -i myfile.mp4 -c:v libx265 out.mp4. Doing that (making an x264 file into x265, which drastically decreases the size, took about 5 minutes longer in FreeBSD for a file of about 265 MB and 24 minutes runtime. However, FreeBSD did a better job of decreasing size, though not drastically, say, 99 MB for FreeBSD vs. 111 MB for Linux. The output indicated that Linux was doing more fps, say, 30-35 vs. FreeBSD's 20-25

I mention this in case it matters, though from your description of what you are planning, it's probably irrelevant. :)
 
Definitely not irrelevant. I am always looking for information regarding ffmpeg to make the final command as performant as possible. This is specifically the case once sound and/or camera are included.
 
I don't want to waste your time with guesses, but using the program ports-mgmt/psearch and running psearch webcam brings up a few responses, including multimedia/pwcbsd and multimedia/pwcview. If you look at their respective pkg-plist and Makefiles, does it suggest anything useful? (I should point out that I'm not a programmer, but assume as these work with webcams, I'm guessing, or at least hoping, that they may be able to get you information on an existing webcam)
 
Last edited:
Hi everybody,

I am trying to port https://github.com/cytopia/ffscreencast over to FreeBSD.

As I am kind of a newbie to FreeBSD on a desktop I am looking for some FreeBSD equivalents to the following Linux tools.

* ffmpeg with x11grab to capture the desktop
* v4l2-ctl to list all attached camera devices
* arecord to list all sound devices
* xdpyinfo to list all connected monitors

Maybe some tools like xdpyinfo are available on FreeBSD anyway, but I am also looking for the best native solutions that can do the above jobs.

Could you guys and girls provide me with some input here.

Thank you

This website may be of use to you:

http://www.rockafunk.org/
 
Thanks so far for all the input.

I guess this will be a longer ongoing progress.
I had to do some major code rewriting, so I can get FreeBSD support in step by step.

I will do screenrecording with sound first and once thats stable continue with the camera overlay
 
Back
Top