6
use Config::Simple '-strict';
10
my $delete = param("delete");
11
my $title = param("title");
12
# remove whitespace, as it causes issues later
16
my $file = "/etc/mythtv/mythexport/mythexport_settings.cfg";
17
my $cfg = new Config::Simple(syntax=>'ini');
24
$cfg->read($file) || die $cfg->error();
28
my $template = HTML::Template->new(filename => 'template/template.tmpl');
31
$cfg->delete("$title.sizeX");
32
$cfg->delete("$title.sizeY");
33
$cfg->delete("$title.audioBR");
34
$cfg->delete("$title.videoBR");
35
$cfg->delete("$title.device");
36
$cfg->delete("$title.codec");
37
$cfg->delete("$title.deletePeriod");
38
$cfg->delete("$title.podcastName");
39
$cfg->delete("$title.deinterlace");
40
$cfg->delete("$title.removeCommercials");
41
$cfg->delete("$title.audioChannels");
42
$cfg->delete("$title.ffmpegArgs");
43
$cfg->delete("$title.threads");
44
$cfg->delete("$title.extension");
45
$cfg->delete("$title.aspect");
46
$cfg->write($file) || die $cfg->error();
48
$content = "Configuration delete sucessfully.";
51
my $sizeX = param("sizeX");
52
my $sizeY = param("sizeY");
53
my $aspect = param("aspect");
54
my $audioBR = param("audioBR");
55
my $videoBR = param("videoBR");
56
my $device = param("device");
57
my $codec = param("codec");
58
my $deletePeriod = param("deletePeriod");
59
my $podcastName = param("podcastName");
60
my $deinterlace = param("deinterlace");
61
my $threads = param("threads");
62
my $removeCommercials = param("removeCommercials");
63
my $audioChannels = param("audioChannels");
64
my $extension = param("extension");
66
my $size = $sizeX . "x$sizeY";
68
my ($audioChannelsText,$deinterlaceText,$codecText,$threadsText) = "";
70
if($audioChannels ne ""){
71
$audioChannelsText = " -ac $audioChannels";
73
if($deinterlace ne ""){
74
$deinterlaceText = " -deinterlace";
77
$codecText = "libxvid";
83
$threadsText = " -threads 2";
86
#my $cfg = new Config::Simple(syntax=>'ini');
87
# or you could also do:
88
# $cfg->autosave('ini')
89
my $args = param("args");
90
if ($device eq "mp3"){
91
$args = "-acodec libmp3lame -ac 2 -ab $audioBR -vn ";
93
elsif ($device eq "ipod" || $device eq "zune" || $device eq "cowon" || $device eq "android" || $device eq "xbox 360" || $device eq "laptop"){
94
if ($codecText eq "mpeg4" or $codecText eq "libxvid"){
95
$args = "-y -acodec libmp3lame -ab $audioBR -vcodec $codecText -b $videoBR -mbd 2 -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -s $size$audioChannelsText$deinterlaceText$threadsText -aspect $aspect";
97
elsif ($codecText eq "h264"){
99
$args = "-y -an -v 1 -vcodec libx264 -b $videoBR -bt 175k -refs 1 -deblockalpha 0 -deblockbeta 0 -partitions +parti4x4+partp8x8 -me_method full -subq 1 -me_range 21 -bf 0 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq \"blurCplx^(1-qComp)\" -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 768k -bufsize 2M -cmp +chroma -flags +loop+slice -s $size$audioChannelsText$deinterlaceText$threadsText -aspect $aspect -f mp4 -pass 1 /dev/null";
102
$args .= "|-y -v 1 -vcodec libx264 -b $videoBR -bt 175k -refs 1 -deblockalpha 0 -deblockbeta 0 -partitions +parti4x4+partp8x8 -me_method full -subq 6 -me_range 21 -bf 0 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq \"blurCplx^(1-qComp)\" -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 768k -bufsize 2M -cmp +chroma -flags +loop+slice -s $size$audioChannelsText$deinterlaceText$threadsText -aspect $aspect -acodec libmp3lame -ab $audioBR -ar 48000 -f mp4 -pass 2";
105
elsif ($device eq "psp"){
106
if ($codecText eq "mpeg4" or $codecText eq "libxvid"){
107
$args = "-y -acodec libmp3lame -ab $audioBR -vcodec $codecText -b $videoBR -ar 24000 -mbd 2 -flags +4mv+aic -trellis 2 -cmp 2 -subcmp 2 -s $size$audioChannelsText$deinterlaceText$threadsText -aspect $aspect -r 30000/1001 -f psp -level 21 -coder 1";
109
elsif ($codecText eq "h264"){
110
$args = "-y -acodec libmp3lame -ab $audioBR -vcodec libx264 -b $videoBR -ar 48000 -coder 1 -s $size$audioChannelsText$deinterlaceText$threadsText -aspect $aspect -f psp -flags +loop -trellis 2 -partitions parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 -level 21 -g 250 -vpre default";
113
elsif ($device eq "archos"){
114
if ($codecText eq "mpeg4" or $codecText eq "libxvid"){
115
# ffmpeg line from courtesy of freymann
116
$args = "-y -acodec libmp3lame -ab $audioBR -vcodec $codecText -b $videoBR -mbd 2 -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -aspect $aspect -s $size$audioChannelsText$deinterlaceText$threadsText";
120
$cfg->param("$title.sizeX", $sizeX);
121
$cfg->param("$title.sizeY", $sizeY);
122
$cfg->param("$title.audioBR", $audioBR);
123
$cfg->param("$title.videoBR", $videoBR);
124
$cfg->param("$title.device", $device);
125
$cfg->param("$title.aspect", $aspect);
126
$cfg->param("$title.codec", $codec);
127
$cfg->param("$title.deletePeriod", $deletePeriod);
128
$cfg->param("$title.podcastName", $podcastName);
129
$cfg->param("$title.deinterlace", $deinterlace);
130
$cfg->param("$title.removeCommercials", $removeCommercials);
131
$cfg->param("$title.audioChannels", $audioChannels);
132
$cfg->param("$title.ffmpegArgs", $args);
133
$cfg->param("$title.threads", $threads);
134
$cfg->param("$title.extension", $extension);
135
$cfg->write($file) || die $cfg->error();
137
$content = "<p>Configuration has been sucessfully saved.</p>";
140
$template->param(CONTENT => $content);
141
$template->param(LOCATION => "setup");
143
print generateContentType(), $template->output;