add audio extraction

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@554 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-12-09 20:33:57 +00:00
parent b6ce0e3b16
commit 25344c5ff4
8 changed files with 159 additions and 13 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.8.4-1
Version: 0.8.5
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4-1),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.1),ssmtp,anacron

View File

@ -184,6 +184,9 @@ puts {
if {[system model] eq "HDR"} {
puts { <li class="separator"><a href=#decrypt>Decrypt</a></li> }
}
if {[system pkginst ffmpeg]} {
puts { <li><a href=#audio>Extract Audio</a></li> }
}
if $nicesplice {
puts { <li class="cut separator"><a href=#crop>Crop</a></li> }
}

View File

@ -0,0 +1,100 @@
#!/mod/bin/jimsh
package require sqlite3
package require cgi
source /mod/var/mongoose/lib/setup
require ts.class
puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
if {[cgi_get do] eq "it"} {
set xstart [clock milliseconds]
set base [file rootname $rfile]
set shname [file tail $base]
puts "Processing $shname"
puts [exec /mod/bin/ffmpeg -y -benchmark -v 0 \
-i $rfile -f mp2 \
-vn -acodec copy "${base}.mp3"]
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
puts "Time taken: $xtime"
exit
}
header
puts "
<link href=/css/jquery.progressbar.css rel=stylesheet type=text/css />
<script type=\"text/javascript\" src=\"/js/jquery.progressbar.js\"></script>
<table class=keyval cellpadding=5>
<tr><th>File:</th><td>$rfile</td></tr>
<tr><th>Length:</th><td>[clock format $len -format "%T"]</td></tr>
</table>
"
puts {
<div style="margin-top: 10px"></div>
<div id=audiodiv><button id=audioit>Perform audio extraction</button></div>
<div id=progressdiv style="display: none">
Extracting audio: <div id=progressbar></div>
}
puts "<button id=back
dir=\"[cgi_quote_url $dir]\"
rfile=\"[cgi_quote_url $rfile]\"
style=\"display: none\">Back to media list</button>"
puts {
<div id=output class=pre style="margin-top: 10px"></div>
</div>
<script type=text/javascript>
var handle = 0;
function update()
{
$.get('/cgi-bin/browse/audio_progress.jim?file='
+ $('#back').attr('rfile'), function(data) {
if (handle)
$('#progressbar').reportprogress(data);
});
}
$(document).ready(function() {
$('#progressbar').reportprogress(0);
$('#back').button().click(function() {
window.location = '/cgi-bin/browse.jim?dir=' + $(this).attr('dir');
});
$('#audioit').button().click(function() {
$('#audiodiv').hide('slow');
$('#progressdiv').show('slow');
handle = setInterval("update()", 1000);
$('#output').load(document.URL + '&do=it', function() {
clearInterval(handle);
handle = 0;
$('#back').show();
$('#progressbar').reportprogress(100);
});
});
});
</script>
</div>
}

View File

@ -0,0 +1,26 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require ts.class
puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set tsfile [cgi_get file]
set rfile [file normalize $tsfile]
set bfile [file rootname $rfile]
if {![file exists "${bfile}.mp3"]} {
puts "0"
} else {
set sz [file size $rfile]
set nsz [expr [file size "${bfile}.mp3"] / 0.3]
set perc [expr $nsz * 100 / $sz]
if {$perc > 100} { set perc 100 }
puts $perc
}

View File

@ -193,9 +193,15 @@ function preparemenu(el, menu)
}
if (el.attr('odencd') == 1)
{
$('#optmenu').enableContextMenuItems('#decrypt');
$('#optmenu').disableContextMenuItems('#audio');
}
else
{
$('#optmenu').disableContextMenuItems('#decrypt');
$('#optmenu').enableContextMenuItems('#audio');
}
}
else
@ -205,6 +211,7 @@ function preparemenu(el, menu)
$('#optmenu').disableContextMenuItems('#enc');
$('#optmenu').disableContextMenuItems('#new');
$('#optmenu').disableContextMenuItems('#decrypt');
$('#optmenu').disableContextMenuItems('#audio');
$('#optmenu').disableContextMenuItems('#crop');
}
@ -275,6 +282,11 @@ var menuclick = function(action, el, pos)
encodeURIComponent(file);
break;
case 'audio':
window.location.href = '/cgi-bin/browse/audio.jim?file=' +
encodeURIComponent(file);
break;
default:
alert('Unhandled action: ' + action);
break;

View File

@ -9,8 +9,7 @@ puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set tsfile [cgi_get file]
set rfile [file normalize $tsfile]
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]

View File

@ -10,14 +10,14 @@ puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set tsfile [cgi_get file]
set rfile [file normalize $tsfile]
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
lassign [$ts dlnaloc] url
if {[cgi_get do] eq "it"} {
set xstart [clock milliseconds]
set base [file rootname $rfile]
set origdir "$dir/_original"
@ -51,6 +51,9 @@ if {[cgi_get do] eq "it"} {
exec /mod/bin/hmt -encrypted "$dir/$shname.hmt"
}
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
puts "Time taken: $xtime"
exit
}

View File

@ -11,20 +11,23 @@ cgi_input
#cgi_dump
set file [cgi_get file]
set rfile [file normalize $file]
set ts [ts fetch $file]
# Default to just downloading the raw file.
set url $file
set mime "video/ts"
# If it's encrypted on disk and the DLNA option is available, then use
# the server to perform decryption on the fly.
if {[$ts flag "ODEncrypted"] > 0} {
set dlna [$ts dlnaloc]
if {[llength $dlna]} { lassign $dlna url mime }
if {[string match {*.ts} $file]} {
if {![catch {set ts [ts fetch $file]}]} {
#puts "DLNA: $dlna"
# If it's encrypted on disk and the DLNA option is available,
# then use the server to perform decryption on the fly.
if {[$ts flag "ODEncrypted"] > 0} {
set dlna [$ts dlnaloc]
if {[llength $dlna]} { lassign $dlna url mime }
#puts "DLNA: $dlna"
}
}
}
puts "Content-Type: text/plain"