Cinelerra Audio Sync Problem on Ubuntu Jaunty

Everytime I try to set up Cinelerra on a new project or on a new system configuration, it takes a while to get everything working well. In my case, I have several new variables to contend with: I’m starting with HDV footage from a new camera, I have a new machine, I’m using a new version of Ubuntu and of Cinelerra.

This time around, I’ve had trouble with audio sync during playback. The symptom is that when I play a dv clip (which is fine on its own in VLC) in the Compositor Window in Cinelerra, I get a 10 second audio time lag which seems impossible to correct by nudging or setting the audio offset value.

Fortunately, this doesn’t seem to affect rendering, but it still makes it tough to edit properly. After a great deal of fiddling, I finally discovered (via a note here) that I could use the Pulseaudio sound driver in Ubuntu (select “Esound” and port 7007 in the Cinelerra Playback settings) instead of ALSA. Suddenly, my project sounded much better. The audio track was still out slightly, but I used the technique described in Secrets of Cinelerra to sync the sound using the nudge value of the audio tracks. There is additional helpful info on audio syncing here.

I was surprised that this simple matter took so much searching to solve. Here’s hoping that this post will pop up in future searches.

To summarize, if you are running Cinelerra on Ubuntu and have audio sync problems, try switching your audio driver to “esound” on port 7007 and you may be pleasantly surprised.

UPDATE: This is very weird, but the above config works fine when I run Cinelerra as a user, but NOT when I run it as root! Obviously, I’ve got the PulseAudio settings messed up somewhere, but at least it works.

Capturing Old VHS Tapes

Yes, I’m digitizing everything — it’s like all of my belongings are slowly being vacuumed up into the computer.

This time it is VHS tape I’m working on. I’m not concerned about commercially recorded tapes — I got rid of all of those a while ago. Rather, I want to capture the tapes we have which are irreplaceable. In our case that is mostly videos which feature people in our family that we recorded from TV or other sources.

I figured the simplest method would be to feed the video out from a VCR to the AV IN on one of my cameras, then sent the output via firewire to my computer for capture using dvgrab. Turns out it worked like a charm.

I found a great explanation of the process here.

I used my old Panasonic PV-GS700 which no longer records properly — it works just fine to convert the analog signal to digital output. I had to switch the camera’s “DV OUT” setting to “ON” and it was ready to go. Here is the dvgrab command I used to capture the video (where “foo” is the base output filename):

dvgrab –frames 0 –size 0 –format raw -noavc -showstatus -d 02:10:00 foo

Note: if you are keeping an eye on it, you can stop the capture at the actual end of the tape by pressing ctrl-c and the output file will still be fine. You don’t have to wait until the 2:10 mark — that is just for convenience so the capture doesn’t continue to run indefinitely.

As per the instructions in the link, the following command is a handy way to trim off the excess from the end of each file (where the time element is the place you want to end the clip):

dvgrab -showstatus -stdin -d 1:05:10 -s 0 foo-001_trimmed.dv < foo-001.dv

Display Video Thumbnails in DigiKam

Digikam is working great for me and I’m diligently tagging all my old photos. I was disappointed that, although DigiKam could play them, it wouldn’t display thumbnails for video files in my albums. Turns out that I just needed to install the mplayerthumbnails package and now I have thumbnails. In Ubuntu Jaunty, ignore instructions which suggest adding libarts1-xine and libxine-extracodecs — neither package is available in Jaunty.

Hauppauge WinTV-HVR 950Q USB TV Tuner

I purchased a USB TV tuner device hoping to be able to do two things: a) receive (and possibly record) analog NTSC TV broadcasts, and b) accept analog input from a VCR to digitize some old VHS media.

After a lot of red herrings and attempts to install drivers, I finally understood that the device had been detected in Ubuntu Jaunty without any extra effort. Configuring the device was a little more complicated, however. I installed the following packages to help diagnose whether the device was working: dvb-apps, dvb-utils, w-scan. Unfortunately, I’ve discovered that apparently Video4Linux doesn’t support receiving analog signals with this device (my fault for not doing more research, I guess). We don’t have digital signals where I live (and I don’t have digital cable or any other usable sources available).

Potentially helpful info here and here.

Plan B: try to get the device running under Windows XP in VirtualBox.

Capturing from Canon Vixia HV40 in Ubuntu

I am very pleased to report that capturing from my new camera works like a charm.  I hardly had to do any tweaking to get it to work.

Here are some commands that worked for me to begin with:

  • grab video
    sudo dvgrab –autosplit –frames 0 –size 0 –format hdv –buffers 1000 –showstatus –timestamp /home/video/foo-
  • convert to avi format for facebook, etc.
    ffmpeg -i foo.m2t video.avi
  • convert to dv format for editing
    ffmpeg -i /home/video/foo.m2t -target ntsc-dv foo.dv

New Camera

Just bought a new camera: a Canon Vixia HV40. Since my old beloved Panasonic died, I’ve decided I should plan for the future by moving to HD. Even so, I also wanted to stick with MiniDV tapes rather than HDD storage. This camera is perfect for me.

I love the HV40. I haven’t found anything not to like yet. My only small complaint is that the battery pack connection has a little play in it when attached to the camera.

Convert Raw MiniDV Footage to Upload to Facebook

I just shot a bit of footage I wanted to upload to Facebook. According to this Facebook question, mpeg4 video is a good choice.

This command seems to do the trick to convert my rawdv footage to a Facebook friendly format:

cat foo.dv | ffmpeg -f dv -i pipe: -acodec libfaac -vcodec libx264 -s 640×360 -aspect 16:9 foo.mp4

