aboutsummaryrefslogtreecommitdiff
path: root/documentation/content/en/books/handbook/multimedia/_index.adoc
blob: 855601abb10fa298fec24542dcd42275e51f4364 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
---
title: Chapter 9. Multimedia
part: Part II. Common Tasks
prev: books/handbook/desktop
next: books/handbook/kernelconfig
description: The multimedia chapter provides an overview of multimedia support on FreeBSD
tags: ["multimedia", "sound card", "Audio players", "scanner", "SANE", "Video players", "Conferencing and Meetings", "Setting Up the Webcam"]
showBookMenu: true
weight: 12
params:
  path: "/books/handbook/multimedia/"
---

[[multimedia]]
= Multimedia
:doctype: book
:toc: macro
:toclevels: 1
:icons: font
:sectnums:
:sectnumlevels: 6
:sectnumoffset: 9
:partnums:
:source-highlighter: rouge
:experimental:
:images-path: books/handbook/multimedia/

ifdef::env-beastie[]
ifdef::backend-html5[]
:imagesdir: ../../../../images/{images-path}
endif::[]
ifndef::book[]
include::shared/authors.adoc[]
include::shared/mirrors.adoc[]
include::shared/releases.adoc[]
include::shared/attributes/attributes-{{% lang %}}.adoc[]
include::shared/{{% lang %}}/teams.adoc[]
include::shared/{{% lang %}}/mailing-lists.adoc[]
include::shared/{{% lang %}}/urls.adoc[]
toc::[]
endif::[]
ifdef::backend-pdf,backend-epub3[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]
endif::[]

ifndef::env-beastie[]
toc::[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]

[[multimedia-synopsis]]
== Synopsis

The multimedia chapter provides an overview of multimedia support on FreeBSD.
Multimedia applications and technologies have become an integral part of modern computing, and FreeBSD provides robust and reliable support for a wide range of multimedia hardware and software.
This chapter covers various multimedia components such as audio, video, and image processing.
It also discusses various media formats and codecs, as well as tools and applications for multimedia creation and playback.
Additionally, the chapter covers multimedia system configuration, troubleshooting, and optimization.
FreeBSD provides a robust platform for multimedia work, suitable for both multimedia enthusiasts and professional content creators.
This chapter aims to help get the most out of FreeBSD's multimedia capabilities, providing useful information and practical examples to help get started.

[[sound-setup]]
== Setting Up the Sound Card

By default, FreeBSD will automatically detect the sound card used by the system.
FreeBSD supports a wide variety of sound cards.
The list of supported sound cards can be consulted in man:sound[4].

[NOTE]
====
It is only necessary to load the sound card module if FreeBSD has not detected it correctly.
====

Where it is not known which sound card the system has, or which module to use, the `snd_driver` metadriver can be loaded by executing the following command:

[source,shell]
....
# kldload snd_driver
....

Alternatively, to load the driver as a module at boot time, place the following line in [.filename]#/boot/loader.conf#:

[.programlisting]
....
snd_driver_load="YES"
....

[[sound-testing]]
=== Testing Sound

To confirm the sound card is detected the following command can be executed:

[source,shell]
....
% dmesg | grep pcm
....

The output should be similar to the following:

[.programlisting]
....
pcm0: <Conexant CX20561 (Hermosa) (Analog 2.0+HP/2.0)> at nid 26,22 and 24 on hdaa0
pcm1: <Conexant CX20561 (Hermosa) (Internal Analog Mic)> at nid 29 on hdaa0
....

The status of the sound card may also be checked using this command:

[source,shell]
....
# cat /dev/sndstat
....

The output should be similar to the following:

