Location: PHPKode > projects > WebVCR+ > recorder.php
<script language="JavaScript">
<!--
function select_recorder()
{
	index = document.recorderform.recid.selectedIndex;
	recprog = document.recorderform.recid.options[index].text;

	if (recprog == "(mjpegtools)lavrec")
		document.recorderform.recprog.value='lavrec --use-read --batch -i N -q #VQUALITY# -s -l 85 -R l -f q -g 352x240 -t #TIME# --file-flush=0 --software-encoding "#OUTPUT#.qt"';
	if (recprog == "(nvrec)divx4rec")
		document.recorderform.recprog.value='divx4rec -Q -o "#OUTPUT#.avi" -vb #VBITRATE# -vq #VQUALITY# -ab #ABITRATE# -input #SOURCE# -norm #NORM# -F $[#TIME#*30]';
	if (recprog == "vcr")
                document.recorderform.recprog.value='vcr --codec #CODEC# -a \'Bitrate=#VBITRATE#,Crispness=#CRISPNESS#\' --source #SOURCE# --quality #VQUALITY# --audiobitrate #ABITRATE# -p #STATION# --rectime #TIME#s "#OUTPUT#.avi"';
	if (recprog == "(mplayer)mencoder")
		document.recorderform.recprog.value='mencoder -quiet -tv on:driver=v4l:width=352:height=240:input=0:device=/dev/video0:norm=NTSC:chanlist=us-cable:channel=#STATION# -ovc lavc -lavcopts vcodec=#FFMPEGCODEC#:vbitrate=#VBITRATE# -oac mp3lame -lameopts cbr:vol=6:br=#ABITRATE# -endpos #TIME# -o "#OUTPUT#"';



}
//-->
</script>

<?php
 // $Id: recorder.php,v 1.14 2003/02/13 08:19:25 chuckw Exp $
 // $Author: chuckw $

include("lib/functions.php");

/* under construction */
if ($SUBMIT == "Save") {
	$sql->query("UPDATE config SET value='".$recprog."' ".
		"WHERE name='recprog'");
        $sql->query("UPDATE config SET value='".addslashes($chanid)."' ".
	        "WHERE name='chanid'");		
	$sql->query("UPDATE config SET value='".addslashes($quality)."' ".
		"WHERE name='quality'");
	$sql->query("UPDATE config SET value='".addslashes($keyframes)."' ".
		"WHERE name='keyframes'");
	$sql->query("UPDATE config SET value='".addslashes($audiobitrate)."' ".
		"WHERE name='audiobitrate'");
	$sql->query("UPDATE config SET value='".addslashes($recordsource)."' ".
		"WHERE name='recordsource'");
	// updating the codec config and the codec
	$cid=getconfig("codec");
	$sql->query("UPDATE codecconfig SET bitrate='".addslashes($bitrate)."',".
		"crispness='".addslashes($crispness)."' ".
		"WHERE cid='".$cid."'");
        $sql->query("UPDATE config SET value='".addslashes($codec)."' ".
                "WHERE name='codec'");
        $sql->query("UPDATE config SET value='".addslashes($norm)."' ".
	                 "WHERE name='norm'");
						
}

print_header_open();
print "<script src=\"popup.js\"></script>";
print_title ("recorder config");
print_header_close();

?>

<FORM ACTION="recorder.php" METHOD=POST NAME="recorderform">
<center>
<table border=1><tr bgcolor="#006666">
<td><center><font color="#FFFFFF">Video Recorder Configuration</font></center></td>
</tr>
<tr bgcolor="#E0E0E0"><td>
<table border=0>
<?php 

