[NCLUG] Video recording with Linux

Sean Reifschneider jafo at tummy.com
Tue Jun 26 22:55:44 MDT 2001


Jamie/LUGs: Some quick background.  You may know we converted all our CDs
to mp3s.  Now I'm working on converting our movies to ditigal format as
well, so we can store them in boxes in the garage next to our CDs, instead
of having a 100+ VHS tapes cluttering the living-room and dining-room.
I'm copying you on it because you asked about video editing under Linux.

A couple of years ago I wrote some code to run 3 Sony 200-disc CD changers
from a Linux machine.  It would do random play, pausing the players until a
song was done on one, then unpausing another player and asking the first to
seek to another song I hadn't heard and pause there.

This was nice because it allowed us to listen to all our CDs in random play
without having to swap them every 60 minutes (or less often).  The problem
though was that it was that I never had a very good index of what was
there, and couldn't ask it to "play Hound Dog for me" -- I could just ask
that it play track x of disc y on player z for me.

I spent a couple weeks converting all our CDs to mp3, and it was SO much
nicer.  Not to mention that it freed up about 2.5'x2.5'x3.5 feet of space,
and allowed us to listen to our music in the car or other places.  It also
let us play whatever we wanted to hear.  For the most part, our CDs are
stored in boxes now and I don't worry about them at all.

I want to have the same convenience with movies.  Another hard drive or two
in an existing machine by the stereo, playing music and our movies.  No
hunting for tapes, no storing a couple hundred VHS tapes in our diningroom
furnature and (more often) on the floor by the stereo...

So, I got my new video capture card last week and it works great...  This
is the card that includes both video in and out ports on the card.  The
card itself does MJPEG compression (basically, jpeg compression of every
frame in hardware) and ships that data across the bus.  So, recording and
play-back are relatively easy -- you just suck the data from the driver and
stick it on the hard drive, or vice-versa.  Very little CPU power is
required...

Getting recording and playback to happen was very easy -- just install the
driver and a simple application and record, then use it's companion app to
play back.  looks great.

The most important controls are "-d" which sets the scaling and "-q" which
sets the jpeg image quality.  "-d1" is something around 640x480 images,
"-d2" is half that.  "-d2" is considered "VHS quality", apparently VHS (and
DVD I believe) saves the half-size images.  As I understand it, VHS just
records the composite signal, one field per swipe of the serpentine heads
(two fields required for a single frame).  I'm sure Jamie will correct me
if I'm wrong...

The biggest influence on the resulting size is the "-q" flag for jpeg
quality.  This box with a single IBM hard drive (unknown if it's 7200 or
5400RPM) could handle up to settings of about "-d1 -q75" before it started
being unable to keep up and would drop frames...  I'm currently running
some captures of movies trying out "-d2 -q90" and "-d2 -q80".  Evelyn
proclaimed "-d2 -q70" to be acceptable...

I found that "-q20" even" looked ok, it was mostly in text like the titles
that it was noticable in the sample video stream I was testing on.  For
some comparisons, I recorded random parts of a video in chunks of 90
seconds (I believe):

-rw-------    1 root     root     130501716 Jun 22 19:58 videoI-d1-q100
-rw-------    1 root     root     128181136 Jun 22 20:00 videoK-d1-q90
-rw-------    1 root     root     116975036 Jun 22 19:59 videoJ-d1-q80
-rw-------    1 root     root     732476576 Jun 22 20:14 videoL-d1-q75
-rw-------    1 root     root     22927572 Jun 22 20:23 videoL-d2-q1
-rw-------    1 root     root     43433488 Jun 22 20:21 videoL-d2-q25
-rw-------    1 root     root     69340856 Jun 22 20:19 videoL-d2-q50
-rw-------    1 root     root     90262192 Jun 23 06:19 videoM-d2-q70
-rw-------    1 root     root     95686380 Jun 22 20:16 videoL-d2-q75

The "videoL" series was the same exact scene done over for each test.  -q1
was useless.  -q70 is about 1MB/sec, or 3.6GB per hour.

The low-hanging fruit here is the audio.  Audio makes up around 150KB/sec
of this.  The "-q1" above is 60% audio data.  Converting to mp3 format
gives something around a 10:1 decrease in audio size alone.

There are tools for taking the recorded stream and splitting out the audio
and video.  Then one can convert the audio to mp3, and the video to mpeg2.
I did a test on this with the "videoM" above using "-d2 -q70", and found
that it reduced the file size from 90MB down to 15MB, for an overall rate
of around 600MB/hour.

That I could live with -- that would put the average move down to around
1GB, which would cost under $3 per movie to store on big-ass hard-drives.
All our video tapes would fit in a couple of 80GB hard drives.  Playing
this back on the computer display looks really crappy, but playing the
original mjpeg does too.  On the TV it seems to look fine.

I haven't yet figured out how to play the mpegs to the video out on the
capture card...  If that's not possible, I'll have to go for a video card
that has composite/s-video out (which I haven't had good luck getting my
laptop to do -- it has s-video).

The thing I'm really trying to go for here is to use DiVX (which as I
understand it is an implementation of MPEG4).  I've heard claims of 10x
better than mpeg2 with "VHS quality", but I don't think that's going to be
100MB per hour.  I'm hoping to get it down to somwhere around 500MB for the
average movie.  That'd put storage cost pretty close to a buck per movie.

Here's what I'm playing with now:

   Hardware:
      Pinnacle DC10Plus card, Zoran-based card -- $100
         S-Video and composite in and out
      Miro DC10, BT9xx-based card -- $50
         S-Video and composite in only
      ESS 1371 audio card: $20
      1GHz Celeron FlipChip system
      100MB RAM
      No video card to speak of.  The net is a wonderful thing.
      IBM hard drive

   Software:
      lav tools (record and playback): Part of MJPEG Tools
      MJPEG Tools (conversion): http://mjpeg.sourceforge.net/
      avifile (divx conversion): http://divx.euro.ru/

I played some with the Miro card under Windows, and used the provided
software for doing editing.  It's pretty sweet...  I took a sample from
Tokyo Extreme Racing where they cut back and forth between actual street
racing scenes and scenes from the game...  I recorded that segment, and
then used the software to remove all the game scenes.  It worked worked
pretty well, but it really doesn't seem to be rocket science that they're
working on.

Apparently, Broadcast 2000 and Main Actor, both available for Linux, are
considered to be fairly high-quality tools for doing editing.  I haven't
mucked with them yet because I mostly want to just rip, and not do any
creation of my own films.  I could see using it for that if one had a video
camera though.  It should be pretty easy to do some pretty good-looking
videos using them though.

Well, that's what I've been doing with my copious spare time over the last
few weeks...

Sean
-- 
 It is far from clear whether "good intentions plus stupidity" or "evil
 intentions plus intelligence" have wrought more harm in the world.
                 --- Domer, The Logic of Failure
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python



More information about the NCLUG mailing list