Linux & ALSA on integrated sound card

I am moving various publications and how-to documents to this blog and found this one. In fact, many of these steps are still valid when troubleshooting issues, however the state of ALSA in kernel 4.4 is much better and in vast majority of cases, sound should work on new laptops right away.

To setup ALSA on a laptops, notebooks and many modern motehrboards which come with an integrated soundcard, you need to take the following steps.

1. Collect information about your hardware device using lspci -v (you can grep for audio).

00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)
Subsystem: Micro-Star International Co., Ltd. Unknown device 040d

Whats important here is the Subsystem. Write it down.

2. Obtain the chipset info from your running configuration.

$ cat /proc/asound/pcm
00-06: Si3054 Modem : Si3054 Modem : playback 1 : capture 1
00-02: ALC883 Analog : ALC883 Analog : capture 2
00-01: ALC883 Digital : ALC883 Digital : playback 1
00-00: ALC883 Analog : ALC883 Analog : playback 1 : capture 2

So, in my case it is a ALC883 chipset and MSI subsystem. Of course, snd-hda-intel driver must be loaded first. But to get proper sound output, you have to add an appropriate model line to /etc/modules.d/alsa where the module gets configured at load (for example at boot time).

3. Checking for the right model to use with the module loading script

Time to read the documentation that comes with the Linux kernel. To do this, open /usr/src/linux/Documentation/sound/alsa/ALSA-Configuration.txt with your favourite text editor. Find the occurence of your chipset and browse the list of options and subsystems. In my case:

3stack-dig 3-jack with SPDIF I/O
6stack-dig 6-jack digital with SPDIF I/O
3stack-6ch 3-jack 6-channel
3stack-6ch-dig 3-jack 6-channel with SPDIF I/O
6stack-dig-demo 6-jack digital for Intel demo board
acer Acer laptops (Travelmate 3012WTMi, Aspire 5600, etc)
medion Medion Laptops
targa-dig Targa/MSI
targa-2ch-dig Targs/MSI with 2-channel
laptop-eapd 3-jack with SPDIF I/O and EAPD (Clevo M540JE, M550JE)
auto auto-config reading BIOS (default)

I find my subsystem (MSI) on the list. It is next to the targa-dig option, so i have to use it in my configuration. This shows that for me the appropriate /etc/modules.d/alsa configuration line is:

options snd_hda_intel model=targa-dig

Put your line in the config file and then have the module re-load (if you did not compile in module re-loading in the kernel, you need to reboot).

Mencoder: create and encode movies from files (frag movies)


This howto provides some usual information on creating frag movies (or any other videos) with a powerful command line tool called mencoder. Mencoder is a part of mplayer and is used to deal with multimedia streams.


MPlayer is a movie player for Linux (runs on many other platforms and CPU architectures, see the documentation). It plays most MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files, supported by many native and binary codecs. You can watch Video CD, SVCD, DVD, 3ivx, DivX 3/4/5 and even WMV movies, too.


mencoder (MPlayer’s Movie Encoder) is a simple movie encoder, designed to encode MPlayer-playable movies (see above) to other MPlayer-playable formats. It encodes to MPEG-4 (DivX/Xvid), one of the libavcodec codecs and PCM/MP3/VBRMP3 audio in 1, 2 or 3 passes. Furthermore it has stream copying abilities, a powerful filter system (crop, expand, flip, postprocess, rotate, scale, noise, RGB/YUV conversion) and more.

Building a video from screenshots

If you are using quake on a UNIX based operating system and ezQuake 1.9 or older, then most probably you can capture screenshots at most (unlike windows, where you can capture and encode video on the fly) with mencoder it is quite easy to compile multiple screenshots into an encoded or raw video file. To compile all .jpg files in the current directory and use 30 files per second:

mencoder "mf://*.jpg" -mf fps=30 -o output.avi

To have the motion unchanged, the fps setting must match the one used during capturing. Changing this value may result in slower or faster playback later. The speed of the output video file can be also adjusted with the -speed parameter. If your capture resulted in getting tga files instead of jpg just replace mf://*.jpg with mf://*.tga.

Building a video from other video files

