Small Video Processing Guide

From IridiaWiki
Jump to: navigation, search

This is a Linux based solution. It has been tested under SuSE 9.3, and it should work under Debian as well if the system is properly configured.


Part A) Requirements

1. Firewire interface

2. Disk space (around 13GB per hour of tape)

3. Software

For video capture and mpeg encoding, I installed the following packages (debian packages of similar name should be available). I would suggest to install mplayer and transcode first, and then you have a look to what could be missing.

dvgrab-2.0-1.pm
libiec61883-1.0.0-1
lame-3.96.1
mplayerplug-in-2.80-0
MPlayer-1.0pre7
w32codec-all-20050412-0
a52dec-0.7.4-3
libffmpeg0-0.4.9-3
faad2-2.0-0
lve-0.040322-0
ffmpeg-0.4.9-3
mjpegtools-1.7.0-0
libfame-0.9.1-0
transcode-0.6.14-0
libraw1394-1.1.0-3

Part B) How to retrieve movies from a digital camcorder.

1. Attach the camcorder with the firewire cable to your computer.

2. Turn in on, and insert a tape.

3. Become super user.

4. Execute (assuming it is tape 1 of your collection):

dvgrab --autosplit --format dv2 --opendml --size 0 --buffers 512 tape1-

5. The camera starts automatically, once the tape is finished stop the process.

Remarks: There can be problems, if

a) your filesystem (e.g. FAT32) does not allow for files bigger than 2GB,
b) your kernel does not recognize the camera (capture does not start),
c) if your harddisk is running out of space (1 hour tape is 13 GB approx.),
d) if your harddisk is slow (e.g. some external USB) it cannot handle the constant flow of data coming from the camera.

Normally, each scene goes in a separate file. However, sometimes, a scene is split by mistake into multiple files. These files you can merge with

avimerge -i file1 file2 file2 ... -o together.avi

Sometimes it can happen also that several scenes go into a single file. For this check

man avisplit

Part C) How to make small MPEG4 movies for your webpage including author and institution frames.

1. Prepare author and institution frames (if applicable, ask Marco).

a) For swarm-bots, we have Photoshop templates (ask Roderich or Christos for the file if it was already created for you). Convert them with Gimp to the ppm format and name them author.ppm and end.ppm. The author frame comes right after the movie, the instituiton frame appears in the end.

b) If you have a single ppm file, you can make a movie out of it using the following script ppm2avi.sh. For this, ppmtompeg has to be installed.

Example: To have the author frame shown for 75 frames (i.e., 3 seconds; 25 frames per second) execute:

sh ppm2avi.sh author 075

It is necessary to specify all 3 digits (from 001 to 999).

 #!/bin/bash
 name=$1
 time=$2
 for I in `seq 1 ${time}`
 do
  if [ $I -lt 10 ]; then
    cp ${name}.ppm ${name}00$I.ppm
  else
    if [ $I -lt 100 ]; then
        cp ${name}.ppm ${name}0$I.ppm
    else
        cp ${name}.ppm ${name}$I.ppm
    fi
  fi
 done

cp paramfile.txt p.txt perl -pi -e "s/NNAAMMEE/${name}/g;" p.txt perl -pi -e "s/FFRRAAMMEESS/${time}/g;" p.txt ppmtompeg p.txt rm ${name}???.ppm rm p.txt

transcode -i ${name}.mpeg -y ffmpeg -F mpeg4 -Z 480x384 --encode_fields b -o ${name}.avi

You need to create the file paramfile.txt, name and timing are adjusted automatically by the script above:

PATTERN I
PIXEL HALF
IQSCALE 10
PQSCALE 10
BQSCALE 10
RANGE 10
PSEARCH_ALG LOGARITHMIC
BSEARCH_ALG SIMPLE
OUTPUT NNAAMMEE.mpeg
GOP_SIZE 5
SLICES_PER_FRAME  1
BASE_FILE_FORMAT PPM
INPUT_CONVERT *
INPUT_DIR .
INPUT
NNAAMMEE*.ppm [001-FFRRAAMMEESS+1]
END_INPUT
FRAME_RATE 25
REFERENCE_FRAME DECODED


2. Once you have the author and institution sub-movies, you just have to execute the following script for encoding the movies for your webpage:

#!/bin/bash for I in tape*.avi do basename=`echo $I | cut -d\. -f1` echo ${basename}.avi transcode -i ${basename}.avi -w 500 -x ffmpeg,avi -y ffmpeg -F mpeg4 -Z 480x384 --encode_fields b -o ${basename}_plain.mpeg --print_status 100 avimerge -i ${basename}_plain.mpeg author.avi end.avi -o ${basename}.mpeg done

Remarks:

a) You need all avi's in the same directory. The once from the tape start with tape, the others are called author.avi and end.avi
b) The size of these movies is only 480x384. This safes for sure space, and might even improve quality. MPEG4 will be standard in some future. It is based on DIVX as far as I understood. You can play the movies with mplayer, mplayer-plugin for mozilla.

Personal tools