[.programlisting]
....
Installed devices:
pcm0: <Conexant CX20561 (Hermosa) (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Conexant CX20561 (Hermosa) (Internal Analog Mic)> (rec)
....

If no `pcm` devices are listed, double-check that the correct device driver was loaded.
If all goes well, the sound card should now work in FreeBSD.

man:beep[1] can be used to produce some noise, confirming that the sound card is working:

[source,shell]
....
% beep
....

[[sound-mixer]]
=== Mixer

FreeBSD has different utilities to set and display sound card mixer values built on the FreeBSD Sound System:

.Supported mixer packages
[options="header", cols="1,1,1,1"]
|===
| Name | License | Package | Toolkit

| man:mixer[8]
| BSD-2
| Included in base system
| CLI

| dsbmixer
| BSD-2
| package:audio/dsbmixer[]
| Qt

| KDE Plasma audio widget
| GPL 2.0
| package:audio/plasma6-plasma-pa[]
| Qt

| mixertui
| BSD-2
| package:audio/mixertui[]
| TUI

|===

[[graphics-card-sound]]
=== Graphics Card Sound

Graphics cards often come with their own integrated sound devices, and it may be unclear which is being used as the default device.
To confirm, run dmesg and look for the pcm entries to identify how the system is enumerating the outputs.
Execute the following command:

[source,shell]
....
% dmesg | grep pcm
....

The output looks something like this:

[.programlisting]
....
pcm0: <HDA NVIDIA (Unknown) PCM #0 DisplayPort> at cad 0 nid 1 on hdac0
pcm1: <HDA NVIDIA (Unknown) PCM #0 DisplayPort> at cad 1 nid 1 on hdac0
pcm2: <HDA NVIDIA (Unknown) PCM #0 DisplayPort> at cad 2 nid 1 on hdac0
pcm3: <HDA NVIDIA (Unknown) PCM #0 DisplayPort> at cad 3 nid 1 on hdac0
hdac1: HDA Codec #2: Realtek ALC889
pcm4: <HDA Realtek ALC889 PCM #0 Analog> at cad 2 nid 1 on hdac1
pcm5: <HDA Realtek ALC889 PCM #1 Analog> at cad 2 nid 1 on hdac1
pcm6: <HDA Realtek ALC889 PCM #2 Digital> at cad 2 nid 1 on hdac1
pcm7: <HDA Realtek ALC889 PCM #3 Digital> at cad 2 nid 1 on hdac1
....

The graphics card (NVIDIA(R)) has been enumerated before the sound card (Realtek(R)), with the sound card appearing as `pcm4`.
The system can be configured to use the sound card as the default device by executing the following command:

[source,shell]
....
# sysctl hw.snd.default_unit=4
....

To make this change permanent add the next line to [.filename]#/etc/sysctl.conf#:

[.programlisting]
....
hw.snd.default_unit=4
....

[[automatically-switching-headphones]]
=== Automatically Switching to Headphones

Some systems may struggle with switching between audio outputs, but fortunately FreeBSD allows automatic switchover to be configured in [.filename]#device.hints#.

Identify how the system is enumerating the audio outputs by executing the following command:

[source,shell]
....
% dmesg | grep pcm
....

The output looks something like this:

[.programlisting]
....
pcm0: <Realtek ALC892 Analog> at nid 23 and 26 on hdaa0
pcm1: <Realtek ALC892 Right Analog Headphones> at nid 22 on hdaa0
....

Add the following lines to [.filename]#/boot/device.hints#:

[.programlisting]
....
hint.hdac.0.cad0.nid22.config="as=1 seq=15 device=Headphones" 
hint.hdac.0.cad0.nid26.config="as=2 seq=0 device=speakers"
....

[NOTE]
====
Keep in mind that these values are for the example indicated above.
They may vary depending on the system.
====

[[troubleshooting-sound]]
=== Troubleshooting Sound

Some common error messages and their solutions:

[[multimedia-sound-common-error-messages]]
.Common Error Messages
[cols="1,1", frame="none", options="header"]
|===
| Error
| Solution

|`xxx: can't open /dev/dsp!`
|Type `fstat \| grep dsp` to check if another application is holding the device open. Noteworthy troublemakers are esound and KDE's sound support.
|===

Programs using package:audio/pulseaudio[] might need to restart the
package:audio/pulseaudio[] daemon for the changes in `hw.snd.default_unit`  to
take effect.
Alternatively, package:audio/pulseaudio[] settings can be changed on the fly.
man:pacmd[1] opens a command line connection to the package:audio/pulseaudio[]
daemon:

[source,shell]
....
# pacmd
Welcome to PulseAudio 14.2! Use "help" for usage information.
>>>
....

The following command changes the default sink to card number 4 as in
the previous example:

[.programlisting]
....
set-default-sink 4
....

[WARNING]
====
Do not use the `exit` command to exit the command line interface. That will kill
the package:audio/pulseaudio[] daemon. Use kbd:[Ctrl+D] instead.
====

[[audio-ports]]
== Audio players

This section introduces some of the software available from the FreeBSD Ports Collection which can be used for audio playback.

.Audio players packages
[options="header", cols="1,1,1,1"]
|===
| Name | License | Package | Toolkit

| Elisa
| LGPL 3.0
| package:audio/elisa[]
| Qt

| GNOME Music
| GPL 2.0
| package:audio/gnome-music[]
| GTK+

| Audacious
| BSD-2
| package:multimedia/audacious[]
| Qt

| MOC (music on console)
| GPL 2.0
| package:audio/moc[]
| TUI

|===

[[elisa]]
=== Elisa

Elisa is a music player developed by the KDE community that strives to be simple and nice to use.

To install Elisa, execute:

[source,shell]
....
# pkg install elisa
....

[[gnome-music]]
=== GNOME Music

GNOME Music is the new GNOME music playing application.
It aims to combine an elegant and immersive browsing experience with simple and straightforward controls.

To install GNOME Music, execute:

[source,shell]
....
# pkg install gnome-music
....

[[audacious]]
=== Audacious

Audacious is an open source audio player.
As a descendant of XMMS, it provides music playback while maintaining efficient use of system resources.

To install Audacious, execute:

[source,shell]
....
# pkg install audacious-qt6 audacious-plugins-qt6
....

[NOTE]
====
Audacious supports OSS natively, but must be configured in the settings on the Audio tab.
====

[[moc-music-on-console]]
=== MOC (music on console)

MOC (music on console) is a console audio player designed to be powerful and easy to use.

MOC plays smoothly, regardless of system or I/O load, because it handles the output buffer in a separate thread.
It does not cause gaps between files, because the next file to be played is pre-cached while playing the current file.

To install MOC (music on console), execute:

[source,shell]
....
# pkg install moc
....

[[video-ports]]
== Video players

This section introduces some of the software available from the FreeBSD Ports Collection which can be used for video playback.

.Video players packages
[options="header", cols="1,1,1,1"]
|===
| Name | License | Package | Toolkit

| MPlayer
| GPL 2.0
| package:multimedia/mplayer[]
| CLI

| SMPlayer
| GPL 2.0
| package:multimedia/smplayer[]
| Qt

| VLC media player
| GPL 2.0
| package:multimedia/vlc[]
| Qt

| Kodi (XBMC) 
| GPL 2.0
| package:multimedia/kodi[]
| X11

|===

[[mplayer]]
=== MPlayer

MPlayer is a multimedia player and encoder suite which runs on many platforms and works on the command line.
It plays a terrific number of different file formats and codecs including popular DivX, XviD, H.264 streams as well as DVD and SVCDs along with many popular audio codecs.

To install MPlayer, execute:

[source,shell]
....
# pkg install mplayer
....

For examples of how MPlayer works see man:mplayer[1].

[[smplayer]]
=== SMPlayer

SMPlayer intends to be a complete front-end for MPlayer, from basic features like playing videos, DVDs, and VCDs to more advanced features like support for MPlayer filters and more.

To install SMPlayer, execute:

[source,shell]
....
# pkg install smplayer
....

[[vlc]]
=== VLC media player

VLC media player is a highly portable multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, and more) as well as DVD's, VCD's, and various streaming protocols.
It can also be used as a server to stream in unicast or multicast in IPv4 or IPv6 on a high-bandwidth network.
VLC also has the ability to transcode media on-the-fly for streaming or saving to disk.