You can do the same with multiple video files, compiling them into one, and possibly encoding. Note though that if the video files vary in resolution, the output video’s resolution will be the largest from the input videos. The other files will be decorated with black borders around them.

To compile all .avi files in the current directory:

mencoder *.avi -o output.avi

Note that you might have to add -nosound to the command line due to various problems.


There are many codecs available to use with mencoder. Each one has it’s own specific encoding options. Short description of the most popular codecs follows. To see what video and audio codecs are available to you, issue the following command:

mencoder -ovc help -oac help

You will be shown a list of possible codecs for audio and video. Selecting a codec is done by -ovc <vidcodec> and -oac <audiocodec> in the command line, where ovc stands for output video codec and oac is output audio codec. The most important encoding settings are bitrate, pass, speed and aspect.

xvid codec

To encode a video file with the xvid codec (recommended for Frag Of The Week), the -ovc parameter has to be set to xvid and -xvidencopts should follow to enable custom encoding options. Possible encoding options are:

pass=<1|2> - specify the pass in two pass mode
bitrate=<x> - specify the bitrate of the file being encoded (the more, the better quality and bigger file size)


mencoder input.avi -o output.avi -ovc xvid -xvidencopts bitrate=3000

For best results use the two pass mode. Some tasks, such as encoding a live feed in real time, TV-capture or a security camera allow for single pass mode only. In any other case it is recommended to use two pass mode. It is often necessary to resize the final movie clip to the desired resolution and use gamma settings other than the default.
Example of encoding with 2-pass mode, resizing to 320×240 and altering the gamma level to 1.5:

mencoder "mf://*.tga" -mf fps=25 -o /dev/null -ovc xvid -xvidencopts pass=1:bitrate=3000 -vf scale=320:240,eq2=1.5
mencoder "mf://*.tga" -mf fps=25 -o output.avi -ovc xvid -xvidencopts pass=2:bitrate=3000 -vf scale=320:240,eq2=1.5

The bitrate setting in the first pass is not really needed and mencoder can ignore it.
Mencoder uses the data gathered from the first pass via the divx2pass.log file (so stay in the same dir).

x264 codec

This codec can give very good quality while the file size remains low. It is rapidly gaining popularity among groups releasing movies. The use is very similar to xvid. -ovc has to be set to x264 and the parameter -x264encopts allows for further customization. The nr encoding parameter stands for noise reduction, which might be useful for bad quality videos. Example:

mencoder input.avi -o output.avi -ovc x264 -x264encopts bitrate=3000 pass=1 nr=2000

MPEG codec

The MPEG muxer can generate 5 types of streams, each of which has reasonable default parameters that the user can override. Generally, when generating MPEG files, it is advisable to disable mencoder’s frame-skip code (see -noskip and -mc). Example:

mencoder input.avi -o output.avi -ovc lavc -mpegopts format=mpeg2:tsaf:vbitrate=8000 -nosound

lavc filter

This filter is supposed to give best quality and relatively small files, according to MPlayer’s manual.The following example shows one way of encoding a file with lavc. Example:

mencoder "mf://*.jpg" -mf fps=30 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4

Another example:

mencoder input.avi -o output.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:mbd=1:vbitrate=2800

Using audio

At the current stage of ezQuake’s development, there is no possibility to record quake sounds in Linux during capturing. It is still possible to use an audio file as soundtrack. Furthermore, it is possible to encode the audio track (-oac). The -noaudio parameter can be used to remove audio from a video file or not to use audio when compiling one. However, an audio stream can be included thanks to the -audiofile parameter. In this next example, mencoder adds an audio track from a .wav file and encodes it to mp3.

mencoder input.avi -o output.avi -ovc copy -oac mp3lame -audiofile soundtrack.wav

It is also possible to add an audio stream which is already encoded:

mencoder input.avi -o output.avi -ovc copy -oac copy -audiofile soundtrack.mp3

It is a good idea to prepare the audio track beforehand. There is a great tool with GUI to do that under Linux, called Audacity. The program is very easy to use thanks to an intuitive interface. It allows mixing, cutting and rearranging of audio files and can export the results to mp3.