Linux Video Creation Tutorial

January 4, 2009 in Online Video | Comments (0)

There is tremendous amounts of traffic in quality video syndication.   Here is how I setup my Unbuntu 8.04 Desktop to do screen captures and dump out to ogg, then convert to flv (so I could upload to the video syndication services, as they don’t accept ogg format).

I tried several video capture softwares for Ubuntu 8.04, but couldn’t get any of them to do exactly what I wanted. Then I found:

http://recordmydesktop.sourceforge.net

So I installed it (and the gui):


sudo aptitude install qt-recordmydesktop krecordmydesktop gtk-recordmydesktop

I ended up not liking the GUI, so I did this from the command line and recorded a portion of my desktop:


recordmydesktop -x 1 -y 480 -width 749 -height 544 -o output.ogg

However, most video sharing sites do not like ogg, and it’s not default for windows world to view the ogg files, even though it’s better quality and compression…

So, I had to convert using ffmpeg to flv and reupload


sudo aptitude install ffmpeg

So I converted using the defaults to see what I got…


ffmpeg -i in.ogg out.flv

and it looked horrible, plus it didn’t carry the sound…. grr.

Lets analyze what they are actually storing theirs in. I downloaded a youtube video and then ran this:

I installed a plugin for firefox that allows me to grab youtube videos:
Fast Video Download 1.61

Then I went and got an amazing video so I could see how they encoded/formatted their videos:

Sunga Jung 9 Year Old Musical Genius Playing Dune

After I cried a bit because of how talented this kid is…. I got back to work.


ffmpeg -i in.flv 2>&1 | grep Stream
Stream #0.0: Video: flv, yuv420p, 320x240, 29.97 fps(r)
Stream #0.1: Audio: mp3, 22050 Hz, mono, 64 kb/s

Here is what my recording looks like…


ffmpeg -i in.ogg 2>&1 | grep Stream
Stream #0.0: Video: theora, yuv420p, 752x544, 15.00 fps(r)
Stream #0.1: Audio: vorbis, 22050 Hz, mono, 89 kb/s

Ok, so I have to use flv @ 320×240 (or 640×480) with mp3

So, I know that my recording was done wrong and needs to be like so:


recordmydesktop -x 1 -y 544 -width 640 -height 480 -o out.ogg

I did some research and I had to enable the medibuntu repository and reinstall ffmpeg and some libraries…

sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
sudo apt-get remove ffmpeg
sudo apt-get install ffmpeg
sudo apt-get install libavcodec1d libavformat1d libavutil-dev libavutil1d libpostproc1d libswscale-dev libswscale1d

Then I tested again…


ffmpeg -i in.ogg -f flv -b 800 out.flv
ffmpeg -i out.flv 2>&1 | grep Stream
Stream #0.0: Video: flv, yuv420p, 752x544, 15.00 fps(r)
Stream #0.1: Audio: mp3, 22050 Hz, mono, 64 kb/s

Finally, video and sound! (Quality is still far worse than the original ogg, and it’s about 10% larger too)


recordmydesktop -x 1 -y 544 -width 640 -height 480 -o test.ogg
ffmpeg -i test.ogg -y -sameq out.flv

Ok finally quality is good, but the output file is 4x as big as the input.. oh well, that will have to do until I figure out how to make them smaller (I need to sleep).

EUREKA! (I didn’t sleep, instead I attacked, visciously until I figured out how)

After reading what seems like hundreds of articles on how to make huge flv files using the -sameq command…. the answer lies in the qmin and qmax settings.  I read the man pages, but couldn’t understand what the qmin qmax was for actually. You can raise the qmin and qmax to get lower quality but smaller files:


ffmpeg -i in.ogg -y -qmin 3 -qmax 6 out.flv (12MB)
ffmpeg -i in.ogg -y -qmin 3 -qmax 15 out.flv (8.1MB, but quality was still bad)

After testing various mins and maxes, I have the final conversion:


ffmpeg -i in.ogg -y -qmin 4 -qmax 8 out.flv (10MB, readable, though it's obviously compressed)

CONCLUSION

Video on Linux is not easy – and if I had been working for $10 an hour, this article (and FREE software) would of cost me almost $150 ! Video for Linux, in the linux world is pretty easy. Making it work for everyone else gave me a headache, but like all things linux – now that I know it will work forever.

INSTALL RECORDMYDESKTOP

sudo aptitude install qt-recordmydesktop krecordmydesktop gtk-recordmydesktop

INSTALL LATEST FFMPEG & LIBS

sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
sudo apt-get remove ffmpeg
sudo apt-get install ffmpeg
sudo apt-get install libavcodec1d libavformat1d libavutil-dev libavutil1d libpostproc1d libswscale-dev libswscale1d

SCREENCAST:

recordmydesktop -x 1 -y 544 -width 640 -height 480 -o test.ogg

CONVERT TO FLV:

ffmpeg -i test.ogg -y -qmin 4 -qmax 8 out.flv

Happy Syndicating!