To install VLC, execute:

[source,shell]
....
# pkg install vlc
....

[[kodi]]
=== Kodi (XBMC)

Kodi (formerly known as XBMC) is a free and open source cross-platform media-player and entertainment hub.
It allows users to play and view most videos, music, podcasts, and other digital media files from local and network storage media and the internet.

To install Kodi, execute:

[source,shell]
....
# pkg install kodi
....

[[conferencing-meetings]]
== Conferencing and Meetings

A FreeBSD desktop environment can be used to join video conferences.
This section will explain how to configure the webcam and which videoconferencing applications are supported on FreeBSD.

[[webcam-setup]]
=== Setting Up the Webcam

To allow FreeBSD access to the webcam and perform its configuration it is necessary to install certain utilities:

* package:multimedia/webcamd[] is a daemon that enables the use of hundreds of different USB based webcam and DVB USB devices.
* package:multimedia/pwcview[] is an application that can be used to view the video stream of the webcam.

To install the required utilities, execute:

[source,shell]
....
# pkg install webcamd pwcview
....

Enable the man:webcamd[8] service in `/etc/rc.conf` to start it at system boot:

[source,shell]
....
# sysrc webcamd_enable=YES
....

The user must belong to the `webcamd` group.
To add the user to `webcamd` group execute the following command:

