Log in Register FAQ Memberlist Search pcHDTV Forum Index
pcHDTV Forum

pcHDTV Forum Index -> General pcHDTV topics -> implimenting recording/MythTV with cronjobs instead (fixed)
Post new topic  This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic 
implimenting recording/MythTV with cronjobs instead (fixed)
PostPosted: Sun Nov 21, 2004 4:24 pm Reply with quote
mspice
 
Joined: 03 Nov 2004
Posts: 36




After an entire night trying to get MythTV working with FC3 all I get is a black screen. From looking at these forums, it seems like if you mess up the slightest things you get this black screen and then it locks up.

I'm giving up on MythTV since this works beautifully and is more straightforward. I've implimented the recording and transcoding process with a series of cronjobs, including one that is for a perl script that transcodes the video based on what channel it gets. It's not beautiful but I'll share it incase it is usefull to anyone else.

Basically here is how it works: First, the cron jobs record the movies using dtvstream. They have a hardcoded naming convention title_channel#_date.m2t. Then, the processfiles.pl script that is run each night goes through the .m2t files (6GB each) and transcodes them using mencoder to .avi files (1GB each). The processfiles.pl uses the channel# that is in the filename to know what commands to pass mencoder. Each morning you have fresh divx .avi files. If you'd rather not encode them as divx files just don't run the processfiles.pl script and you'll still have all of your recorded shows.

To use it, just cut and paste these lines from my crontab into yours (use crontab -e). You'll need to edit the times (crontab format of: minute hour * * day), the duration (passed to dtvstream as -m), and the name of the show and channel in the filename. Anytime you want to add or delete a show, you just edit your crontab. Next, you'll need to edit processfiles.pl. You'll only have to edit it once. You'll see the basic structure where it checks to see what channel it was recorded from (from the filename) and then edit whatever options you want to pass mencoder for that channel.

If anyone wants to use my method and needs help editing files just let me know.

My crontab:
Code:
#minute hour dayotm month dayotw command
                                                                                                                                                     
#process all these movies to divx .avi's (this transcodes any already recorded movies)
0 2 * * * /movies/processfiles.pl
                                                                                                                                                     
#one timers
59 20 25 11 * /usr/local/bin/dtvstream -c 49 -p 2 -m 61 -o /movies/seinfeldstory_49_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
                                                                                                                                                     
#weekly shows
0 20 * * sun /usr/local/bin/dtvstream -c 32 -p 1 -m 59 -o /movies/desperatehousewives_32_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
                                                                                                                                                     
30 20 * * mon /usr/local/bin/dtvstream -c 59 -p 1 -m 29 -o /movies/twoandahalfmen_59_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
0 21 * * mon /usr/local/bin/dtvstream -c 59 -p 1 -m 59 -o /movies/csimiami_59_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
                                                                                                                                                     
0 19 * * tue /usr/local/bin/dtvstream -c 59 -p 1 -m 59 -o /movies/ncis_59_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
#0 19 * * tue /usr/local/bin/dtvstream -c 41 -p 3 -m 59 -o /movies/gilmoregirls_wb_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
                                                                                                                                                     
0 20 * * wed /usr/local/bin/dtvstream -c 49 -p 2 -m 59 -o /movies/westwing_49_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
0 21 * * wed /usr/local/bin/dtvstream -c 49 -p 2 -m 59 -o /movies/lawandorder_49_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
                                                                                                                                                     
0 20 * * thu /usr/local/bin/dtvstream -c 59 -p 1 -m 59 -o /movies/csi_59_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
0 21 * * thu /usr/local/bin/dtvstream -c 59 -p 1 -m 59 -o /movies/withoutatrace_59_`date \+\%m-\%d-\%y`.m2t 2>/dev/null
                                                                                                                                                     
#24 season 3 starts Jan 9th 8/7c on FOX


And here are the contents of processfiles.pl (which is run by the cron):
Code:
#!/usr/bin/perl
######################################################################################
# HDTV movie processor
#
# Look through a directory of recorded HDTV movies and convert them to something more manageable and
# reasonable.
#
# This scripat assues the files are named show_channel_date.m2t where date
# is mm-dd-yy.  This date can
# be obtained from `date +%m-%d-%y`.  For instance, you could use the following in a
# cronjob :
#
# dtvstream -c 49 -p 1 -m 60 -o westwing_49_`date +%m-%d-%y`.m2t
# -c channel
# -p program (subchannel)
# -m minutes
# -o outfile
#####################################################################################

