https://wiki.archlinux.org/api.php?action=feedcontributions&user=Nikolam&feedformat=atomArchWiki - User contributions [en]2024-03-29T13:30:21ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=FFmpeg&diff=577824FFmpeg2019-07-23T23:23:10Z<p>Nikolam: Typo</p>
<hr />
<div>[[Category:Audio]]<br />
[[Category:Video]]<br />
[[ja:FFmpeg]]<br />
[[zh-hans:FFmpeg]]<br />
{{Related articles start}}<br />
{{Related|Convert FLAC to MP3#With FFmpeg}}<br />
{{Related articles end}}<br />
<br />
<br />
From the project [http://www.ffmpeg.org/ home page]:<br />
:FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.<br />
<br />
== Installation ==<br />
{{Note|You may encounter FFmpeg forks like ''libav'' and ''avconv'', see [http://blog.pkh.me/p/13-the-ffmpeg-libav-situation.html The FFmpeg/Libav situation] for a blog article about the differences between the project and the current status of FFmpeg.}}<br />
<br />
[[Install]] the {{Pkg|ffmpeg}} package.<br />
<br />
For the development version, install the {{AUR|ffmpeg-git}} package. There is also {{AUR|ffmpeg-full}}, which is built with as many optional features enabled as possible.<br />
<br />
== Encoding examples ==<br />
{{Note|<br />
*It is important parameters are specified in the correct order (e.g. input, video, filters, audio, output), failing to do so may cause parameters being skipped or will prevent FFmpeg from executing.<br />
*FFmpeg should automatically choose the number of CPU threads available. However you may want to force the number of threads available by the parameter {{ic|-threads <number>}}.<br />
}}<br />
<br />
=== Screen capture ===<br />
<br />
FFmpeg includes the [http://www.ffmpeg.org/ffmpeg-devices.html#x11grab x11grab] and [http://www.ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA] virtual devices that enable capturing the entire user display and audio input.<br />
<br />
To take a screenshot {{ic|screen.png}}:<br />
<br />
$ ffmpeg -f x11grab -video_size 1920x1080 -i $DISPLAY -vframes 1 screen.png<br />
<br />
where {{ic|-video_size}} specifies the size of the area to capture.<br />
<br />
To take a screencast {{ic|screen.mkv}} with lossless encoding and without audio:<br />
<br />
$ ffmpeg -f x11grab -video_size 1920x1080 -framerate 25 -i $DISPLAY -c:v ffvhuff screen.mkv<br />
<br />
Here, the Huffyuv codec is used, which is fast, but produces huge file sizes.<br />
<br />
To take a screencast {{ic|screen.mp4}} with lossy encoding and with audio:<br />
<br />
$ ffmpeg -f x11grab -video_size 1920x1080 -framerate 25 -i $DISPLAY -f alsa -i default -c:v libx264 -preset ultrafast -c:a aac screen.mp4<br />
<br />
Here, the x264 codec with the fastest possible encoding speed is used. Other codecs can be used; if writing each frame is too slow (either due to inadequate disk performance or slow encoding), then frames will be dropped and video output will be choppy.<br />
<br />
See also the [https://trac.ffmpeg.org/wiki/Capture/Desktop#Linux official documentation].<br />
<br />
=== Recording webcam ===<br />
<br />
FFmpeg includes the [http://www.ffmpeg.org/ffmpeg-devices.html#video4linux2_002c-v4l2 video4linux2] and [http://www.ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA] input devices that enable capturing webcam and audio input.<br />
<br />
The following command will record a video {{ic|webcam.mp4}} from the webcam without audio, assuming that the webcam is correctly recognized under {{ic|/dev/video0}}:<br />
<br />
$ ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -c:v libx264 -preset ultrafast webcam.mp4<br />
<br />
where {{ic|-video_size}} specifies the largest allowed image size from the webcam.<br />
<br />
The above produces a silent video. To record a video {{ic|webcam.mp4}} from the webcam with audio:<br />
<br />
$ ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -f alsa -i default -c:v libx264 -preset ultrafast -c:a aac webcam.mp4<br />
<br />
Here, the x264 codec with the fastest possible encoding speed is used. Other codecs can be used; if writing each frame is too slow (either due to inadequate disk performance or slow encoding), then frames will be dropped and video output will be choppy.<br />
<br />
See also the [https://trac.ffmpeg.org/wiki/Capture/Webcam#Linux official documentation].<br />
<br />
=== VOB to any container ===<br />
<br />
Concatenate the desired [[Wikipedia:VOB|VOB]] files into a single stream and mux them to MPEG-2:<br />
$ cat f0.VOB f1.VOB f2.VOB | ffmpeg -i - out.mp2<br />
<br />
=== x264 lossless ===<br />
<br />
The ''ultrafast'' preset will provide the fastest encoding and is useful for quick capturing (such as screencasting):<br />
$ ffmpeg -i input -c:v libx264 -preset ultrafast -qp 0 -c:a copy output<br />
On the opposite end of the preset spectrum is ''veryslow'' and will encode slower than ''ultrafast'' but provide a smaller output file size:<br />
$ ffmpeg -i input -c:v libx264 -preset veryslow -qp 0 -c:a copy output<br />
Both examples will provide the same quality output.<br />
<br />
{{Tip|If your computer is able to handle {{ic|-preset superfast}} in realtime, you should use that instead of {{ic|-preset ultrafast}}. Ultrafast is ''far'' less efficient compression than superfast.}}<br />
<br />
=== x265 ===<br />
<br />
In encoding x265 files, you may need to specify the aspect ratio of the file via {{ic|-aspect <width:height>}}. Example :<br />
{{bc|<nowiki> ffmpeg -i input -c:v libx265 -aspect 1920:1080 -preset veryslow -x265-params crf=20 output</nowiki>}}<br />
<br />
=== Single-pass MPEG-2 (near lossless) ===<br />
<br />
Allow FFmpeg to automatically set DVD standardized parameters. Encode to DVD [[Wikipedia:MPEG-2|MPEG-2]] at ~30 FPS:<br />
<br />
$ ffmpeg -i ''video''.VOB -target ntsc-dvd ''output''.mpg<br />
<br />
Encode to DVD MPEG-2 at ~24 FPS:<br />
<br />
$ ffmpeg -i ''video''.VOB -target film-dvd ''output''.mpg<br />
<br />
=== x264: constant rate factor ===<br />
<br />
Used when you want a specific quality output. General usage is to use the highest {{ic|-crf}} value that still provides an acceptable quality. Lower values are higher quality; 0 is lossless, 18 is visually lossless, and 23 is the default value. A sane range is between 18 and 28. Use the slowest {{ic|-preset}} you have patience for. See the [https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide x264 Encoding Guide] for more information.<br />
$ ffmpeg -i ''video'' -c:v libx264 -tune film -preset slow -crf 22 -x264opts fast_pskip=0 -c:a libmp3lame -aq 4 ''output''.mkv<br />
{{ic|-tune}} option can be used to [http://forum.doom9.org/showthread.php?t=149394 match the type and content of the of media being encoded].<br />
<br />
=== Two-pass x264 (very high-quality) ===<br />
<br />
Audio deactivated as only video statistics are recorded during the first of multiple pass runs: <br />
$ ffmpeg -i ''video''.VOB -an -vcodec libx264 -pass 1 -preset veryslow \<br />
-threads 0 -b:v 3000k -x264opts frameref=15:fast_pskip=0 -f rawvideo -y /dev/null<br />
Container format is automatically detected and muxed into from the output file extenstion ({{ic|.mkv}}):<br />
$ ffmpeg -i ''video''.VOB -acodec aac -b:a 256k -ar 96000 -vcodec libx264 \<br />
-pass 2 -preset veryslow -threads 0 -b:v 3000k -x264opts frameref=15:fast_pskip=0 ''video''.mkv<br />
<br />
=== x264 video stabilization ===<br />
Video stablization using the vid.stab plugin entails two passes. <br />
<br />
==== First pass ====<br />
<br />
The first pass records stabilization parameters to a file and/or a test video for visual analysis.<br />
<br />
* Records stabilization parameters to a file only <br />
<br />
$ ffmpeg -i input -vf vidstabdetect=stepsize=4:mincontrast=0:result=transforms.trf -f null -<br />
<br />
* Records stabilization parameters to a file and create test video "output-stab" for visual analysis<br />
<br />
$ ffmpeg -i input -vf vidstabdetect=stepsize=4:mincontrast=0:result=transforms.trf -f output-stab<br />
<br />
==== Second pass ====<br />
<br />
The second pass parses the stabilization parameters generated from the first pass and applies them to produce "output-stab_final". You will want to apply any additional filters at this point so as to avoid subsequent transcoding to preserve as much video quality as possible. The following example performs the following in addition to video stabilization:<br />
<br />
* {{ic|unsharp}} is recommended by the author of vid.stab. Here we are simply using the defaults of 5:5:1.0:5:5:1.0<br />
* {{Tip|1=fade=t=in:st=0:d=4}} fade in from black starting from the beginning of the file for four seconds<br />
* {{Tip|1=fade=t=out:st=60:d=4}} fade out to black starting from sixty seconds into the video for four seconds<br />
* {{ic|-c:a pcm_s16le}} XAVC-S codec records in pcm_s16be which is losslessly transcoded to pcm_s16le<br />
<br />
$ ffmpeg -i input -vf vidstabtransform=smoothing=30:interpol=bicubic:input=transforms.trf,unsharp,fade=t=in:st=0:d=4,fade=t=out:st=60:d=4 -c:v libx264 -tune film -preset veryslow -crf 8 -x264opts fast_pskip=0 -c:a pcm_s16le output-stab_final<br />
<br />
=== Subtitles ===<br />
<br />
==== Extracting ====<br />
<br />
Subtitles embedded in container files, such as MPEG-2 and Matroska, can be extracted and converted into SRT, SSA, among other subtitle formats.<br />
<br />
* Inspect a file to determine if it contains a subtitle stream:<br />
<br />
{{hc|$ ffprobe -hide_banner foo.mkv|<br />
...<br />
Stream #0:0(und): Video: h264 (High), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)<br />
Metadata:<br />
CREATION_TIME : 2012-06-05 05:04:15<br />
LANGUAGE : und<br />
Stream #0:1(und): Audio: aac, 44100 Hz, stereo, fltp (default)<br />
Metadata:<br />
CREATION_TIME : 2012-06-05 05:10:34<br />
LANGUAGE : und<br />
HANDLER_NAME : GPAC ISO Audio Handler<br />
'''Stream #0:2: Subtitle: ssa (default)'''<br />
}}<br />
<br />
* {{ic|foo.mkv}} has an embedded SSA subtitle which can be extracted into an independent file:<br />
<br />
$ ffmpeg -i foo.mkv foo.ssa<br />
<br />
Add {{ic|-c:s srt}} to save subtitles in desirable format, e.g. [[Wikipedia:SubRip|SubRip]]:<br />
<br />
$ ffmpeg -i foo.mkv -c:s srt foo.srt<br />
<br />
When dealing with multiple subtitles, you may need to specify the stream that needs to be extracted using the {{ic|-map <key>:<stream>}} parameter:<br />
<br />
$ ffmpeg -i foo.mkv -map 0:2 foo.ssa<br />
<br />
==== Hardsubbing ====<br />
<br />
(instructions based on [http://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo HowToBurnSubtitlesIntoVideo] at the FFmpeg wiki)<br />
<br />
[[Wikipedia:Hardsub|Hardsubbing]] entails merging subtitles with the video. Hardsubs can't be disabled, nor language switched.<br />
<br />
* Overlay {{ic|foo.mpg}} with the subtitles in {{ic|foo.ssa}}:<br />
<br />
$ ffmpeg -i foo.mpg -vf subtitles=foo.ssa out.mpg<br />
<br />
=== Volume gain ===<br />
<br />
Volume gain can be modified through {{ic|ffmpeg}}'s filter function. Fist select the audio stream by using: {{ic|-af}} or {{ic|-filter:a}}, then select the {{ic|volume}} filter, and then the number that you want to change the stream by.<br />
<br />
<br />
'''Example''':<br />
<br />
$ ffmpeg -i input.flac -af volume=3.0 ouput.flac<br />
<br />
# -af colume=0.5 Half volume gain<br />
# -af volume=1.0 Unchanged volume gain<br />
# -af volume=2.0 Double volume gain<br />
<br />
<br />
{{note|<br />
* Doubling a file's volume gain, is not the same thing as doubling its volume. You will have to experiment to find the right volume.<br />
* ffmpeg writes changes into an output file. So, unlike mp3gain or ogggain, the source file will be left unchanged.<br />
}}<br />
<br />
=== Extracting audio ===<br />
<br />
{{hc|$ ffmpeg -i ''video''.mpg|<br />
...<br />
Input #0, avi, from '''video''.mpg':<br />
Duration: 01:58:28.96, start: 0.000000, bitrate: 3000 kb/s<br />
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 1:1 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.97 tbc<br />
Stream #0.1: Audio: ac3, 48000 Hz, stereo, s16, 384 kb/s<br />
Stream #0.2: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s<br />
Stream #0.3: Audio: dts, 48000 Hz, 5.1 768 kb/s<br />
...<br />
}}<br />
<br />
Extract the first ({{ic|-map 0:1}}) [[Wikipedia:Dolby_Digital|AC-3]] encoded audio stream exactly as it was multiplexed into the file: <br />
$ ffmpeg -i ''video''.mpg -map 0:1 -acodec copy -vn ''video''.ac3<br />
Convert the third ({{ic|-map 0:3}}) [[Wikipedia:DTS_(sound_system)|DTS]] audio stream to an [[Wikipedia:Advanced_Audio_Coding|AAC]] file with a bitrate of 192 kb/s and a [[Wikipedia:Sampling_rate|sampling rate]] of 96000 Hz:<br />
$ ffmpeg -i ''video''.mpg -map 0:3 -acodec aac -b:a 192k -ar 96000 -vn ''output''.aac<br />
{{ic|-vn}} disables the processing of the video stream.<br />
<br />
Extract audio stream with certain time interval: <br />
$ ffmpeg -ss 00:01:25 -t 00:00:05 -i ''video''.mpg -map 0:1 -acodec copy -vn ''output''.ac3<br />
{{ic|-ss}} specifies the start point, and {{ic|-t}} specifies the duration.<br />
<br />
=== Stripping audio ===<br />
<br />
# Copy the first video stream ({{ic|-map 0:0}}) along with the second AC-3 audio stream ({{ic|-map 0:2}}).<br />
# Convert the AC-3 audio stream to two-channel MP3 with a bitrate of 128 kb/s and a sampling rate of 48000 Hz.<br />
$ ffmpeg -i ''video''.mpg -map 0:0 -map 0:2 -vcodec copy -acodec libmp3lame \<br />
-b:a 128k -ar 48000 -ac 2 ''video''.mkv<br />
<br />
{{hc|$ ffmpeg -i ''video''.mkv|<br />
...<br />
Input #0, avi, from '''video''.mpg':<br />
Duration: 01:58:28.96, start: 0.000000, bitrate: 3000 kb/s<br />
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 1:1 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.97 tbc<br />
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s<br />
}}<br />
<br />
{{Note|Removing undesired audio streams allows for additional bits to be allocated towards improving video quality.}}<br />
<br />
=== Splitting files ===<br />
<br />
You can use the {{ic|copy}} codec to perform operations on a file without changing the encoding. For example, this allows you to easily split any kind of media file into two:<br />
<br />
$ ffmpeg -i file.ext -t 00:05:30 -c copy part1.ext -ss 00:05:30 -c copy part2.ext<br />
<br />
=== Hardware video acceleration ===<br />
{{Expansion|Missing [[VA-API]] and possible other solutions like [[opencl]].}}<br />
<br />
{{Warning|Encoding may fail when using hardware acceleration, use software encoding as a fallback.}}<br />
<br />
Encoding performance may be improved by using [https://trac.ffmpeg.org/wiki/HWAccelIntro hardware acceleration API's], however only a specific kind of codec(s) are allowed and/or may not always produce the same result when using software encoding.<br />
<br />
==== VA-API ====<br />
[[VA-API]] can be used for encoding and decoding on Intel CPUs (requires {{Pkg|libva-intel-driver}}) and on certain AMD GPUs when using the open-source [[AMDGPU]] driver (requires {{Pkg|libva-mesa-driver}}).<br />
See the following [https://gist.github.com/Brainiarc7/95c9338a737aa36d9bb2931bed379219 GitHub gist] and [https://wiki.libav.org/Hardware/vaapi Libav documentation] for information about available parameters and supported platforms.<br />
<br />
An example of encoding using the supported H.264 codec:<br />
<br />
$ ffmpeg -threads 1 -i file.ext -vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi -vf format='nv12|vaapi,hwupload' output.mp4<br />
<br />
==== NVIDIA NVENC/NVDEC ====<br />
[[w:Nvidia NVENC|NVENC]] and [[w:Nvidia NVDEC|NVDEC]] can be used for encoding/decoding when using the proprietary [[NVIDIA]] driver with the {{Pkg|nvidia-utils}} package installed. Minimum supported GPUs are from 600 series, see [[Hardware video acceleration#NVIDIA]] for details.<br />
<br />
The [https://gist.github.com/Brainiarc7/8b471ff91319483cdb725f615908286e following gist] provides some techniques. NVENC is somewhat similar to [[CUDA]], thus it works even from terminal session. Depending on hardware NVENC is several times faster than Intel's VA-API encoders.<br />
<br />
To print available options execute ({{ic|hevc_nvenc}} may also be available):<br />
<br />
$ ffmpeg -help encoder=h264_nvenc<br />
<br />
Example usage:<br />
<br />
$ ffmpeg -i source.ext -c:v h264_nvenc -rc constqp -qp 28 output.mkv<br />
<br />
==== Intel QuickSync (QSV) ====<br />
<br />
[https://www.intel.com/content/www/us/en/architecture-and-technology/quick-sync-video/quick-sync-video-general.html|Intel® Quick Sync Video] uses media processing capabilities of an [[Intel]] GPU to decode and encode fast, enabling the processor to complete other tasks and improving system responsiveness.<br />
<br />
This requires {{AUR|intel-media-sdk}} to be installed and FFmpeg needs to be build with {{ic|--enable-libmfx}}. Packages are available in [[AUR]]: {{AUR|ffmpeg-qsv}} or {{AUR|ffmpeg-qsv-git}}. The package {{pkg|ffmpeg}} doesn't have this flag enabled.<br />
<br />
The usage of QuickSync is describe in the [https://trac.ffmpeg.org/wiki/Hardware/QuickSync FFmpeg Wiki]. It is recommended to use [[VA-API]] [https://trac.ffmpeg.org/wiki/Hardware/VAAPI] with either the ''iHD'' or ''i965'' driver instead of using ''libmfx'' directly, see the FFmpeg Wiki section ''Hybrid transcode'' for encoding examples and [[Hardware video acceleration#Configuring VA-API]] for driver instructions.<br />
<br />
== Preset files ==<br />
<br />
Populate {{ic|~/.ffmpeg}} with the default [http://ffmpeg.org/ffmpeg.html#Preset-files preset files]: <br />
<br />
$ cp -iR /usr/share/ffmpeg ~/.ffmpeg<br />
<br />
Create new and/or modify the default preset files:<br />
<br />
{{hc|~/.ffmpeg/libavcodec-vhq.ffpreset|2=<br />
vtag=DX50<br />
mbd=2<br />
trellis=2<br />
flags=+cbp+mv0<br />
pre_dia_size=4<br />
dia_size=4<br />
precmp=4<br />
cmp=4<br />
subcmp=4<br />
preme=2<br />
qns=2<br />
}}<br />
<br />
=== Using preset files ===<br />
<br />
Enable the {{ic|-vpre}} option after declaring the desired {{ic|-vcodec}}<br />
<br />
==== libavcodec-vhq.ffpreset ====<br />
<br />
* {{ic|libavcodec}} '''=''' Name of the vcodec/acodec<br />
* {{ic|vhq}} '''=''' Name of specific preset to be called out<br />
* {{ic|ffpreset}} '''=''' FFmpeg preset filetype suffix <br />
<br />
== Tips and tricks ==<br />
<br />
=== Output the duration of a video ===<br />
<br />
$ ffprobe -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 file.ext<br />
<br />
=== Output stream information as JSON ===<br />
<br />
$ ffprobe -v quiet -print_format json -show_format -show_streams file.ext<br />
<br />
=== Create a screen of the video every X frames ===<br />
<br />
$ ffmpeg -i file.ext -an -s 319x180 -vf fps=1/'''100''' -qscale:v 75 %03d.jpg<br />
<br />
== See also ==<br />
<br />
* [http://ffmpeg.org/ffmpeg.html FFmpeg documentation] - official documentation<br />
* [https://trac.ffmpeg.org/wiki#Encoding Encoding] - FFmpeg wiki<br />
* [http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html Encoding with the x264 codec] - MEncoder documentation<br />
* [http://avidemux.org/admWiki/doku.php?id=tutorial:h.264 H.264 encoding guide] - Avidemux wiki<br />
* [http://howto-pages.org/ffmpeg/ Using FFmpeg] - Linux how to pages<br />
* [http://ffmpeg.org/general.html#Supported-File-Formats-and-Codecs List] of supported audio and video streams</div>Nikolamhttps://wiki.archlinux.org/index.php?title=PulseAudio/Troubleshooting&diff=577823PulseAudio/Troubleshooting2019-07-23T23:02:47Z<p>Nikolam: Added a note for the error I encountered on my system, but couldn't find the information about it anywhere on the internet. PA docs doesn't mention it. Folks at PA IRC helped me figure this one out. Might help someone in future.</p>
<hr />
<div>[[Category:Sound]]<br />
[[it:PulseAudio/Troubleshooting]]<br />
[[ja:PulseAudio/トラブルシューティング]]<br />
[[ru:PulseAudio/Troubleshooting]]<br />
See [[PulseAudio]] for the main article.<br />
<br />
== Volume ==<br />
<br />
Here you will find some hints on volume issues and why you may not hear anything.<br />
<br />
=== Auto-Mute Mode ===<br />
<br />
''Auto-Mute Mode'' is a configurable setting from {{ic|amixer}}. For more information, see [[ALSA#Disabling auto mute on startup]].<br />
<br />
=== Muted audio device ===<br />
<br />
If one experiences no audio output via any means while using [[ALSA]], attempt to unmute the sound card. To do this, launch {{ic|alsamixer}} and make sure each column has a green {{ic|00}} under it (this can be toggled by pressing {{ic|m}}):<br />
<br />
$ alsamixer -c 0<br />
<br />
{{Note|alsamixer will not tell you which output device is set as the default. One possible cause of no sound after install is that PulseAudio detects the wrong output device as a default. Install {{Pkg|pavucontrol}} and check if there is any output on the pavucontrol panel when playing a ''.wav'' file.}}<br />
<br />
=== Output stuck muted while Master is toggled ===<br />
<br />
In setups with multiple outputs (e.g. 'Headphone' and 'Speaker') using plain amixer to toggle Master can trigger PulseAudio to mute the active output too, but it does not necessarily unmute it when Master is toggled back to be unmuted. [https://lists.freedesktop.org/archives/pulseaudio-discuss/2015-December/025062.html] To resolve this, amixer must have the device flag set to 'pulse':<br />
<br />
$ amixer -D pulse sset Master toggle<br />
<br />
This will cause amixer to ask PulseAudio to do the toggling rather than toggling it directly.<br />
Because of this, PulseAudio will correctly unmute Master as well as any applicable output.<br />
<br />
=== Muted application ===<br />
<br />
If a specific application is muted or low while all else seems to be in order, it may be due to individual {{ic|sink-input}} settings. With the offending application playing audio, run:<br />
<br />
$ pacmd list-sink-inputs<br />
<br />
Find and make note of the {{ic|index}} of the corresponding {{ic|sink input}}. The {{ic|properties:}} {{ic|application.name}} and {{ic|application.process.binary}}, among others, should help here. Ensure sane settings are present, specifically those of {{ic|muted}} and {{ic|volume}}.<br />
If the sink is muted, it can be unmuted by:<br />
<br />
$ pacmd set-sink-input-mute <index> false<br />
<br />
If the volume needs adjusting, it can be set to 100% by:<br />
<br />
$ pacmd set-sink-input-volume <index> 0x10000<br />
<br />
{{Note|If {{ic|pacmd}} reports {{ic|0 sink input(s)}}, double-check that the application is playing audio. If it is still absent, verify that other applications show up as sink inputs.}}<br />
<br />
=== Volume adjustment does not work properly ===<br />
<br />
Check {{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common}}.<br />
<br />
If the volume does not appear to increment/decrement properly using {{ic|alsamixer}} or {{ic|amixer}}, it may be due to PulseAudio having a larger number of increments (65537 to be exact). Try using larger values when changing volume (e.g. {{ic|amixer set Master 655+}}).<br />
<br />
=== Per-application volumes change when the Master volume is adjusted ===<br />
<br />
This is because PulseAudio uses flat volumes by default, instead of relative volumes, relative to an absolute master volume. If this is found to be inconvenient, asinine, or otherwise undesireable, relative volumes can be enabled by disabling flat volumes in the PulseAudio daemon's configuration file:<br />
<br />
{{hc|/etc/pulse/daemon.conf or ~/.config/pulse/daemon.conf|2=<br />
flat-volumes = no<br />
}}<br />
<br />
and then restarting PulseAudio by executing<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
=== Volume gets louder every time a new application is started ===<br />
<br />
Per default, it seems as if changing the volume in an application sets the global system volume to that level instead of only affecting the respective application. Applications setting their volume on startup will therefore cause the system volume to "jump".<br />
<br />
Fix this by disabling flat volumes, as demonstrated in the previous section. When Pulse comes back after a few seconds, applications will not alter the global system volume anymore but have their own volume level again.<br />
<br />
{{Note|A previously installed and removed pulseaudio-equalizer may leave behind remnants of the setup in {{ic|~/.config/pulse/default.pa}} or {{ic|~/.pulse/default.pa}} which can also cause maximized volume trouble. Comment that out as needed.}}<br />
<br />
=== Sound output is only mono on M-Audio Audiophile 2496 sound card ===<br />
<br />
Add the following:<br />
<br />
{{hc|/etc/pulseaudio/default.pa|2=<br />
load-module module-alsa-sink sink_name=delta_out device=hw:M2496 format=s24le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7<br />
load-module module-alsa-source source_name=delta_in device=hw:M2496 format=s24le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9<br />
set-default-sink delta_out<br />
set-default-source delta_in<br />
}}<br />
<br />
=== No sound below a volume cutoff or Clipping on a particular output device ===<br />
<br />
Known issue (will not fix): https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/223133<br />
<br />
If sound does not play when PulseAudio's volume is set below a certain level, or if you hear clipping on output even at low volume (including bluetooth devices), try setting {{ic|1=ignore_dB=1}} in {{ic|/etc/pulse/default.pa}}:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-udev-detect ignore_dB=1<br />
}}<br />
<br />
However, be aware that it may cause another bug preventing PulseAudio to unmute speakers when headphones or other audio devices are unplugged.<br />
<br />
=== Low volume for internal microphone ===<br />
<br />
If you experience low volume on internal notebook microphone, try setting:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
set-source-volume 1 300000<br />
}}<br />
<br />
=== Clients alter master output volume (a.k.a. volume jumps to 100% after running application) ===<br />
<br />
If changing the volume in specific applications or simply running an application changes the master output volume this is likely due to flat volumes mode of pulseaudio. Before disabling it, KDE users should try lowering their system notifications volume in ''System Settings -> Application and System Notifications -> Manage Notifications'' under the ''Player Settings'' tab to something reasonable. Changing the ''Event Sounds'' volume in KMix or another volume mixer application will not help here. This should make the flat-volumes mode work out as intended, if it does not work, some other application is likely requesting 100% volume when its playing something. If all else fails, you can try to disable flat-volumes:<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
flat-volumes = no<br />
}}<br />
<br />
Then restart PulseAudio daemon:<br />
<br />
# pulseaudio -k<br />
# pulseaudio --start<br />
<br />
=== No sound after resume from suspend ===<br />
<br />
If audio generally works, but stops after resume from suspend, try "reloading" PulseAudio by executing:<br />
<br />
$ /usr/bin/pasuspender /bin/true<br />
<br />
This is better than completely killing and restarting it ({{ic|pulseaudio -k}} followed by {{ic|pulseaudio --start}}), because it does not break already running applications.<br />
<br />
If the above fixes your problem, you may wish to automate it, by creating a systemd service file.<br />
<br />
1. Create the template service file in {{ic|/etc/systemd/system/resume-fix-pulseaudio@.service}}:<br />
<br />
[Unit]<br />
Description=Fix PulseAudio after resume from suspend<br />
After=suspend.target<br />
<br />
[Service]<br />
User=%I<br />
Type=oneshot<br />
Environment="XDG_RUNTIME_DIR=/run/user/%U"<br />
ExecStart=/usr/bin/pasuspender /bin/true<br />
<br />
[Install]<br />
WantedBy=suspend.target<br />
<br />
2. Enable it for your user account<br />
<br />
# systemctl enable resume-fix-pulseaudio@''YOUR_USERNAME_HERE''.service<br />
<br />
3. Reload systemd<br />
<br />
# systemctl --system daemon-reload<br />
<br />
=== ALSA channels mute when headphones are plugged/unplugged improperly ===<br />
<br />
If when you unplug your headphones or plug them in the audio remains muted in alsamixer on the wrong channel due to it being set to 0%, you may be able to fix it by opening {{ic|/etc/pulse/default.pa}} and commenting out the line:<br />
<br />
load-module module-switch-on-port-available<br />
<br />
=== Volume resets to 50% every few seconds ===<br />
<br />
Install {{Pkg|alsa-tools}} and use:<br />
<br />
$ hdajackretask<br />
<br />
Set "Not Connected" to everything but the ports you are using. It seems the other unused audio ports on the motherboard interfere with the used ones.<br />
Then if you want use the Boot Override to save this change between reboots. There is a possibility it is the Front Green Headphone that is causing the bug, if you need it override the Front Microphone to Headphone and the Front Green Headphone to "Not Connected" and use the Front Microphone port as your headphone port.<br />
<br />
More info about this problem: [https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1585084].<br />
<br />
=== Volume low/too quiet on analog headphones/speakers ===<br />
<br />
If you added the {{ic|1=ignore_dB=1}} option earlier to the {{ic|load-module module-udev-detect}} line in your {{ic|/etc/pulse/default.pa}}, try removing it.<br />
<br />
== Microphone ==<br />
<br />
=== Microphone not detected by PulseAudio ===<br />
<br />
Determine the card and device number of your mic:<br />
<br />
{{hc|$ arecord -l|<br />
**** List of CAPTURE Hardware Devices ****<br />
card 0: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
}}<br />
<br />
In {{ic|hw:''CARD'',''DEVICE''}} notation, you would specify the above device as {{ic|hw:0,0}}.<br />
<br />
Then, edit {{ic|/etc/pulse/default.pa}} and insert a {{ic|load-module}} line specifying your device as follows:<br />
<br />
load-module module-alsa-source device=hw:0,0<br />
# the line above should be somewhere before the line below<br />
.ifexists module-udev-detect.so<br />
<br />
Finally, restart pulseaudio to apply the new settings:<br />
<br />
$ pulseaudio -k ; pulseaudio -D<br />
<br />
If everything worked correctly, you should now see your mic show up when running {{ic|pavucontrol}} (under the {{ic|Input Devices}} tab).<br />
<br />
=== PulseAudio uses wrong microphone ===<br />
<br />
If PulseAudio uses the wrong microphone, and changing the Input Device with Pavucontrol did not help, take a look at alsamixer. It seems that Pavucontrol does not always set the input source correctly.<br />
<br />
$ alsamixer<br />
<br />
Press {{ic|F6}} and choose your sound card, e.g. HDA Intel. Now press {{ic|F5}} to display all items. Try to find the item: {{ic|Input Source}}. With the up/down arrow keys you are able to change the input source.<br />
<br />
Now try if the correct microphone is used for recording.<br />
<br />
=== No microphone on ThinkPad T400/T500/T420 ===<br />
<br />
Run:<br />
<br />
$ alsamixer -c 0<br />
<br />
Unmute and maximize the volume of the "Internal Mic".<br />
<br />
Once you see the device with:<br />
<br />
$ arecord -l<br />
<br />
you might still need to adjust the settings. The microphone and the audio jack are duplexed. Set the configuration of the internal audio in pavucontrol to ''Analog Stereo Duplex''.<br />
<br />
=== No microphone input on Acer Aspire One ===<br />
<br />
Install pavucontrol, unlink the microphone channels and turn down the left one to 0.<br />
<br />
=== Static noise in microphone recording ===<br />
<br />
If we are getting static noise in Skype, gnome-sound-recorder, arecord, etc.'s recordings, then the sound card sample rate is incorrect. That is why there is static noise in Linux microphone recordings. To fix this, we need to set the sampling rate in {{ic|/etc/pulse/daemon.conf}} for the sound hardware.<br />
<br />
In addition to the guide below, since [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/ PulseAudio 11] it is possible to set {{ic|1=avoid-resampling = yes}} in [[PulseAudio#daemon.conf|daemon.conf]].<br />
<br />
==== Determine sound cards in the system (1/5) ====<br />
<br />
This requires {{Pkg|alsa-utils}} and related packages to be installed:<br />
<br />
{{hc|$ arecord --list-devices|<br />
**** List of CAPTURE Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
}}<br />
<br />
The sound card is {{ic|hw:''x'',''y''}} where {{ic|''x''}} is the card number and {{ic|''y''}} is the device number. In the above example, it is {{ic|hw:0,0}}.<br />
<br />
==== Determine sampling rate of the sound card (2/5) ====<br />
<br />
We aim to find the highest sample rate supported by the {{ic|hw:0,0}} sound card using a ''trial-and-error'' procedure starting from a low value. When the top value is reached, we got a warning message:<br />
<br />
{{hc|1=arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav|2=<br />
"Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo<br />
Warning: rate is not accurate (requested = 60000Hz, '''got = 44100Hz''')<br />
please, try the plug plugin<br />
}}<br />
<br />
observe, the {{ic|1=got = 44100Hz}}. This is the maximum sampling rate of our card.<br />
<br />
==== Setting the sound card's sampling rate into PulseAudio configuration (3/5) ====<br />
<br />
The default sampling rate in PulseAudio:<br />
<br />
{{hc|1=$ grep "default-sample-rate" /etc/pulse/daemon.conf|2=<br />
; default-sample-rate = 48000<br />
}}<br />
<br />
{{ic|48000}} is disabled and needs to be changed to {{ic|44100}}:<br />
<br />
# sed 's/; default-sample-rate = 48000/default-sample-rate = 44100/g' -i /etc/pulse/daemon.conf<br />
<br />
==== Restart PulseAudio to apply the new settings (4/5) ====<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
==== Finally check by recording and playing it back (5/5) ====<br />
<br />
Let us record some voice using a microphone for, say, 10 seconds. Make sure the microphone is not muted and all<br />
<br />
$ arecord -f cd -d 10 test-mic.wav<br />
<br />
After 10 seconds, let us play the recording...<br />
<br />
$ aplay test-mic.wav<br />
<br />
Now hopefully, there is no static noise in microphone recording anymore.<br />
<br />
==== Another Possible Cause ====<br />
<br />
Another possible cause is that your mic has two channels but only one channel can provide a valid sound signal. Some information can be found [https://github.com/MaartenBaert/ssr/issues/323#issuecomment-268230548 here]. The solution is to remap the stereo input to a mono input:<br />
<br />
1. Find your source name from the following command; mine is {{ic|alsa_input.pci-0000_00_1f.3.analog-stereo}}<br />
<br />
pacmd list-sources | grep 'name:.*input'<br />
<br />
2. Edit {{ic|/etc/pulse/default.pa}} and add the following lines, where INPUT_NAME is name of the input source from above step:<br />
<br />
load-module module-remap-source source_name=record_mono master=INPUT_NAME master_channel_map=front-left channel_map=mono<br />
set-default-source record_mono<br />
<br />
3. Restart PulseAudio:<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
Now {{ic|arecord}} hopefully works. You may still need to change the {{ic|RecordStream from}} setting to {{ic|Remapped Built-in Audio Analog Stereo}} of a specific application in the {{ic|Recording}} tab of {{ic|pavucontrol}}.<br />
<br />
==== If using a USB microphone ====<br />
<br />
Try plugging it into a different port (eg: ports at the back rather than front).<br />
<br />
=== No microphone on Steam or Skype with enable-remixing = no ===<br />
<br />
When you set {{ic|1=enable-remixing = no}} on {{ic|/etc/pulse/daemon.conf}} you may find that your microphone has stopped working on certain applications like Skype or Steam. This happens because these applications capture the microphone as mono only and because remixing is disabled, Pulseaudio will no longer remix your stereo microphone to mono.<br />
<br />
To fix this you need to tell Pulseaudio to do this for you:<br />
<br />
1. Find the name of the source <br />
<br />
# pacmd list-sources<br />
<br />
Example output edited for brevity, the name you need is in bold:<br />
<br />
index: 2<br />
name: <'''alsa_input.pci-0000_00_14.2.analog-stereo'''><br />
driver: <module-alsa-card.c><br />
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY<br />
<br />
2. Add a remap rule to {{ic|/etc/pulse/default.pa}}, use the name you found with the previous command, here we will use '''alsa_input.pci-0000_00_14.2.analog-stereo''' as an example:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
### Remap microphone to mono<br />
load-module module-remap-source master=alsa_input.pci-0000_00_14.2.analog-stereo master_channel_map=front-left,front-right channels=2 channel_map=mono,mono<br />
}}<br />
<br />
3. Restart Pulseaudio<br />
<br />
# pulseaudio -k<br />
<br />
{{Note|Pulseaudio may fail to start if you do not exit a program that was using the microphone (e.g. if you tested on Steam before modifying the file), in which case you should exit the application and manually start Pulseaudio}}<br />
<br />
# pulseaudio --start<br />
<br />
=== Microphone distorted due to automatic adjustment ===<br />
If your microphone volume creeps up automatically and causes the sound to be distorted, you can fix it by disabling mic boost:<br />
<br />
In {{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf}} and {{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-input-mic.conf}},<br />
<br />
* Under {{ic|[Element Internal Mic Boost]}} set {{ic|volume}} to {{ic|zero}}.<br />
* Under {{ic|[Element Int Mic Boost]}} set {{ic|volume}} to {{ic|zero}}.<br />
* Under {{ic|[Element Mic Boost]}} set {{ic|volume}} to {{ic|zero}}.<br />
<br />
Then restart PulseAudio:<br />
<br />
# pulseaudio -k<br />
<br />
=== Microphone crackling with Realtek ALC892 ===<br />
<br />
Sometimes ALC892 chips have crackling sound while recording using a microphone. Some Pulseaudio config changes may help:<br />
<br />
{{hc|/etc/pulse/daemon.conf|output=<br />
resample-method = src-sinc-best-quality<br />
default-sample-format = s16le<br />
default-sample-rate = 48000<br />
}}<br />
<br />
and add the {{ic|use_ucm}} option to<br />
<br />
{{hc|/etc/pulse/default.pa|output=<br />
load-module module-udev-detect use_ucm=0 tsched=0<br />
}}<br />
<br />
then restart pulseaudio.<br />
<br />
=== Microphone crackling with Azalia chipsets ===<br />
<br />
Some Azalia based chips have popping/crackling noise and distortion while recording using a microphone with PulseAudio. This can be fixed by loading the {{ic|snd-hda-intel}} module with {{ic|position_fix}} set to an appropriate value. This tells the module to use various DMA pointer fixes. Use trial and error to determine which value works for you. ([https://wiki.sabayon.org/index.php?title=HOWTO:_Resolve_Problems_with_HDA-Intel_Sound_Cards source])<br />
<br />
Create a new {{ic|modprobe.d}} config:<br />
<br />
{{hc|/etc/modprobe.d/azalia-microphone.conf|output=<br />
options snd-hda-intel position_fix=1<br />
}}<br />
<br />
Valid values for {{ic|position_fix}} are:<br />
* {{ic|0}} = Auto<br />
* {{ic|1}} = None<br />
* {{ic|2}} = POSBUF<br />
* {{ic|3}} = FIFO size<br />
<br />
then reload your modules.<br />
<br />
=== Echo test ===<br />
<br />
If you are unsure about your microphone setup, you can hear the input from the microphone in real-time by enabling the [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index57h3 loopback module] ([https://answers.launchpad.net/ubuntu/+source/pulseaudio/+question/83742 source]):<br />
<br />
$ pactl load-module module-loopback<br />
<br />
The module will show up in the '''Recording''' tab of the {{Pkg|pavucontrol}} program, where the source and volume can be configured. While latency should be low, it should be sufficient to get a feeling of the sound quality as you will hear yourself speak in the microphone. To make the change permanent, add the following pulseaudio configuration:<br />
<br />
{{hc|/etc/pulse/default.pa|output=<br />
load-module module-loopback<br />
}}<br />
<br />
Watch out for feedback! Be ready to lower all volumes in case the microphone picks up the output from the loudspeakers. Naturally, it is better to run such a test with headphones.<br />
<br />
== Audio quality ==<br />
<br />
=== Enable Echo/Noise-Cancellation ===<br />
<br />
Arch does not load the Pulseaudio Echo-Cancellation module by default, therefore, we have to add it in {{ic|/etc/pulse/default.pa}}. First you can test if the module is present with {{ic|pacmd}} and entering {{ic|list-modules}}. If you cannot find a line showing {{ic|name: <module-echo-cancel>}} you have to add <br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
### Enable Echo/Noise-Cancellation<br />
load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0 digital_gain_control=1" source_name=echoCancel_source sink_name=echoCancel_sink<br />
set-default-source echoCancel_source<br />
set-default-sink echoCancel_sink<br />
}}<br />
<br />
then restart Pulseaudio<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
and check if the module is activated by starting {{ic|pavucontrol}}. Under {{ic|Recording}} the input device should show {{ic|Echo-Cancel Source Stream from"}}.<br />
<br />
If you want existing streams to be automatically moved to the new sink and source, you have to load the [[#Automatically switch to Bluetooth or USB headset|module-switch-on-connect]] with {{ic|1=ignore_virtual=no}} before.<br />
<br />
{{Note|1=If you plug in a USB sound card or headset, or you have for example a 5.1 Speaker configuration and plug in a headset on your front audio connectors after you have loaded the {{ic|module-echo-cancel}}, you have to manually unload and load the {{ic|module-echo-cancel}} again, because unfortunately there is no way to tell the module that it should automatically switch to the new default 'source_master' and 'source_sink'. See [https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/196].}}<br />
<br />
==== Possible 'aec_args' for 'aec_method=webrtc' ====<br />
<br />
Here is a list of possible 'aec_args' for 'aec_method=webrtc' with their default values [https://github.com/pulseaudio/pulseaudio/blob/master/src/modules/echo-cancel/webrtc.cc][https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index45h3]:<br />
<br />
* {{ic|1=analog_gain_control=1}} - Analog AGC - 'Automatic Gain Control' done over changing the volume directly - Will most likely lead to [[#Microphone distorted due to automatic adjustment|distortions]].<br />
* {{ic|1=digital_gain_control=0}} - Digital AGC - 'Automatic Gain Control' done in post processing (higher CPU load).<br />
* {{ic|1=experimental_agc=0}} - Allow enabling of the webrtc experimental AGC mechanism.<br />
* {{ic|1=agc_start_volume=85}} - Initial volume when using AGC - Possible values 0-255 - A too low initial volume may prevent the AGC algorithm from ever raising the volume high enough [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/9.0/].<br />
* {{ic|1=high_pass_filter=1}} - ?<br />
* {{ic|1=noise_suppression=1}} - Noise suppression.<br />
* {{ic|1=voice_detection=1}} - VAD - Voice activity detection.<br />
* {{ic|1=extended_filter=0}} - The extended filter is more complex and less sensitive to incorrect delay reporting from the hardware than the regular filter. The extended filter mode is disabled by default, because it seemed produce worse results during double-talk [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/9.0/].<br />
* {{ic|1=intelligibility_enhancer=0}} - Some bits for webrtc intelligibility enhancer.<br />
* {{ic|1=drift_compensation=0}} - Drift compensation to allow echo cancellation between different devices (such as speakers on your laptop and the microphone on your USB webcam). - only possible with "mobile=0".<br />
* {{ic|1=beamforming=0}} - See [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index45h3][https://arunraghavan.net/2016/06/beamforming-in-pulseaudio/]<br />
** {{ic|1=mic_geometry=x1,y1,z1,x2,y2,z2}} - Only with "beamforming=1".<br />
** {{ic|1=target_direction=a,e,r}} - Only with "beamforming=1". Note: If the module does not want to load with this argument, set azimuth (a) to the desired value, but set elevation (e) and radius (r) to 0.<br />
* {{ic|1=mobile=0}} - ?<br />
** {{ic|1=routing_mode=speakerphone}} - Possible Values "quiet-earpiece-or-headset,earpiece,loud-earpiece,speakerphone,loud-speakerphone" - only valid with "mobile=1".<br />
** {{ic|1=comfort_noise=1}} - ? - only valid with "mobile=1".<br />
<br />
==== Disable audio post processing in certain applications ====<br />
<br />
If you are using the [[#Enable Echo/Noise-Cancellation|module-echo-cancel]], you probably do not want other applications to do additional audio post processing. Here is a list for disabling audio post processing in following applications:<br />
<br />
* Mumble:<br />
*# Configure -> Settings -> Check 'Advanced' check box -> Audio Input<br />
*# Echo: Select 'Disabled'<br />
*# Noise Suppression: Set slider to 'Off'<br />
*# Max. Aplification: Set slider to '1.0'<br />
* TeamSpeak:<br />
*# Tools -> Options -> Check 'Advanced Options' check box<br />
*# Uncheck: 'Echo reduction', 'Echo cancellation', 'Remove background noise' and 'Automatic voice gain control'<br />
* Firefox: see [[Firefox tweaks#Disable WebRTC audio post processing]]<br />
* Steam:<br />
*# In window "Friends List" -> Manage friends list settings (gear symbol) -> VOICE -> Show Advanced Settings<br />
*# Set the following sliders to "OFF": "Echo cancellation", "Noise cancellation", "Automatic volume/gain control"<br />
* Skype:<br />
*# Tools -> Settings... -> Audio & Video -> Microphone -> Automatically adjust microphone settings -> off<br />
<br />
==== Script for reloading module-echo-cancel ====<br />
<br />
Since the module-echo-cancel is not always needed, or must be reloaded if the source_master or sink_master has changed, it is nice to have a easy way to load or reload the module-echo-cancel.<br />
<br />
[[Create]] the following script and make it [[executable]]:<br />
<br />
{{hc|echoCancelEnable.sh|<nowiki><br />
#!/bin/bash<br />
aecArgs="$*"<br />
# If no "aec_args" are passed on to the script, use this "aec_args" as default:<br />
[ -z "$aecArgs" ] && aecArgs="analog_gain_control=0 digital_gain_control=1"<br />
newSourceName="echoCancelSource"<br />
newSinkName="echoCancelSink"<br />
<br />
# "module-switch-on-connect" with "ignore_virtual=no" (needs PulseAudio 12 or higher) is needed to automatically move existing streams to a new (virtual) default source and sink.<br />
if ! pactl list modules short | grep "module-switch-on-connect.*ignore_virtual=no" >/dev/null 2>&1; then<br />
echo Load module \"module-switch-on-connect\" with \"ignore_virtual=no\"<br />
pactl unload-module module-switch-on-connect 2>/dev/null<br />
pactl load-module module-switch-on-connect ignore_virtual=no<br />
fi<br />
<br />
# Reload "module-echo-cancel"<br />
echo Reload \"module-echo-cancel\" with \"aec_args=$aecArgs\"<br />
pactl unload-module module-echo-cancel 2>/dev/null<br />
if pactl load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args=\"$aecArgs\" source_name=$newSourceName sink_name=$newSinkName; then<br />
# Set a new default source and sink, if module-echo-cancel has loaded successfully.<br />
pacmd set-default-source $newSourceName<br />
pacmd set-default-sink $newSinkName<br />
fi<br />
</nowiki>}}<br />
<br />
To run the script easily from the graphical environment, you can create a [[desktop launcher]] for it.<br />
<br />
=== Glitches, skips or crackling ===<br />
<br />
The newer implementation of the PulseAudio sound server uses timer-based audio scheduling instead of the traditional, interrupt-driven approach. <br />
<br />
Timer-based scheduling may expose issues in some ALSA drivers. On the other hand, other drivers might be glitchy without it on, so check to see what works on your system. <br />
<br />
To turn timer-based scheduling off add {{ic|1=tsched=0}} in {{ic|/etc/pulse/default.pa}}:<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-udev-detect tsched=0<br />
}}<br />
<br />
Then restart the PulseAudio server:<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
Do the reverse to enable timer-based scheduling, if not already enabled by default.<br />
<br />
If you are using Intel's [[Wikipedia:IOMMU|IOMMU]] and experience glitches and/or skips, add {{ic|1=intel_iommu=igfx_off}} to your kernel command line.<br />
<br />
Some Intel audio cards using the {{ic|snd-hda-intel}} module need the otions {{ic|1=vid=8086 pid=8ca0 snoop=0}}. In order to set them permanently, create/modify the following file including the line below.<br />
<br />
{{hc|/etc/modprobe.d/sound.conf|2=<br />
options snd-hda-intel vid=8086 pid=8ca0 snoop=0<br />
}}<br />
<br />
Please report any such cards to [http://www.freedesktop.org/wiki/Software/PulseAudio/Backends/ALSA/BrokenDrivers/ PulseAudio Broken Sound Driver page]<br />
<br />
=== Static noise when using headphones ===<br />
<br />
Time-based scheduling may be causing this, disable it as explained in [[#Glitches, skips or crackling]].<br />
<br />
Another reason you are encountering static noise in your headphone jack could be ALSA's loopback mixing.<br />
<br />
Make sure you have {{Pkg|alsa-utils}} installed, launch {{ic|alsamixer}}, then select your audio device (pressing {{ic|F6}}}), navigate all the way left using the {{ic|left arrow}}, and stop on '''Loopback''', if '''Enabled''' disable it using the {{ic|down arrow}}. This should not impact audio playback or microphone recording negatively, unless you require loopback mixing.<br />
<br />
Yet another reason for this symptom could be power-saving mode of your audio device.[https://askubuntu.com/a/534082] If you followed [[Power management#Audio]], revert the changes and check if it solves the problem.<br />
<br />
=== Setting the default fragment number and buffer size in PulseAudio ===<br />
<br />
{{Style|Copied from Linux mint topic with few additions}}<br />
<br />
==== Disabling timer-based scheduling (0/4) ====<br />
<br />
By default, PulseAudio uses timer-based scheduling. In this mode, fragments are not used at all, and so the default-fragments and default-fragment-size-msec parameters are ignored.<br />
To turn timer-based scheduling off add {{ic|1=tsched=0}} in {{ic|/etc/pulse/default.pa}}:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-udev-detect tsched=0<br />
}}<br />
<br />
==== Finding out your audio device parameters (1/4) ====<br />
<br />
To find out what your sound card buffering settings are, use the following command and scroll through the output until you find the correct sink entry.<br />
<br />
{{hc|$ pactl list sinks|2=<br />
Sink #1<br />
State: RUNNING<br />
Name: alsa_output.pci-0000_00_1b.0.analog-stereo<br />
Description: Built-in Audio Analog Stereo<br />
Driver: module-alsa-card.c<br />
Sample Specification: s16le 2ch 44100Hz<br />
Channel Map: front-left,front-right<br />
Owner Module: 7<br />
Mute: no<br />
Volume: front-left: 42600 / 65% / -11.22 dB, front-right: 42600 / 65% / -11.22 dB<br />
balance 0.00<br />
Base Volume: 65536 / 100% / 0.00 dB<br />
Monitor Source: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor<br />
Latency: 70662 usec, configured 85000 usec<br />
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY <br />
Properties:<br />
alsa.resolution_bits = "16"<br />
device.api = "alsa"<br />
device.class = "sound"<br />
alsa.class = "generic"<br />
alsa.subclass = "generic-mix"<br />
alsa.name = "ALC283 Analog"<br />
alsa.id = "ALC283 Analog"<br />
alsa.subdevice = "0"<br />
alsa.subdevice_name = "subdevice #0"<br />
alsa.device = "0"<br />
alsa.card = "1"<br />
alsa.card_name = "HDA Intel PCH"<br />
alsa.long_card_name = "HDA Intel PCH at 0xe111c000 irq 43"<br />
alsa.driver_name = "snd_hda_intel"<br />
device.bus_path = "pci-0000:00:1b.0"<br />
sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card1"<br />
device.bus = "pci"<br />
device.vendor.id = "8086"<br />
device.vendor.name = "Intel Corporation"<br />
device.product.id = "9ca0"<br />
device.product.name = "Wildcat Point-LP High Definition Audio Controller"<br />
device.form_factor = "internal"<br />
device.string = "front:1"<br />
device.buffering.buffer_size = "352800"<br />
device.buffering.fragment_size = "176400"<br />
device.access_mode = "mmap+timer"<br />
device.profile.name = "analog-stereo"<br />
device.profile.description = "Analog Stereo"<br />
device.description = "Built-in Audio Analog Stereo"<br />
alsa.mixer_name = "Realtek ALC283"<br />
alsa.components = "HDA:10ec0283,10ec0283,00100003"<br />
module-udev-detect.discovered = "1"<br />
device.icon_name = "audio-card-pci"<br />
Ports:<br />
analog-output-speaker: Speakers (priority: 10000, not available)<br />
analog-output-headphones: Headphones (priority: 9000, available)<br />
Active Port: analog-output-headphones<br />
Formats:<br />
pcm<br />
...<br />
}}<br />
<br />
Take note the {{ic|buffer_size}} and {{ic|fragment_size}} values for the relevant sound card.<br />
<br />
==== Calculate your fragment size in msecs and number of fragments (2/4) ====<br />
<br />
PulseAudio's default sampling rate and bit depth are set to {{ic|44100Hz}} @ {{ic|16 bits}}.<br />
<br />
With this configuration, the bit rate we need is {{ic|44100}}*{{ic|16}} = {{ic|705600}} bits per second. That is {{ic|1411200 bps}} for stereo.<br />
<br />
Let us take a look at the parameters we have found in the previous step:<br />
<br />
device.buffering.buffer_size = "352800" => 352800/1411200 = 0.25 s = 250 ms<br />
device.buffering.fragment_size = "176400" => 176400/1411200 = 0.125 s = 125 ms<br />
<br />
==== Modify PulseAudio's configuration file (3/4) ====<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
; default-fragments = X<br />
; default-fragment-size-msec = Y<br />
}}<br />
<br />
In the previous step, we calculated the fragment size parameter.<br />
The number of fragments is simply buffer_size/fragment_size, which in this case ({{ic|250/125}}) is {{ic|2}}:<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
; default-fragments = '''2'''<br />
; default-fragment-size-msec = '''125'''<br />
}}<br />
<br />
==== Restart the PulseAudio daemon (4/4) ====<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
For more information, see: [http://forums.linuxmint.com/viewtopic.php?f=42&t=44862 Linux Mint topic]<br />
<br />
=== Choppy sound with analog surround sound setup ===<br />
<br />
The low-frequency effects (LFE) or Subwoofer channel is not remixed per default. To enable it the following needs to be set in {{ic|/etc/pulse/daemon.conf}} :<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
enable-lfe-remixing = yes<br />
}}<br />
<br />
You should also consider to set a proper crossover frequency for the LFE- channel.<br />
The crossover frequency is the frequency up to which the audio signal is rerouted to the LFE sink.<br />
The optimal crossover frequency in Hz depends on the size of all your speakers.<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
lfe-crossover-freq = <40-200><br />
}}<br />
<br />
=== Laggy sound ===<br />
<br />
This issue is due to incorrect buffer sizes. First verify that the variables {{ic|default-fragments}} and {{ic|default-fragment-size-msec}} are not being set to non default values in the file {{ic|/etc/pulse/daemon.conf}}. If the issue is still present, try setting them to the following values:<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
default-fragments = 5<br />
default-fragment-size-msec = 2<br />
}}<br />
<br />
=== Choppy/distorted sound ===<br />
<br />
This can result from an incorrectly set sample rate. Try the following setting:<br />
<br />
{{hc|/etc/pulse/daemon.conf|2=<br />
avoid-resampling = yes #(Needs [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/ PA11] or higher)<br />
default-sample-rate = 48000<br />
}}<br />
<br />
and restart the PulseAudio server.<br />
<br />
If one experiences choppy sound in applications using [[Wikipedia:OpenAL|OpenAL]], change the sample rate in {{ic|/etc/openal/alsoft.conf}}:<br />
<br />
{{hc|/etc/openal/alsoft.conf|2=<br />
frequency = 48000<br />
}}<br />
<br />
Setting the PCM volume above 0 dB can cause [[Wikipedia:Clipping_(audio)|clipping]]. Running {{ic|alsamixer}} will allow you to see if this is the problem and if so fix it. Note that ALSA may not [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PulseAudioStoleMyVolumes/ correctly export] the dB information to PulseAudio. Try the following:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-udev-detect ignore_dB=1<br />
}}<br />
<br />
and restart the PulseAudio server. See also [[#No sound below a volume cutoff]].<br />
<br />
=== Sound stuttering when streaming over network ===<br />
<br />
When streaming over Wi-Fi using module-native-protocol-tcp you can experience periodic sound stuttering with buffer underruns. As a workaround you can try to use rtp protocol. On sender side create rtp sink:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-null-sink sink_name=rtp<br />
load-module module-rtp-send source=rtp.monitor<br />
}}<br />
<br />
and switch to it:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
set-default-sink rtp<br />
}}<br />
<br />
On receiver side load rtp module:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-rtp-recv<br />
}}<br />
<br />
=== Pops when starting and stopping playback ===<br />
<br />
PulseAudio can suspend sinks after a period of inactivity. This can make an audible noise (like a crack/pop/scratch). Sometimes even when move the slider volume, or open and close windows (KDE4). This behavior is enabled in default configuration files:<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-suspend-on-idle<br />
}}<br />
<br />
{{hc|/etc/pulse/system.pa|2=<br />
load-module module-suspend-on-idle<br />
}}<br />
<br />
Commenting that line in relevant file fixes that issue. A better solution is to add the following file:<br />
<br />
{{hc|~/.config/pulse/default.pa|2=<br />
.include /etc/pulse/default.pa<br />
unload-module module-suspend-on-idle<br />
}}<br />
<br />
== Hardware and Cards ==<br />
<br />
=== No HDMI sound output after some time with the monitor turned off ===<br />
<br />
The monitor is connected via HDMI/DisplayPort, and the audio jack is plugged in the headphone jack of the monitor, but PulseAudio insists that it is unplugged:<br />
<br />
{{hc|pactl list sinks|<br />
...<br />
hdmi-output-0: HDMI / DisplayPort (priority: 5900, not available)<br />
...<br />
}}<br />
<br />
This leads to no sound coming from HDMI output. A workaround for this is to switch to another VT and back again. If that does not work, try: turn off your monitor, switch to another VT, turn on your monitor, and switch back. This problem has been reported by ATI/Nvidia/Intel users.<br />
<br />
Another workaround could be to disable the switch-on-port-available module by commenting it in /etc/pulse/default.pa [https://bugs.freedesktop.org/show_bug.cgi?id=93946#c36]:<br />
<br />
{{hc|/etc/pulse/default.pa|<br />
...<br />
### Should be after module-*-restore but before module-*-detect<br />
#load-module module-switch-on-port-available<br />
...<br />
}}<br />
<br />
=== No HDMI sound using a headless server ===<br />
<br />
You might want to use HDMI audio with your a/v receiver but no display. HDMI requires a video signal, which we have from the virtual terminal. <br />
<br />
By default, this signal is turned off after 600 seconds, thus the audio sink gets lost as well.<br />
<br />
To prevent screen blanking, add {{ic|consoleblank&#61;0}} to the kernel command line.<br />
<br />
=== No cards ===<br />
<br />
If PulseAudio starts, run {{ic|pacmd list}}. If no cards are reported, make sure that the ALSA devices are not in use:<br />
<br />
$ fuser -v /dev/snd/*<br />
$ fuser -v /dev/dsp<br />
<br />
Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.<br />
<br />
=== Starting an application interrupts other app's sound ===<br />
<br />
If you have trouble with some applications (such as TeamSpeak or Mumble) interrupting sound output of already running applications (such as Deadbeaf), you can solve this by commenting out the line {{ic|load-module module-role-cork}} in {{ic|/etc/pulse/default.pa}} like shown below:<br />
<br />
{{hc|/etc/pulse/default.pa|<br />
### Cork music/video streams when a phone stream is active<br />
# load-module module-role-cork<br />
}}<br />
<br />
Then restart pulseaudo by using your normal user account with<br />
<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
=== The only device shown is "dummy output" or newly connected cards are not detected ===<br />
<br />
If the only playback device is the Dummy Output, PulseAudio cannot access your sound devices. It is possible there is an issue with logind giving permissions, see [[General troubleshooting#Session permissions]] for more information.<br />
<br />
An application might also not have been configured to work with PulseAudio. This happens with [[FluidSynth#Conflicting_with_PulseAudio|FluidSynth]] for example. To see which application is responsible for a direct access to the sound card via alsa, run the following command:<br />
<br />
# fuser -v /dev/snd/*<br />
<br />
Try to close these applications. pulseaudio, if running, should take again precedence over these applications and all the applications relying on pulseaudio should work again like expected.<br />
<br />
=== No HDMI 5/7.1 Selection for Device ===<br />
<br />
If you are unable to select 5/7.1 channel output for a working HDMI device, then turning off "stream device reading" in {{ic|/etc/pulse/default.pa}} might help. <br />
<br />
See [[#Fallback device is not respected]].<br />
<br />
=== Failed to create sink input: sink is suspended ===<br />
<br />
If you do not have any output sound and receive dozens of errors related to a suspended sink in your {{ic|journalctl -b}} log, then backup first and then delete your user-specific pulse folders:<br />
<br />
$ rm -r ~/.pulse ~/.pulse-cookie ~/.config/pulse<br />
<br />
=== Simultaneous output to multiple sound cards / devices ===<br />
<br />
Simultaneous output to two different devices can be very useful. For example, being able to send audio to your A/V receiver via your graphics card's HDMI output, while also sending the same audio through the analogue output of your motherboard's built-in audio. This is much less hassle than it used to be (in this example, we are using GNOME desktop).<br />
<br />
Using {{Pkg|paprefs}}, simply select "Add virtual output device for simultaneous output on all local sound cards" from under the "Simultaneous Output" tab. Then, under GNOME's "sound settings", select the simultaneous output you have just created.<br />
<br />
If this does not work, try adding the following to {{ic|~/.asoundrc}}:<br />
<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
<br />
{{Tip|Simultaneous output can also be achieved manually using alsamixer. Disable "auto mute" item, then unmute other output sources you want to hear and increase their volume.}}<br />
<br />
=== Simultaneous output to multiple sinks on the same sound card not working ===<br />
<br />
This can be useful for users who have multiple sound sources and want to play them on different sinks/outputs. <br />
An example use-case for this would be if you play music and also voice chat and want to output music to speakers (in this case Digital S/PDIF) and voice to headphones. (Analog)<br />
<br />
This is sometimes auto detected by PulseAudio but not always. If you know that your sound card can output to both Analog and S/PDIF at the same time and PulseAudio does not have this option in its profiles in pavucontrol, or veromix then you probably need to create a configuration file for your sound card.<br />
<br />
More in detail you need to create a profile-set for your specific sound card.<br />
This is done in two steps mostly.<br />
<br />
* Create udev rule to make PulseAudio choose your PulseAudio configuration file specific to the sound card.<br />
* Create the actual configuration.<br />
<br />
Create a pulseadio udev rule.<br />
<br />
{{Note|This is only an example for Asus Xonar Essence STX.<br />
Read [[udev]] to find out the correct values.}}<br />
<br />
{{Note|Your configuration file should have lower number than the original PulseAudio rule to take effect.}}<br />
<br />
{{hc|/usr/lib/udev/rules.d/90-pulseaudio-Xonar-STX.rules|<br />
ACTION&#61;&#61;"change", SUBSYSTEM&#61;&#61;"sound", KERNEL&#61;&#61;"card*", \<br />
ATTRS&#123;subsystem_vendor&#125;&#61;&#61;"0x1043", ATTRS&#123;subsystem_device&#125;&#61;&#61;"0x835c", ENV&#123;PULSE_PROFILE_SET&#125;&#61;"asus-xonar-essence-stx.conf" <br />
}}<br />
<br />
Now, create a configuration file. If you bother, you can start from scratch and make it saucy. However you can also use the default configuration file, rename it, and then add your profile there that you know works. Less pretty but also faster.<br />
<br />
To enable multiple sinks for Asus Xonar Essence STX you need only to add this in.<br />
<br />
{{Note|{{ic|asus-xonar-essence-stx.conf}} also includes all code/mappings from {{ic|default.conf}}.}}<br />
<br />
{{hc|/usr/share/pulseaudio/alsa-mixer/profile-sets/asus-xonar-essence-stx.conf|<br />
[Profile analog-stereo+iec958-stereo]<br />
description &#61; Analog Stereo Duplex + Digital Stereo Output<br />
input-mappings &#61; analog-stereo<br />
output-mappings &#61; analog-stereo iec958-stereo<br />
skip-probe &#61; yes<br />
}}<br />
<br />
This will auto-profile your Asus Xonar Essence STX with default profiles and add your own profile so you can have multiple sinks.<br />
<br />
You need to create another profile in the configuration file if you want to have the same functionality with AC3 Digital 5.1 output.<br />
<br />
[http://www.freedesktop.org/wiki/Software/PulseAudio/Backends/ALSA/Profiles/ See PulseAudio article about profiles]<br />
<br />
=== Some profiles like SPDIF are not enabled by default on the card ===<br />
<br />
Some profiles like IEC-958 (i.e. S/PDIF) may not be enabled by default on the selected sink. Each time the system starts up, the card profile is disabled and the pulseaudio daemon cannot select it.<br />
You have to add the profile selection to you default.pa file. <br />
Verify the card and profile name with :<br />
<br />
$ pacmd list-cards<br />
<br />
Then edit the config to add the profile<br />
<br />
{{hc|~/.config/pulse/default.pa|<br />
## Replace with your card name and the profile you want to activate<br />
set-card-profile alsa_card.pci-0000_00_1b.0 output:iec958-stereo+input:analog-stereo<br />
}}<br />
<br />
Pulse audio will add this profile the pool of available profiles<br />
<br />
=== Only S/PDIF output available ===<br />
<br />
This might happen if PulseAudio use the wrong output device. Firstly, set up proper card profile:<br />
<br />
$ pacmd set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo<br />
<br />
or<br />
<br />
$ pacmd set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo+input:analog-stereo<br />
<br />
Replace {{ic|alsa_card.pci-0000_00_1f.3}} with your card, and {{ic|output:analog-stereo}} or {{ic|output:analog-stereo+input:analog-stereo}} with your profile, remember to choose the profile with analog. Using shell auto completion could help you a lot. One could also use check available cards and profiles with:<br />
<br />
$ pacmd list-cards<br />
<br />
One might also need to set sink port by:<br />
<br />
$ pacmd set-sink-port alsa_output.pci-0000_00_1f.3.analog-stereo analog-output-headphones<br />
<br />
Check available sink ports with:<br />
<br />
$ pacmd list-sinks<br />
<br />
To keep these setting, add them to PulseAudio's configuration file {{ic|default.pa}}.<br />
<br />
{{hc|~/.config/pulse/default.pa|<br />
.include /etc/pulse/default.pa<br />
<br />
set-card-profile alsa_card.pci-0000_00_1f.3 output:analog-stereo+input:analog-stereo<br />
set-sink-port alsa_output.pci-0000_00_1f.3.analog-stereo analog-output-headphones<br />
}}<br />
<br />
== Bluetooth ==<br />
<br />
=== Disable Bluetooth support ===<br />
<br />
If you do not use Bluetooth, you may experience the following error in your journal:<br />
<br />
bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez was not provided by any .service files<br />
<br />
To disable Bluetooth support in PulseAudio, make sure that the following lines are commented out in the configuration file in use ({{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}}):<br />
<br />
{{hc|~/.config/pulse/default.pa|<br />
### Automatically load driver modules for Bluetooth hardware<br />
#.ifexists module-bluetooth-policy.so<br />
#load-module module-bluetooth-policy<br />
#.endif<br />
<br />
#.ifexists module-bluetooth-discover.so<br />
#load-module module-bluetooth-discover<br />
#.endif<br />
}}<br />
<br />
=== Bluetooth headset replay problems ===<br />
<br />
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 reports] huge delays or even no sound when the Bluetooth connection does not send any data. This is due to the {{ic|module-suspend-on-idle}} module, which automatically suspends sinks/sources on idle. As this can cause problems with headset, the responsible module can be deactivated.<br />
<br />
To disable loading of the {{ic|module-suspend-on-idle}} module, comment out the following line in the configuration file in use ({{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}}):<br />
<br />
{{hc|~/.config/pulse/default.pa|<br />
### Automatically suspend sinks/sources that become idle for too long<br />
#load-module module-suspend-on-idle<br />
}}<br />
<br />
Finally restart PulseAudio to apply the changes.<br />
<br />
=== Automatically switch to Bluetooth or USB headset ===<br />
<br />
Add the following:<br />
{{hc|/etc/pulse/default.pa|output=<br />
# automatically switch to newly-connected devices<br />
load-module module-switch-on-connect<br />
# or switch also to newly-connected virtual devices<br />
load-module module-switch-on-connect ignore_virtual=no<br />
}}<br />
<br />
Since [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/ PulseAudio 11] USB and bluetooth devices are preferred over internal sound cards by default, but as in the above link described, you still need module-switch-on-connect to also moves existing streams to the new sink.<br />
<br />
Since [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/12.0/ PulseAudio 12] virtual devices are ignored by default.<br />
If you do not want this behavior because you want to move existing streams to freshly loaded [[#Enable Echo/Noise-Cancellation|module-echo-cancel]] for example, you have to add {{ic|1=ignore_virtual=no}}.<br />
<br />
=== My Bluetooth device is paired but does not play any sound ===<br />
<br />
[[Bluetooth headset#A2DP_not_working_with_PulseAudio|See the article in Bluetooth headset section]]<br />
<br />
Starting from PulseAudio 2.99 and bluez 4.101 you should '''avoid''' using Socket interface. Do NOT use:<br />
<br />
{{hc|/etc/bluetooth/audio.conf|2=<br />
[General]<br />
Enable=Socket<br />
}}<br />
<br />
If you face problems with A2DP and PA 2.99 make sure you have {{Pkg|sbc}} library.<br />
<br />
== Applications ==<br />
<br />
=== Flash content ===<br />
<br />
Since Adobe Flash does not directly support PulseAudio, the recommended way is to [[PulseAudio#ALSA|configure ALSA to use the virtual PulseAudio sound card]].<br />
<br />
If Flash audio is lagging, you may try to have Flash access ALSA directly. See [[PulseAudio#ALSA/dmix without grabbing hardware device]] for details.<br />
<br />
=== Permission errors bug ===<br />
<br />
{{hc|pulseaudio --start|<br />
E: [autospawn] core-util.c: Failed to create secure directory (/run/user/1000/pulse): Operation not permitted<br />
W: [autospawn] lock-autospawn.c: Cannot access autospawn lock.<br />
E: [pulseaudio] main.c: Failed to acquire autospawn lock<br />
}}<br />
<br />
Known programs that changes permissions for {{ic|/run/user/''user id''/pulse}} when using [[Polkit]] for root elevation:<br />
<br />
* {{AUR|sakis3g}} <br />
<br />
As a workaround, include {{Pkg|kdesu}} in a [[desktop entry]], or add {{ic|1=''username'' ALL=NOPASSWD: /usr/bin/''program_name''}} to [[sudoers]] to run it with {{Pkg|sudo}} without a password.<br />
<br />
The other workaround is to uncomment and set {{ic|1=daemonize = yes}} in the {{ic|/etc/pulse/daemon.conf}}.<br />
<br />
See also [https://bbs.archlinux.org/viewtopic.php?id=135955].<br />
<br />
=== Audacity ===<br />
<br />
To work with PulseAudio, Audacity requires the {{Pkg|pulseaudio-alsa}} is installed. This provides the {{ic|1=pulse:...}} playback and recording devices.<br />
<br />
When starting Audacity you may find that your headphones no longer work. This can be because Audacity is trying to use them as a recording device. To fix this, open Audacity, then set its recording device to {{ic|1=pulse:Internal Mic:0}}.<br />
<br />
Under some circumstances, playback may be distorted, very fast, or freeze, as discussed in the [http://wiki.audacityteam.org/wiki/Linux_Issues#ALSA_and_other_sound_systems Audacity Wiki's Linux Issues page].<br />
<br />
The solution proposed in this page may work: start Audacity with:<br />
<br />
$ env PULSE_LATENCY_MSEC=30 audacity<br />
<br />
If the solution above does not fix this issue, one may wish to temporarily disable pulseaudio while running Audacity by using the {{ic|pasuspender}} command:<br />
<br />
$ pasuspender -- audacity<br />
<br />
Then, be sure to select the appropriate ALSA input and output devices in Audacity.<br />
<br />
See also [[#Setting the default fragment number and buffer size in PulseAudio]].<br />
<br />
== Other Issues ==<br />
<br />
=== Bad configuration files ===<br />
<br />
After starting PulseAudio, if the system outputs no sound, it may be necessary to delete the contents of {{ic|~/.config/pulse}} and/or {{ic|~/.pulse}}. PulseAudio will automatically create new configuration files on its next start.<br />
<br />
=== Cannot update configuration of sound device in pavucontrol ===<br />
<br />
{{Pkg|pavucontrol}} is a handy GUI utility for configuring PulseAudio. Under its 'Configuration' tab, you can select different profiles for each of your sound devices e.g. analogue stereo, digital output (IEC958), HDMI 5.1 Surround etc.<br />
<br />
However, you may run into an instance where selecting a different profile for a card results in the pulse daemon crashing and auto restarting without the new selection "sticking". If this occurs, use the other useful GUI tool, {{Pkg|paprefs}}, to check under the "Simultaneous Output" tab for a virtual simultaneous device. If this setting is active (checked), it will prevent you changing any card's profile in pavucontrol. Uncheck this setting, then adjust your profile in pavucontrol prior to re-enabling simultaneous output in paprefs.<br />
<br />
=== Failed to create sink input: sink is suspended ===<br />
<br />
If you do not have any output sound and receive dozens of errors related to a suspended sink in your {{ic|journalctl -b}} log, then backup first and then delete your user-specific pulse folders:<br />
<br />
$ rm -r ~/.pulse ~/.pulse-cookie ~/.config/pulse<br />
<br />
=== Pulse overwrites ALSA settings ===<br />
<br />
PulseAudio usually overwrites the ALSA settings — for example set with alsamixer — at start-up, even when the ALSA daemon is loaded. Since there seems to be no other way to restrict this behaviour, a workaround is to restore the ALSA settings again after PulseAudio has started. Add the following command to {{ic|.xinitrc}} or {{ic|.bash_profile}} or any other [[autostart]] file:<br />
<br />
restore_alsa() {<br />
while [ -z "$(pidof pulseaudio)" ]; do<br />
sleep 0.5<br />
done<br />
alsactl -f /var/lib/alsa/asound.state restore <br />
}<br />
restore_alsa &<br />
<br />
=== Prevent Pulse from restarting after being killed ===<br />
<br />
{{Remove|Obsolete due to [[PulseAudio#Running]]. Controlling systemd units is explained in [[systemd#Using units]].}}<br />
<br />
Sometimes you may wish to temporarily disable Pulse. In order to do so you will have to prevent Pulse from restarting after being killed. To disable autospawning you can [https://bbs.archlinux.org/viewtopic.php?pid=1807567#p1807567 issue]:<br />
<br />
$ systemctl --user mask pulseaudio.socket<br />
$ systemctl --user stop pulseaudio<br />
<br />
To re-enable autospawning:<br />
<br />
$ systemctl --user unmask pulseaudio.socket<br />
<br />
On older systems you could set this option:<br />
<br />
{{hc|~/.config/pulse/client.conf|2=<br />
# Disable autospawning the PulseAudio daemon<br />
autospawn = no<br />
}}<br />
<br />
=== Daemon startup failed ===<br />
<br />
Try resetting PulseAudio:<br />
<br />
$ rm -rf /tmp/pulse* ~/.pulse* ~/.config/pulse<br />
$ pulseaudio -k<br />
$ pulseaudio --start<br />
<br />
* Check that options for sinks are set up correctly.<br />
* If you configured in default.pa to load and use the OSS modules then check with {{Pkg|lsof}} that {{ic|/dev/dsp}} device is not used by another application.<br />
* Set a preferred working resample method. Use {{ic|pulseaudio --dump-resample-methods}} to see a list with all available resample methods you can use.<br />
* To get details about currently appeared unfixed errors or just get status of daemon use commands like {{ic|pax11publish -d}} and {{ic|pulseaudio -v}} where {{ic|v}} option can be used multiple time to set verbosity of log output equal to the {{ic|1=--log-level[=LEVEL]}} option where LEVEL is from 0 to 4. See the [[#Outputs by PulseAudio error status check utilities]] section.<br />
<br />
See also man pages for {{man|1|pax11publish}} and {{man|1|pulseaudio}} for more details.<br />
<br />
==== Outputs by PulseAudio error status check utilities ====<br />
<br />
If the {{ic|pax11publish -d}} shows error like:<br />
<br />
N: [pulseaudio] main.c: User-configured server at "user", refusing to start/autospawn.<br />
<br />
then run {{ic|pax11publish -r}} command then could be also good to logout and login again.<br />
<br />
If the {{ic|pulseaudio -vvvv}} command shows error like:<br />
<br />
E: [pulseaudio] module-udev-detect.c: You apparently ran out of inotify watches, probably because Tracker/Beagle took them all away. I wished people would do their homework first and fix inotify before using it for watching whole directory trees which is something the current inotify is certainly not useful for. Please make sure to drop the Tracker/Beagle guys a line complaining about their broken use of inotify.<br />
<br />
This can be resolved temporary by:<br />
<br />
$ echo 100000 > /proc/sys/fs/inotify/max_user_watches<br />
<br />
For permanent use save settings in the ''99-sysctl.conf'' file:<br />
<br />
{{hc|/etc/sysctl.d/99-sysctl.conf|2=<br />
# Increase inotify max watchs per user<br />
fs.inotify.max_user_watches = 100000<br />
}}<br />
<br />
{{Warning|It may cause much bigger consumption of memory by kernel.}}<br />
<br />
'''See also''' <br />
<br />
* [http://www.linuxinsight.com/proc_sys_fs_inotify.html proc_sys_fs_inotify] and [http://lwn.net/Articles/604686/ dnotify, inotify]- more details about ''inotify/max_user_watches''<br />
* [http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux?answertab=votes#tab-top reasonable amount of inotify watches with Linux]<br />
* {{man|7|inotify}} - man page<br />
<br />
=== Daemon already running ===<br />
<br />
On some systems, PulseAudio may be started multiple times. journalctl will report:<br />
<br />
[pulseaudio] pid.c: Daemon already running.<br />
<br />
Make sure to use only one method of autostarting applications. {{Pkg|pulseaudio}} includes these files:<br />
<br />
* {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}}<br />
* {{ic|/etc/xdg/autostart/pulseaudio.desktop}}<br />
* {{ic|/etc/xdg/autostart/pulseaudio-kde.desktop}}<br />
<br />
Also check user autostart files and directories, such as [[xinitrc]], {{ic|~/.config/autostart/}} etc.<br />
<br />
=== Subwoofer stops working after end of every song ===<br />
<br />
Known issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/494099<br />
<br />
To fix this, {{ic|1=enable-lfe-remixing = yes}} must be set as described in [[#Choppy sound with analog surround sound setup]].<br />
<br />
=== Unable to select surround configuration other than "Surround 4.0" ===<br />
<br />
If you are unable to set 5.1 surround output in pavucontrol because it only shows "Analog Surround 4.0 Output", open the ALSA mixer and change the output configuration there to 6 channels. Then restart pulseaudio, and pavucontrol will list many more options.<br />
<br />
=== Realtime scheduling ===<br />
<br />
If rtkit does not work, you can manually set up your system to run PulseAudio with real-time scheduling, which can help performance. To do this, add the following lines to {{ic|/etc/security/limits.conf}}:<br />
<br />
@pulse-rt - rtprio 9<br />
@pulse-rt - nice -11<br />
<br />
Afterwards, you need to add your user to the {{ic|pulse-rt}} group:<br />
<br />
# gpasswd -a <user> pulse-rt<br />
<br />
=== pactl "invalid option" error with negative percentage arguments ===<br />
<br />
{{ic|pactl}} commands that take negative percentage arguments will fail with an 'invalid option' error. Use the standard shell '--' pseudo argument<br />
to disable argument parsing before the negative argument. ''e.g.'' {{ic|pactl set-sink-volume 1 -- -5%}}.<br />
<br />
=== Fallback device is not respected ===<br />
<br />
PulseAudio does not have a true default device. Instead it uses a [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/DefaultDevice/ "fallback"], which only applies to new sound streams. This means previously run applications are not affected by the newly set fallback device.<br />
<br />
{{Pkg|gnome-control-center}}, {{Pkg|mate-media}} and {{AUR|paswitch}} handle this gracefully. Alternatively: <br />
<br />
1. Move the old streams in {{Pkg|pavucontrol}} manually to the new sound card.<br />
<br />
2. Stop Pulse, erase the "stream-volumes" in {{ic|~/.config/pulse}} and/or {{ic|~/.pulse}} and restart Pulse. This also resets application volumes.<br />
<br />
3. Disable stream device reading. This may be not wanted when using different soundcards with different applications.<br />
<br />
{{hc|/etc/pulse/default.pa|2=<br />
load-module module-stream-restore restore_device=false<br />
}}<br />
<br />
=== RTP/UDP packet flood ===<br />
<br />
In some cases the default configuration might flood the network with UDP packets.[https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/505] <br />
To fix this problem, launch {{ic|paprefs}} and disable "Multicast/RTP Sender".[https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/411688/comments/36]</div>Nikolam