[source,shell]
....
# pw groupmod webcamd -m username
....

Since package:multimedia/webcamd[] needs the man:cuse[3] module this module must be loaded by executing the following command:

[source,shell]
....
# kldload cuse
....

To load man:cuse[3] at system boot, execute the command:

[source,shell]
....
# sysrc kld_list+=cuse
....

Once the utilities have been installed the list of available webcams can be shown with man:webcamd[8]:

[source,shell]
....
# webcamd -l
....

The output should be similar to the following:

[.programlisting]
....
webcamd [-d ugen0.2] -N SunplusIT-Inc-HP-TrueVision-HD-Camera -S unknown -M 0 <.>
webcamd [-d ugen1.3] -N Realtek-802-11n-WLAN-Adapter -S 00e04c000001 -M 0
....
<.> Available webcam

Configure the available webcam executing the following command:

[source,shell]
....
# sysrc webcamd_0_flags="-d ugen0.2" <.>
....

[NOTE]
====
Note here that if this is a plug-and-play USB webcam, changing the USB port to which it is connected will change the output from `webcamd -l`, and the entry in rc.conf might need to be updated.
For laptops that use USB integrated webcams, this should not be an issue.
====

The man:webcamd[8] service must be started by executing the following command:

[source,shell]
....
# service webcamd start
....

The output should be similar to the following:

[.programlisting]
....
Starting webcamd.
webcamd 1616 - - Attached to ugen0.2[0]
....

package:multimedia/pwcview[] can be used to check the proper functioning of the webcam.
The following command can be used to execute package:multimedia/pwcview[]:

[source,shell]
....
% pwcview -f 30 -s vga
....

Then package:multimedia/pwcview[] will display the webcam:

image::pwcview.png[pwcview showing Absolute FreeBSD 3rd edition as an example]

[[meetings-software-status]]
=== Meetings software status

FreeBSD currently supports the following tools used to carry out videoconferences.

.Meeting software
[options="header", cols="1,1,1,1"]
|===
| Name | Firefox status | Chromium status | Website

| Microsoft Teams
| Does not work
| Works
| link:https://teams.live.com[]

| Google Meet
| Works
| Works
| link:https://meet.google.com/[]

| Zoom
| Works
| Works
| link:https://zoom.us[]

| Jitsi
| Does not work
| Works
| link:https://meet.jit.si/[]

| BigBlueButton
| Does not work
| Works
| link:https://bigbluebutton.org/[]

|===

[[scanners]]
== Image Scanners

In FreeBSD, access to image scanners is provided by link:http://www.sane-project.org[SANE (Scanner Access Now Easy)], which is available in the FreeBSD Ports Collection.

[[scanners-kernel-usb]]
=== Checking the Scanner

Before attempting any configuration it is important to check the scanner is supported by SANE.

With the scanner connected, run the following command to get all connected USB devices:

