From 6ab397855fde341417761a2e91667c85cbfc41ef Mon Sep 17 00:00:00 2001
From: "Alan J. Pippin" <ajp@server.pippins.net>
Date: Fri, 7 Nov 2008 13:27:45 -0700
Subject: [PATCH] Fixed reboot option in cmd script. Added support for new
 dvgrab 3.2, which included adding .avi extension on grabbed video files, and
 new --rewind option.

---
 make_home_videos.cmd |  2 +-
 make_home_videos.pl  | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/make_home_videos.cmd b/make_home_videos.cmd
index ac3fa22..ce6b266 100755
--- a/make_home_videos.cmd
+++ b/make_home_videos.cmd
@@ -68,5 +68,5 @@ popd > /dev/null
 echo "-> Rebooting the system in 10 seconds... Press CTRL-C to abort..."
 sleep 10
 echo "-> Rebooting now..."
-sudo /sbin/reboot
+/sbin/reboot
 
diff --git a/make_home_videos.pl b/make_home_videos.pl
index a35a983..33c0c0d 100755
--- a/make_home_videos.pl
+++ b/make_home_videos.pl
@@ -35,7 +35,7 @@ $max_dv_clip_size_in_mb = "1023"; #I had to keep it at this size to avoid errors
 # max_tape_grab_time=7200 Allows Max time of 2 hours to allow a tape to be dumped (good for 90 min tape)
 # max_tape_grab_time=5400 Allows Max time of 1.5 hours to allow a tape to be dumped (good for 60 min tape)
 $max_tape_grab_time = 5400;
-$dvgrab_options = "--autosplit --timestamp --format dv2 --opendml --buffers 500";
+$dvgrab_options = "--autosplit --timestamp --format dv2 --opendml --buffers 2048 --rewind";
 $encode_options_pass1 = "-mc 0 -oac mp3lame -lameopts cbr:cbr=128 -ffourcc XVID -fps 29.97 -ovc lavc ";
 $encode_options_pass1.= "-lavcopts vcodec=mpeg4:vhq:vbitrate=$bitrate:keyint=15:vpass=1 -vf pp=ci";
 $encode_options_pass2 = "-mc 0 -oac mp3lame -lameopts cbr:cbr=128 -ffourcc XVID -fps 29.97 -ovc lavc ";
@@ -172,6 +172,14 @@ sub capture_videos {
     alarm(0);
     sleep 5; # Give some time to catch an interrupt if needed
     print "-> Done grabbing video from camera\n\n";
+
+    # Now see if we need to add a ".avi" extension to the video files dvgrab created
+    opendir(VIDEODIR, $video_directory) or die "-E- Could not open: $video_directory";
+    my @all_files = readdir VIDEODIR;
+    closedir(VIDEODIR);
+    foreach $file (@all_files) {
+      if(($file =~ /$opt_n/) && ($file !~ /$opt_n.*?\.avi/)) { rename("$file","$file.avi"); }
+    }
 }
 
 sub encode_videos {
-- 
2.34.1