Note that the names of the codecs in this command seem to vary according to your version of ffmpeg.  If this version doesn’t work, you might try faac and h264 instead of libfaac and libx264, respectively.

Setting up/Moving a Cinelerra Project

I finally decided to reorganize my current video project to make things easier to find.  For starters, I realized that all the raw dv footage I’ve captured should not be in the same folder as the project itself.  That is a recipe for creating copies of the same footage later when I want to use it in another project.

Instead, I created a folder for my footage named by date and subject and stored it with the rest of my similar captured footage.  That way it is ready for me to grab for any project.  Next, I created a project folder (I called it “project_wbp” in my case).  Inside that I added another folder called “media_rawdv”.  Then I used this command in a terminal:

ln -s -t /path/to/media_rawdv /path/to/original/*.dv

That command creates symbolic links (i.e. shortcuts) to all the original files.  Cinelerra doesn’t care whether its resources are real files or links, so this works fine.  Later, if I move the original files, I can just recreate the links and I’m all set.

There are two important steps  you need to do when you move things around or rename them in your project:

1. You should edit your project .xml file and change the paths as necessary (note that Cinelerra doesn’t seem to like relative paths, so you should use absolute ones).  Don’t forget to change the path to the xml file itself if that has moved.  Any text editor can handle this.

2. To save a lot of processing on large projects with many resources, you should rename all the project’s index files (you can change the location in Cinelerra’s settings, but they’re usually in ~/.bcast”) and change the internal paths in each file.  The following program should do the trick:

#first rename the files in .bcast
rename ‘s/home_video_oldname/home_video_project_wbp_media_rawdv/’ ~/.bcast/*.idx
#next use this to fix the internal paths in the index files
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
if [ -f $f -a -r $f ]; then
/bin/cp -f $f $BPATH
echo $f
sed “s/$OLD/$NEW/g” “$f” > $TFILE && mv $TFILE “$f”
echo “Error: Cannot read $f”
/bin/rm $TFILE

The only things to change in the preceding script are the two paths in the rename command and the same in the OLD and NEW variables.  Note the the index files include real paths (hence the \ escapes to make the literal / characters work), but in their names they replace the / characters with underscores.

For smaller projects, you could probably skip this step, as Cinelerra will regenerate the files anyhow.  For my 40 minute video, which has hundreds of clips, it takes hours to do this.   The script does the job in a couple of minutes.

Capturing Video Over Firewire in UbuStu

Today I wanted to capture some video from mini-DV tapes using my camera, a Panasonic mini-DV model. I have done so in the past using a firewire cable, but this is the first time I’ve tried with my new Ubuntu Studio setup.

Here are the steps to follow:

1. In “Ubuntu Studio Controls,” check “enable raw1394 access.” If you try to use your firewire device now, it may crash the machine, so you should reboot before proceeding. I had the system freeze up on me two or three times before I had everything working reliably (this may be a result of the wonky firewire connection on my camera, which seems to be loose).

2. After the reboot, put the camera into VCR mode and press play. Then run Kino (from a terminal as root) and switch to capture mode. You should see the video playing in the Kino window. Rewind the tape again before you proceed. This step seems to be necessary in order to get Ubuntu Studio to recognize the camera as a firewire device (dvgrab may work just as well).

3. If you aren’t capturing a whole tape, you could just use Kino to control the camera and capture the clips. I actually prefer to do the capture from the command line using dvgrab.  To begin capture, enter this command (again as root):

#dvgrab –autosplit –frames 0 –size 0 –format raw –timestamp <dest>/<foo>

In this command, <dest> is the place you want to store the clips (e.g. /home/video), and
<foo> is whatever prefix you want the resulting filenames to have (e.g. tape1-). The clips will automatically be split into files and the timestamp will follow the prefix in each name.

Once you run the dvgrab command, it will wait for you to press play on the camera and begin capturing the clips. You’ll have to press <ctrl>-c once the clips are finished being captured.

Because of the broken firewire connection on my camera, I investigated the possibility of using USB to capture video, but that doesn’t appear to be a viable choice (and much slower, even if one could get it to work).

More info on firewire in Ubuntu here: Firewire – Community Ubuntu Documentation

Auditioning Multimedia Distros (part 2 – pure:dyne)

So, after my brush with dyne:bolic, I decided to try pure:dyne. PD was originally a revised version of dyne:bolic, but the producers of it decided to go upstream and recreate their distro based on Debian — The Universal Operating System (the ultimate ancestor of many specialized distros, including Ubuntu).

I’ve been using Debian for nearly ten years now, and I believe it is a good foundation to start from.  Unfortunately, the pure:dyne folks have a lot of work to do in order to customize their version to the same extent as dyne:bolic.  For example, where dyne:bolic has organized its apps and utilities into a very hierarchical menu system which makes it easy to find the function you want, even if you don’t know the name of the application, pure:dyne dumps everything into a single menu folder.  Unless you already know all of the multimedia apps you want to use, you have to spend a long time exploring to begin to be productive.  This is a minor complaint, of course, and otherwise pure:dyne looks like it would suit my purposes just fine.

When I tried to run Cinelerra on “leek and potato,” the latest pure:dyne release, I couldn’t get past loading my project.  This was due to the USB hard drive problem I’ve been having with certain kernel versions.  Pure:dyne, through no fault of its own, inherited the same issue.

At this point, not yet understanding the source of the problem, I gave up and moved on to Ubuntu Studio.  Since my drive worked with Ubuntu Hardy on another machine, I reasoned that UbuStu might work better.  Meanwhile, PD looks like a good distro which I would happily use again.  I expect it will be even better in future versions.