[source,shell]
....
# usbconfig list
....

The output should be similar to the following:

[.programlisting]
....
ugen4.2: <LITE-ON Technology USB NetVista Full Width Keyboard.> at usbus4, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (70mA)
ugen4.3: <Logitech USB Optical Mouse> at usbus4, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen3.2: <HP Deskjet 1050 J410 series> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)
....

Run the following command to obtain the `idVendor` and the `idProduct`:

[source,shell]
....
# usbconfig -d 3.2 dump_device_desc
....

[NOTE]
====
Note here that the scanner is a plug-and-play device, and changing the USB port to which it is connected will change the output from `usbconfig list`.
====

The output should be similar to the following:

[.programlisting]
....
ugen3.2: <HP Deskjet 1050 J410 series> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)

bLength = 0x0012
bDescriptorType = 0x0001
bcdUSB = 0x0200
bDeviceClass = 0x0000  <Probed by interface class>
bDeviceSubClass = 0x0000
bDeviceProtocol = 0x0000
bMaxPacketSize0 = 0x0040
idVendor = 0x03f0
idProduct = 0x8911
bcdDevice = 0x0100
iManufacturer = 0x0001  <HP>
iProduct = 0x0002  <Deskjet 1050 J410 series>
bNumConfigurations = 0x0001
....

Once the `idVendor` and the `idProduct` have been obtained, it is necessary to check in the link:http://www.sane-project.org/lists/sane-mfgs-cvs.html[list of supported devices of SANE] if the scanner is supported by filtering by the idProduct. 

[[_sane_configuration]]
=== SANE Configuration

SANE provides the access to the scanner via backends.
To be able to scan with FreeBSD the package:graphics/sane-backends[] package must be installed by running the following command:

[source,shell]
....
# pkg install sane-backends
....

[TIP]
====
Some USB scanners require firmware to be loaded.
Like the HP scanner used in the example above, which needs the package package:print/hplip[] installed.
====

After installing the necessary packages man:devd[8] must be configured to allow FreeBSD access to the scanner.

Add the `saned.conf` file to [.filename]#/usr/local/etc/devd/saned.conf# with the following content:

[.programlisting]
....
notify 100 {
        match "system" "USB";
        match "subsystem" "INTERFACE";
        match "type" "ATTACH";
        match "cdev" "ugen[0-9].[0-9]";
        match "vendor" "0x03f0"; <.>
        match "product" "0x8911"; <.>
        action "chown -L cups:saned /dev/\$cdev && chmod -L 660 /dev/\$cdev";
};
....

<.> `vendor`: Is the idVendor obtained previously by running the `usbconfig -d 3.2 dump_device_desc` command.
<.> `product`: Is the idProduct obtained previously by running the `usbconfig -d 3.2 dump_device_desc` command.

After that man:devd[8] must be restarted by running the following command:

[source,shell]
....
# service devd restart
....

The SANE backends include man:scanimage[1] which can be used to list the devices and perform an image acquisition.

Execute man:scanimage[1] with `-L` argument to list the scanner devices:

[source,shell]
....
# scanimage -L
....

The output should be similar to the following:

[.programlisting]
....
device `hpaio:/usb/Deskjet_1050_J410_series?serial=XXXXXXXXXXXXXX' is a Hewlett-Packard Deskjet_1050_J410_series all-in-one
....

If man:scanimage[1] is not able to identify the scanner, this message will appear:

[.programlisting]
....
No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).
....

Once man:scanimage[1] sees the scanner, the configuration is complete and the scanner is now ready to use.

To activate the service and have it run at boot execute the following command:

[source,shell]
....
# sysrc saned_enable=YES
....

While man:scanimage[1] can be used to perform an image acquisition from the command line, it is often preferable to use a graphical interface to perform image scanning.

.Graphical scanner programs
[options="header", cols="1,1,1"]
|===
| Name | License | Package

| skanlite
| GPL 2.0
| graphics/skanlite

| GNOME Simple Scan
| GPL 3.0
| graphics/simple-scan

| XSANE
| GPL 2.0
| graphics/xsane

|===