forked from hummypkg/webif
add thumbnail generation
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1445 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
ccf3cc1888
commit
b2c7be03a4
@ -1,9 +1,9 @@
|
||||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 0.13.3-2
|
||||
Version: 0.13.3-3
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hummypkg.org.uk
|
||||
Depends: webif-channelicons(>=1.0.4-1),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73-1),jim-cgi(>=0.7),jim-binary,service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.10),hmt(>=1.1.13),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2),smartmontools,tmenu(>=1.05)
|
||||
Suggests: ffmpeg
|
||||
Depends: webif-channelicons(>=1.0.4-1),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73-1),jim-cgi(>=0.7),jim-binary,service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.10),hmt(>=1.1.13),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2),smartmontools,tmenu(>=1.05),ffmpeg,id3v2
|
||||
Suggests:
|
||||
Description: An evolving web interface for the Humax.
|
||||
|
@ -291,5 +291,9 @@ Please wait...
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<div id=bmpdialogue title="Recording Thumbnail" class=hidden>
|
||||
<img id=thmbmp class=doublebmp src="about:blank">
|
||||
</div>
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,12 @@ if {$type eq "ts"} {
|
||||
<table class=keyval>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<td>[$ts get title]</td>
|
||||
<td class=va>
|
||||
"
|
||||
if {[file exists "[file rootname $file].thm"]} {
|
||||
puts "<img class=\"bmp va\" width=70 height=39 src=\"bmp.jim?file=$file\">"
|
||||
}
|
||||
puts "[$ts get title]</td>
|
||||
</tr><tr>
|
||||
<th>Synopsis</th>
|
||||
<td>[$ts get synopsis]</td>
|
||||
|
@ -271,7 +271,7 @@ function preparemenu(el, menu)
|
||||
else
|
||||
$(menu).disableContextMenuItems('#crop');
|
||||
|
||||
if (el.attr('bx') > 0 && el.attr('odencd') == 0)
|
||||
if (el.attr('odencd') == 0)
|
||||
$(menu).enableContextMenuItems('#thm');
|
||||
else
|
||||
$(menu).disableContextMenuItems('#thm');
|
||||
@ -449,14 +449,16 @@ var menuclick = function(action, el, pos)
|
||||
break;
|
||||
|
||||
case 'thm':
|
||||
confirm_action('re-generate the thumbnail for',
|
||||
thumbnail_callback, file, dir, id);
|
||||
window.location.href = '/browse/thumbnail/index.jim?file=' +
|
||||
file;
|
||||
break;
|
||||
|
||||
case 'vthm':
|
||||
window.open('/browse/bmp.jim?file=' + file, 'hxwebifbmp',
|
||||
'height=78,width=140,toolbar=no,' +
|
||||
'scrollbars=no,menubar=no,location=no,titlebar=no');
|
||||
// window.open('/browse/bmpw.jim?file=' + file, 'hxwebifbmp',
|
||||
// 'height=156,width=280,toolbar=no,' +
|
||||
// 'scrollbars=no,menubar=no,location=no,titlebar=no');
|
||||
$('#thmbmp').attr('src', 'bmp.jim?file=' + file);
|
||||
$('#bmpdialogue').dialog('open');
|
||||
break;
|
||||
|
||||
case 'download':
|
||||
@ -783,6 +785,18 @@ var dmenuclick = function(action, el, pos)
|
||||
close: function() { $('#savestream_name').val(''); }
|
||||
});
|
||||
|
||||
$('#bmpdialogue').dialog({
|
||||
autoOpen: false,
|
||||
height: 'auto', width: 'auto',
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Close": function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
close: function() { $('#thmbmp').attr('src', 'about:blank'); }
|
||||
});
|
||||
|
||||
// Create re-usable confirmation dialogue.
|
||||
$confirm = $('#confirm').dialog({
|
||||
modal: true, autoOpen: false,
|
||||
|
19
var/mongoose/html/browse/thumbnail/_mk.jim
Executable file
19
var/mongoose/html/browse/thumbnail/_mk.jim
Executable file
@ -0,0 +1,19 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require ts.class cat
|
||||
|
||||
httpheader "image/bmp"
|
||||
|
||||
set rfile [cgi_get file]
|
||||
set pos [cgi_get pos 0]
|
||||
|
||||
if {![catch {set ts [ts fetch $rfile]}]} {
|
||||
$ts mkbmp $pos ".pos$pos"
|
||||
|
||||
set f "[file rootname $rfile].pos$pos.bmp"
|
||||
cat $f
|
||||
file delete $f
|
||||
}
|
||||
|
17
var/mongoose/html/browse/thumbnail/fetch.jim
Executable file
17
var/mongoose/html/browse/thumbnail/fetch.jim
Executable file
@ -0,0 +1,17 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require cat
|
||||
|
||||
httpheader "image/bmp"
|
||||
|
||||
set rfile [cgi_get file]
|
||||
set pos [cgi_get pos 0]
|
||||
|
||||
set f "[file rootname $rfile].pos$pos.bmp"
|
||||
if {[file exists $f]} {
|
||||
cat $f
|
||||
file delete $f
|
||||
}
|
||||
|
98
var/mongoose/html/browse/thumbnail/index.jim
Executable file
98
var/mongoose/html/browse/thumbnail/index.jim
Executable file
@ -0,0 +1,98 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require ts.class pretty_size
|
||||
|
||||
header
|
||||
|
||||
set rfile [cgi_get file]
|
||||
set ts [ts fetch $rfile]
|
||||
set dir [file dirname $rfile]
|
||||
|
||||
set len [$ts duration 1]
|
||||
|
||||
lassign [$ts bookmarks] book
|
||||
if {$book eq ""} { set book 0 }
|
||||
|
||||
set pos [cgi_get pos $book]
|
||||
set pos $($pos + 0)
|
||||
if {$pos < 0} { set pos 0 }
|
||||
|
||||
puts "
|
||||
<script type=text/javascript src=script.js></script>
|
||||
<script type=text/javascript src=/js/enadis.js></script>
|
||||
|
||||
<fieldset class=cleft>
|
||||
<legend>Replace Thumbnail</legend>
|
||||
|
||||
<table class=keyval cellpadding=5>
|
||||
<tr><th>File:</th><td>
|
||||
<span class=hidden id=dir>[file dirname $rfile]</span>
|
||||
<span id=file>$rfile</span>
|
||||
</td></tr>
|
||||
<tr><th>Length:</th><td>[clock format $len -format %T]</td></tr>
|
||||
<tr><th>Size:</th><td>[pretty_size [$ts size]] ([$ts get definition])</td></tr>
|
||||
<tr><th>Bookmarks:</th><td>[$ts get bookmarks] ($book second(s))</td></tr>
|
||||
<tr><th>Thumbnail:</th><td>
|
||||
<img class=doublebmp src=\"../bmp.jim?file=[cgi_quote_url $rfile]\">
|
||||
</td></tr>
|
||||
</table>
|
||||
"
|
||||
|
||||
if {[$ts get definition] eq "HD"} {
|
||||
set start $($pos - 0.5)
|
||||
set incr 1.0
|
||||
} else {
|
||||
set start $($pos - 1)
|
||||
set incr 2.0
|
||||
}
|
||||
if {$start < 0} { set start 0 }
|
||||
set limit $($start + $incr)
|
||||
|
||||
puts "<div style=\"width=100%; text-align: center\">
|
||||
<button id=back>Back to media browser</button>
|
||||
<br /> <br />
|
||||
<form method=get action=index.jim>
|
||||
<input type=hidden name=file value=\"$rfile\">
|
||||
Thumbnails from around
|
||||
<input name=pos id=pos size=5 maxlength=4 value=\"$pos\">
|
||||
second(s) into recording.
|
||||
</form>
|
||||
<button class=mvpos pos=[expr $pos - 30]><< 30 seconds</button>
|
||||
<button class=mvpos pos=[expr $pos - 5]>< 5 seconds</button>
|
||||
<button id=repos>Update</button>
|
||||
<button class=mvpos pos=[expr $pos + 5]>> 5 seconds</button>
|
||||
<button class=mvpos pos=[expr $pos + 30]>>> 30 seconds</button>
|
||||
</div>
|
||||
<span id=start class=hidden>$start</span>
|
||||
<span id=end class=hidden>$limit</span>
|
||||
<table class=keyval cellpadding=5>
|
||||
<tr>
|
||||
"
|
||||
|
||||
for {set i [expr $start + 0.0]} {$i <= $limit} {set i [expr $i + 0.5]} {
|
||||
lappend times $i
|
||||
puts "<th style=\"text-align: center\">
|
||||
@ <span class=mark>$i</span>s</th>"
|
||||
}
|
||||
puts "</tr><tr>"
|
||||
|
||||
foreach i $times {
|
||||
puts "<td>
|
||||
<img class=bmp src=/img/generating.png pos=$i>
|
||||
</td>"
|
||||
}
|
||||
|
||||
puts "</tr><tr>"
|
||||
|
||||
foreach i $times {
|
||||
puts "<td style=\"text-align: center\">
|
||||
<button class=usethm pos=\"$i\">Use</button>
|
||||
</td>"
|
||||
}
|
||||
|
||||
puts "</tr>"
|
||||
|
||||
puts "</table>"
|
||||
|
21
var/mongoose/html/browse/thumbnail/mkrange.jim
Executable file
21
var/mongoose/html/browse/thumbnail/mkrange.jim
Executable file
@ -0,0 +1,21 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require ts.class
|
||||
|
||||
httpheader
|
||||
|
||||
set rfile [cgi_get file]
|
||||
set s [cgi_get s 0]
|
||||
set e [cgi_get e $($s + 2)]
|
||||
set i [expr [cgi_get i 0.5] + 0.0]
|
||||
|
||||
if {![catch {set ts [ts fetch $rfile]}]} {
|
||||
$ts cleanbmp
|
||||
for {set n [expr $s + 0.0]} {$n <= $e} {set n [expr $n + $i]} {
|
||||
puts "Generating thumbnail for pos $n"
|
||||
$ts mkbmp $n ".pos$n"
|
||||
}
|
||||
}
|
||||
|
58
var/mongoose/html/browse/thumbnail/script.js
Executable file
58
var/mongoose/html/browse/thumbnail/script.js
Executable file
@ -0,0 +1,58 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var dir = $('#dir').text();
|
||||
var file = $('#file').text();
|
||||
|
||||
$('button').button();
|
||||
|
||||
function go(pos)
|
||||
{
|
||||
window.location.href = 'index.jim?file=' +
|
||||
encodeURIComponent(file) + '&pos=' + pos;
|
||||
}
|
||||
|
||||
$('button.mvpos').disable().on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var pos = $(this).attr('pos');
|
||||
go(pos);
|
||||
});
|
||||
|
||||
$('#repos').disable().on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var pos = $('#pos').val();
|
||||
go(pos);
|
||||
});
|
||||
|
||||
$('#back').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
window.location.href = '/browse/index.jim?dir=' +
|
||||
encodeURIComponent(dir);
|
||||
});
|
||||
|
||||
$('button.usethm').disable().on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var pos = $(this).attr('pos');
|
||||
$('button,input').disable();
|
||||
$.get('set.jim?file=' + encodeURIComponent(file) + '&pos=' + pos,
|
||||
function() {
|
||||
window.location.href = '/browse/index.jim?dir=' +
|
||||
encodeURIComponent(dir);
|
||||
});;
|
||||
});
|
||||
|
||||
var start = $('#start').text();
|
||||
var end = $('#end').text();
|
||||
$.get('mkrange.jim?file=' + encodeURIComponent(file) +
|
||||
'&s=' + start + '&e=' + end, function() {
|
||||
$('img.bmp').each(function(i) {
|
||||
var pos = $(this).attr('pos');
|
||||
$(this).attr('src',
|
||||
'fetch.jim?file=' + encodeURIComponent(file) +
|
||||
'&pos=' + pos);
|
||||
});
|
||||
$('button').enable();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -7,7 +7,9 @@ require ts.class
|
||||
httpheader
|
||||
|
||||
set file [cgi_get file]
|
||||
set pos [cgi_get pos 0]
|
||||
|
||||
if {![catch {set ts [ts fetch $file]}]} {
|
||||
$ts mkthm
|
||||
$ts mkthm $pos
|
||||
}
|
||||
|
@ -410,3 +410,18 @@ div#restart_block
|
||||
z-index: 31;
|
||||
}
|
||||
|
||||
img.bmp, img.doublebmp
|
||||
{
|
||||
transform: scaleY(-1);
|
||||
-webkit-transform: scaleY(-1);
|
||||
-o-transform: scaleY(-1);
|
||||
height: 78px;
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
img.doublebmp
|
||||
{
|
||||
height: 156px;
|
||||
width: 280px;
|
||||
}
|
||||
|
||||
|
BIN
var/mongoose/html/img/generating.png
Normal file
BIN
var/mongoose/html/img/generating.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -235,20 +235,51 @@ ts method dlnaloc {{urlbase 0}} {
|
||||
if {$url ne "" } { return [list $url $mime] } else { return {} }
|
||||
}
|
||||
|
||||
ts method mkthm {} {
|
||||
if {!$bookmarks} {
|
||||
puts "No bookmarks found."
|
||||
return
|
||||
}
|
||||
lassign [$self bookmarks] s
|
||||
puts "Grabbing thumbnail from $s second(s) in."
|
||||
ts method cleanbmp {} {
|
||||
set bfile [file rootname $file]
|
||||
puts [exec /mod/bin/ffmpeg -loglevel fatal -ss $s -i $file \
|
||||
-frames 1 -pix_fmt argb -vf vflip -s 140x78 \
|
||||
$bfile.bmp]
|
||||
puts [exec /bin/dd if=$bfile.bmp of=$bfile.thm bs=54 skip=1]
|
||||
foreach f [glob -nocomplain "${bfile}*.bmp"] {
|
||||
file delete $f
|
||||
}
|
||||
}
|
||||
|
||||
ts method mkbmps {{offset 0}} {
|
||||
set bfile [file rootname $file]
|
||||
if {[catch {
|
||||
exec /mod/bin/ffmpeg -loglevel fatal -ss $offset -i $file \
|
||||
-vf fps=fps=2 -frames 5 \
|
||||
-pix_fmt argb -vf vflip -s 140x78 "${bfile}%d.bmp"
|
||||
} msg]} {
|
||||
puts "ERROR: $msg"
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
ts method mkbmp {{offset 0} {ext ""}} {
|
||||
set bfile [file rootname $file]
|
||||
if {[catch {
|
||||
exec /mod/bin/ffmpeg -loglevel fatal -ss $offset -i $file \
|
||||
-frames 1 -pix_fmt argb -vf vflip -s 140x78 "$bfile$ext.bmp"
|
||||
} msg]} {
|
||||
puts "ERROR: $msg"
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
ts method mkthm {{offset 0}} {
|
||||
if {![$self mkbmp $offset]} { return 0 }
|
||||
set bfile [file rootname $file]
|
||||
if {[catch {
|
||||
exec /bin/dd if=$bfile.bmp of=$bfile.thm~ bs=54 skip=1
|
||||
} msg]} {
|
||||
puts "ERROR: $msg"
|
||||
return 0
|
||||
}
|
||||
exec /bin/echo -n " " >> $bfile.thm~
|
||||
file rename -force $bfile.thm~ $bfile.thm
|
||||
tdelete $bfile.bmp
|
||||
puts "Done."
|
||||
return 1
|
||||
}
|
||||
|
||||
proc {ts renamegroup} {from to} {
|
||||
|
Loading…
Reference in New Issue
Block a user