Solving choppy and distorted sound while playing back video on Ubuntu 12.04 LTS (Precise Pangolin)

Since installing Ubuntu 12.04 LTS on my Core I5 computer, I’ve noticed that I’ve problem with Video/Audio playback on my computer.

It turns out that it only affects computer with Intel-based sound chip. To confirm that you have Intel based audio chip, you need to run this command:

sudo lshw -c multimedia

If Intel chip is present, then you should see something like this at the bottom of the output:
[bash]
configuration: driver=snd_hda_intel latency=32
resources: irq:16 memory:fe024000-fe027fff

[/bash]

To fix it, you need to add “options snd-had-intel model=generic” at the end of /etc/modprob.d/alsa-base.conf file.

This should fix the problem with choppy/laggy sound while playing video.

How to extract Audio from Youtube Flash Video (FLV) in Ubuntu Linux

First you need youtube-dl tool or ‘cclive’ to download the Youtube .FLV file.

Then, download the Youtube stream.
python youtube-dl http://www.youtube.com/watch?v=lee7a55401e

Alternatively, you can use ‘cclive’ to download the youtube stream.
cclive http://www.youtube.com/watch?v=lee7a55401e

After that, use ffmpeg to extract the audio and encode it to MP3
ffmpeg -i lee7a55401e.flv vn -acodec libmp3lame -ab 128000 -ar 44100 lee7a55401e.mp3

Note: You need to install the restricted codecs in order to extract MP3 audio files.

Thanks Mohammad Bahathir Hashim for the tip!