MythTV podcast

引き続き MythTV のセットアップ。http://www.myth2ipod.com/myth2ipod.htmlスクリプトを使用する。iPod.pm はすでに入っていたので、myth2ipod.txt だけ落としてきてインストール。このスクリプトでは、nuvexport で mp4 に変換してくれるらしいのだが、なぜか ffmpeg浮動小数点演算で落ちてしまう(´・ω・`)仕方ないので、ffmpeg を直接動かすように変更。試しに一つ動画を変換してみて、iTunes に登録。無事に読み込み完了(・∀・)

PSPにもRSSチャンネルとして登録してみると、アイテムがありませんとはねられてしまう。いろいろ調べてみると RSS feed の pubDate のフォーマットがよろしくないらしい。こちらもスクリプトで対応。修正のまとめは以下の通り。

--- myth2ipod.txt	2006-03-06 14:05:06.000000000 +0900
+++ /usr/local/bin/myth2ipod.pl	2007-04-15 16:38:03.994844856 +0900
@@ -88,20 +88,27 @@
 	PrepSQLRead();
 	$db_handle = DBI->connect("dbi:mysql:database=$db_name:host=$db_host", $db_user, $db_pass)
 	or die "Cannot connect to database: $!\n\n";
-		$sql = "SELECT title, subtitle, description, category, starttime FROM recorded WHERE chanid = $chanid AND DATE_FORMAT(starttime,'%Y%m%d%H%i%s') = $start";
+#		$sql = "SELECT title, subtitle, description, category, starttime FROM recorded WHERE chanid = $chanid AND DATE_FORMAT(starttime,'%Y%m%d%H%i%s') = $start";
+		$sql = "SELECT title, subtitle, description, category, DATE_FORMAT(starttime,'%a, %d %b %Y %H:%i:%S +0900') FROM recorded WHERE chanid = $chanid AND DATE_FORMAT(starttime,'%Y%m%d%H%i%s') = $start";
 
 		$statement = $db_handle->prepare($sql)
 			or die "Couldn't prepare query '$sql': $DBI::errstr\n";
 		
 		$statement->execute()
 		or die "Couldn't execute query '$sql': $DBI::errstr\n";
-		$row_ref = $statement->fetchrow_hashref();
+#		$row_ref = $statement->fetchrow_hashref();
+		$row_ref = $statement->fetchrow_arrayref();
 		if($debug == 1){ print "$row_ref->{starttime}\n"};
-	$title = $row_ref->{title}; 
-	$subtitle = $row_ref->{subtitle};
-	$recorddate = $row_ref->{starttime}; 
-	$description = $row_ref->{description};
-	$category = $row_ref->{category};
+#	$title = $$row_ref->{title}; 
+#	$subtitle = $$row_ref->{subtitle};
+#	$recorddate = $$row_ref->{starttime}; 
+#	$description = $$row_ref->{description};
+#	$category = $$row_ref->{category};
+	$title = $row_ref[0]; 
+	$subtitle = $row_ref[1];
+	$description = $row_ref[2];
+	$category = $row_ref[3];
+	$recorddate = $row_ref[4]; 
 	$filename = $title."-".$subtitle."-".substr $start, 0, 8;
 	$filename =~ s/ /_/g;
 	$filename =~ s/&/+/g;
@@ -133,6 +140,13 @@
 # Encode for Portable
 #
 sub EncodeIt { 
+    $cmd = "/usr/bin/ffmpeg -y -v 0 -i $directory$chanid\_$start.mpg -aspect 16:9 -s 320x240 -f mp4 -vcodec xvid -deinterlace -qscale 5 -acodec aac -ar 48000 -ab 128 -ac 2 $feedpath$chanid\_$start.$portable.mp4";
+    if(system($cmd)) {
+	print "MP4Box cleanup seems to have failed\n";
+    } 
+    return 0;
+
+
 	# Create cutlist from commercial flagging if -cut was passed to the script
 	if ($cut == 1){
 	printf("Generating cutlist\n");