add thumbnail generation/display

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1442 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2013-03-07 23:37:56 +00:00
parent 9d3e52edd3
commit ccf3cc1888
11 changed files with 93 additions and 3 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.13.3-1
Version: 0.13.3-2
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)

View File

@ -23,8 +23,12 @@ if {[system pkginst ffmpeg]} {
puts {
<li class=mp3><a href=#audio>Extract Audio</a></li>
<li class=mpg><a href=#mpg>Extract to MPG</a></li>
<li class=thm><a href=#thm>Set Thumbnail</a></li>
}
}
puts { <li><a href=#vthm>View Thumbnail</a></li> }
if $nicesplice {
puts {
<li class="cut"><a href=#crop>Crop</a></li>

View File

@ -0,0 +1,19 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require cat
set file [cgi_get file]
set file "[file rootname $file].thm"
if {![file exists $file]} {
httpheader "text/plain"
puts "No such file, $file"
exit
}
httpheader "image/bmp"
cat "/mod/webif/lib/bmpheader"
cat $file

View File

@ -96,11 +96,13 @@ proc entry {file} {{i 0}} {
set base [file rootname $file]
set thmok 0
if {$ext eq ".ts" && [file exists "${base}.nts"]} {
set type ts
set ts [ts fetch $file 1]
set img Video_TS
set omenu opt
if {[file exists "${base}.thm"]} { set thmok 1 }
} elseif {$ext eq ".hmt"} {
if {[file exists "${base}.ts"]} { continue }
# Sole hmt file indicates failure to track.
@ -221,7 +223,7 @@ proc entry {file} {{i 0}} {
<img class=\"$omenu va\" border=0 width=45 type=$type did=$i
locked=$locked encd=$encd def=$def new=$new bx=$bx
shrunk=$shrunk rsize=$rsz
odencd=$odencd dlna=$dlna
odencd=$odencd dlna=$dlna thmok=$thmok
src=/images/181_1_00_Help5_OPT_Plus.png>
</a>
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>

View File

@ -178,6 +178,20 @@ function new_callback(file, type, id)
$.get(url, function() { window.location.reload(true); });
}
function thumbnail_callback(file, type, id)
{
var el = 'div.bf#' + id;
var results = el + ' .results';
$(results)
.html('<img src=/img/loading.gif>Generating thumbnail, ' +
'please wait...')
.slideDown('slow')
.load('/browse/thumbnail.jim?file=' + file)
.delay(3000)
.slideUp('slow');
$('div.bf#' + id + ' img.opt').attr('thmok', 1);
}
function rename_submit()
{
var s = $('#renameform_form').serialize();
@ -257,6 +271,16 @@ function preparemenu(el, menu)
else
$(menu).disableContextMenuItems('#crop');
if (el.attr('bx') > 0 && el.attr('odencd') == 0)
$(menu).enableContextMenuItems('#thm');
else
$(menu).disableContextMenuItems('#thm');
if (el.attr('thmok') == 1)
$(menu).enableContextMenuItems('#vthm');
else
$(menu).disableContextMenuItems('#vthm');
$(menu).enableContextMenuItems('#strip');
if (el.attr('rsize') > 4294967296)
@ -424,6 +448,17 @@ var menuclick = function(action, el, pos)
$('#renameform').dialog('open');
break;
case 'thm':
confirm_action('re-generate the thumbnail for',
thumbnail_callback, file, dir, id);
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');
break;
case 'download':
window.location.href = '/browse/download.jim?file=' +
file + '&base=' +

View File

@ -0,0 +1,13 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require ts.class
httpheader
set file [cgi_get file]
if {![catch {set ts [ts fetch $file]}]} {
$ts mkthm
}

View File

@ -72,5 +72,6 @@
.contextMenu LI.mpg A { background-image: url(/img/context/mpg.png); }
.contextMenu LI.mp3 A { background-image: url(/img/context/mp3.png); }
.contextMenu LI.clock A { background-image: url(/img/context/clock.png); }
.contextMenu LI.thm A { background-image: url(/img/context/thumb.png); }

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

BIN
var/mongoose/lib/bmpheader Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

View File

@ -2,7 +2,7 @@
if {![exists -proc cat]} {
proc cat {file} {
if {[catch {set fp [open $file r}]} { return }
puts [read $fp]
puts -nonewline [read $fp]
close $fp
}
}

View File

@ -235,6 +235,22 @@ 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."
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]
tdelete $bfile.bmp
puts "Done."
}
proc {ts renamegroup} {from to} {
global tsgroup