use strict;

our $movie_dir = '/movies';
our $mencoder = '/usr/local/bin/mencoder';

foreach our $file (glob("$movie_dir/*")){
   my ($show,$channel,$date);
   $file =~ s/^$movie_dir\///i;
   if($file =~ /(.*)\.m2t$/){ # this is an unprocessed movie file
      ($show,$channel,$date)=split(/_/,$1);

      # channel uses 1920x1080 1080i
      if($channel eq "32"){
          `$mencoder "$movie_dir/$file" -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell -vf field=0 -o "$movie_dir/$show\_$date.avi"`;
         unlink("$movie_dir/$file");

      # channel uses 544x480p
      }elsif($channel eq "wb"){
          `$mencoder "$movie_dir/$file" -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell -vf field=0 -o "$movie_dir/$show\_$date.avi"`;
         unlink("$movie_dir/$file");

      # channel uses 1080i
      }elsif($channel eq "41"){
          `$mencoder "$movie_dir/$file" -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell -vf field=0,scale=960:540 -o "$movie_dir/$show\_$date.avi"`;
         unlink("$movie_dir/$file");

      # channel uses 1080i
      }elsif($channel eq "49"){
          `$mencoder "$movie_dir/$file" -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell -vf field=0,scale=960:540 -o "$movie_dir/$show\_$date.avi"`;
         unlink("$movie_dir/$file");

      # channel uses 1080i
      }elsif($channel eq "59"){
          `$mencoder "$movie_dir/$file" -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell -vf field=0,scale=960:540 -o "$movie_dir/$show\_$date.avi"`;
         unlink("$movie_dir/$file");

      # default case - this should never happen
      }else{
         print "ERROR:  Don't know how to handle $file!  $channel is not a valid channel.";
      }
   }
   
}


Last edited by mspice on Wed Nov 24, 2004 2:15 pm; edited 6 times in total
View user's profile Send private message
fixed now
PostPosted: Tue Nov 23, 2004 9:06 am Reply with quote
mspice
 
Joined: 03 Nov 2004
Posts: 36




I edited the above post to fix errors with the cron jobs. I forgot to escape a few characters used in the date formatting.

I'm using this method now and happily getting all of the shows that I want recording and then transcoding to DIVX each night to only take up 1GB each Smile
View user's profile Send private message
PostPosted: Thu Nov 25, 2004 12:54 am Reply with quote
Scott Larson
 
Joined: 15 Oct 2003
Posts: 713
Location: Portland, OR




For me, the reason I don't transcode HD to MPEG4 is because XvMC doesn't support MPEG4 hardware acceleration (at not on my system). That makes playing them very difficult. It works OK if crop and resize to SD but I wouldn't do that for stuff I want to keep forever (like the Olympics).
View user's profile Send private message
divx is light on the CPU
PostPosted: Thu Nov 25, 2004 9:23 am Reply with quote
mspice
 
Joined: 03 Nov 2004
Posts: 36




I understand you wanting to keep the full res version for things you want to keep forever, but I don't understand your other point. I assume that the reason you want to use XvMC is because it uses less CPU usage. Well, since I am resizing them as I encode them to Divx I end up using 20% CPU upon playback instead of the 90% that I was using with the full res MPEG2 streams. One of the reasons I resize them is to save space. The other is to be able to play them on my CPU without too much strain.

You could aways still use the cronjob method to record and simply not include the processfiles.pl cronjob so they'd stay full res original .m2t files.
View user's profile Send private message
implimenting recording/MythTV with cronjobs instead (fixed)
  pcHDTV Forum Index -> General pcHDTV topics
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 7 Hours  
Page 1 of 1  

  
  
 Post new topic  This topic is locked: you cannot edit posts or make replies.  


Powered by phpBB © 2001-2003 phpBB Group
Theme created by Vjacheslav Trushkin