$recprogs = array("(mjpegtools)lavrec" =>
	     'lavrec --use-read --batch -i N -q #VQUALITY# -s -l 85 -R l -f q -g 352x240 -t #TIME# --file-flush=0 --software-encoding "#OUTPUT#.qt"',
	     "(nvrec)divx4rec" =>
             'divx4rec -Q -o "#OUTPUT#.avi" -vb #VBITRATE# -vq #VQUALITY# -ab #ABITRATE# -input #SOURCE# -norm #NORM# -F $[#TIME#*30]',
	     "vcr"  => 
             'vcr --codec #CODEC# -a \'Bitrate=#VBITRATE#,Crispness=#CRISPNESS#\' --source #SOURCE# --quality #VQUALITY# --audiobitrate #ABITRATE# -p #STATION# --rectime #TIME#s \"#OUTPUT#.avi\"',
	     "(mplayer)mencoder"   =>
             'mencoder -quiet -tv on:driver=v4l:width=352:height=240:input=0:device=/dev/video0:norm=NTSC:chanlist=us-cable:channel=#STATION# -ovc lavc -lavcopts vcodec=#FFMPEGCODEC#:vbitrate=#VBITRATE# -oac mp3lame -lameopts cbr:vol=6:br=#ABITRATE# -endpos #TIME# -o "#OUTPUT#"');
$norms = array("NTSC (USA)"=>"NTSC","PAL (Europe)"=>"PAL","SECAM"=>"SECAM");
print "
<tr>
        <td>Channel Changing Program</td><td>:</td>
	<td>
	<SELECT NAME=\"chanid\">";
print_select_chan_prog(getconfig("chanid"));
	print "
	</SELECT>
	</td>
</tr>
		
<tr>
	<td>Recording Quality (max 100)</td><td>:</td>";
$quality=getconfig("quality");
print "
	<td>".text_widget("quality")."</td>
</tr>
<tr>
	<td>Key frames (max 30)</td><td>:</td>";
$keyframes=getconfig("keyframes");
print "
	<td>".text_widget("keyframes")."</td>
</tr>
<tr>
	<td>Audio Bitrate</td><td>:</td>";
$audiobitrate=getconfig("audiobitrate");
print "
	<td>".text_widget("audiobitrate")."</td>
</tr>
<tr>
	<td>Recording Source</td><td>:</td>";
$recordsource=getconfig("recordsource");
print "
	<td>".text_widget("recordsource")."</td>
</tr>
<tr>
        <td>Norm</td><td>:</td>";
	$norm=getconfig("norm");
	print "
        <td><select name=\"norm\">";
        foreach ($norms as $name => $normval)  {
                if ($normval == $norm) {
                        print "<option selected value=\"$normval\">$name</option>\n";
                }
                else  print "<option value=\"$normval\">$name</option>\n";
        }
	print "
	</select>
	</td>
</tr>

<tr>
	<td>Codec</td><td>:</td><td><select name=\"codec\">";
$cid=getconfig("codec");
print_select_codec($cid);
print "</select></td></tr>
<tr>
	<td>Bitrate</td><td>:</td>";
$bitrate=getcodecconfig("bitrate");
print "
	<td>".text_widget("bitrate")."</td>
</tr>
<tr>
	<td>Crispness</td><td>:</td>";
$crispness=getcodecconfig("crispness");
print "
	<td>".text_widget("crispness")."</td>
</tr>
<tr>";
$recprog=getconfig("recprog");
print "
        <td>Recording Program Presets</td><td>:</td>
        <td>
        <SELECT NAME=\"recid\" onChange=select_recorder()>";
	foreach ($recprogs as $name => $prog)  {
		$recprog_name = preg_replace("/\(.+\)/","",$name);
		if (preg_match("/$recprog_name/",$recprog)) {
			$preset = 1;
			print "<option selected>$name</option>\n";
		}
		else  print "<option>$name</option>\n";
	}
		if (!$preset)
			print "<option selected>Custom</option\n";
		else print "<option>Custom</option>\n";
		print "</select>\n";
print "
        </td>
</tr>

<tr>
        <td>Recording Program - <a href=\"javascript:LaunchPopup('record_help.html','640','480','1');\">Help</a></td><td>:</td>
        <td>";
	print text_widget("recprog");
print "
        </td>
</tr>
<tr>";
?>
</td>
<tr>
<td colspan=3 align=center>
	<a href="config.php">General Configuration</a>
</td>
</tr>
 
  <TD COLSPAN=3 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME=SUBMIT VALUE="Save"></TD>
     </TR>
</TABLE>
</table>
</center>
</FORM>

<?php
print_page_close();
?>

Return current item: WebVCR+