forked from hummypkg/webif
Automatic edit point bookmarks following crop
This commit is contained in:
parent
0c7dd2b31f
commit
b42f2ed7b5
@ -4,8 +4,8 @@ package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require ts.class pretty_size
|
||||
|
||||
jqplugin progressbar
|
||||
jscss crop.js
|
||||
jqplugin progressbar iphone-style-checkboxes
|
||||
jscss crop.js style.css
|
||||
header
|
||||
|
||||
set rfile [cgi_get file]
|
||||
@ -23,13 +23,13 @@ puts "
|
||||
<tr><th>File:</th><td>$rfile</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] @ "
|
||||
<tr><th>Bookmarks:</th><td id=originalbookmarks>[$ts get bookmarks] @ "
|
||||
|
||||
puts [join [lmap i [$ts bookmarks 1] {
|
||||
clock format $i -format "%T"
|
||||
}] ", "]
|
||||
|
||||
puts "</td></tr><tr><th>File</th><td>"
|
||||
puts "</td></tr><tr><th> </th><td id=cutplan>"
|
||||
|
||||
puts "<div style=\"position: relative; top: -10px\">"
|
||||
|
||||
@ -48,14 +48,21 @@ append bookmarks [$ts bookmarks]
|
||||
set keeping 0
|
||||
set last 0
|
||||
set start -1
|
||||
set newbookmarks "0 "
|
||||
set cur 0
|
||||
foreach b $bookmarks {
|
||||
if {$start < 0} {
|
||||
# Start of a section to keep
|
||||
set start $b
|
||||
continue
|
||||
}
|
||||
# End of a section to keep
|
||||
set end $b
|
||||
|
||||
incr keeping $($end - $start)
|
||||
set l $($end - $start)
|
||||
incr keeping $l
|
||||
incr cur $l
|
||||
append newbookmarks "[expr $cur + 3] "
|
||||
|
||||
set left $($start * 500 / $len)
|
||||
set right $($end * 500 / $len)
|
||||
@ -69,6 +76,7 @@ foreach b $bookmarks {
|
||||
}
|
||||
|
||||
if {$start > 0} {
|
||||
# Still in a keep section...
|
||||
incr keeping $($len - $start)
|
||||
set left $($start * 500 / $len)
|
||||
div cut $last $($left - 1)
|
||||
@ -77,6 +85,10 @@ if {$start > 0} {
|
||||
div cut $last 500
|
||||
}
|
||||
|
||||
if {$cur > $keeping - 8 && $keeping - 8 > 0} {
|
||||
set newbookmarks [lreplace $newbookmarks end end $($keeping - 8)]
|
||||
}
|
||||
|
||||
set keepperc $($keeping * 100.0 / $len)
|
||||
set esttime $(int($keeping * 0.025))
|
||||
if {[$ts get definition] eq "HD"} { set esttime $($esttime * 4) }
|
||||
@ -86,7 +98,23 @@ puts "
|
||||
</td></tr>
|
||||
<tr><th>Keeping:</th><td>
|
||||
[clock format $keeping -format "%T"] ([format "%.2f" $keepperc]%)
|
||||
</td></tr>
|
||||
</td></tr>"
|
||||
|
||||
puts "
|
||||
<tr>
|
||||
<th title=\"Calculated bookmarks for edit points following crop.\">
|
||||
New Bookmarks:
|
||||
</th><td id=newbookmarks>
|
||||
<span id=bookmarks val=\"$newbookmarks\">
|
||||
$newbookmarks</span> (
|
||||
"
|
||||
puts [join [lmap i $newbookmarks {
|
||||
clock format $i -format "%T"
|
||||
}] ", "]
|
||||
|
||||
puts " )</td></tr>"
|
||||
|
||||
puts "
|
||||
<tr><th>Time:</th>
|
||||
<td>Cropping will take around [clock format $esttime -format "%T"]</td></tr>
|
||||
</table>
|
||||
@ -98,10 +126,19 @@ puts "
|
||||
></span>
|
||||
|
||||
<div id=cropdiv style=\"padding: 1em\">
|
||||
<button id=invert invert=$invert>Invert selection</button>
|
||||
<button id=cropit>Perform crop operation</button>
|
||||
<table><tr>
|
||||
<td><button id=invert invert=$invert>Invert selection</button></td>
|
||||
<td><button id=cropit>Perform crop operation</button></td>
|
||||
<td>
|
||||
Save new bookmarks?
|
||||
<input id=saveit type=checkbox name=saveit checked>
|
||||
<label id=saveitlabel for=saveit> </label>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<button id=back>Back to media list</button>
|
||||
<button id=save class=\"hidden\">Save New Bookmarks</button>
|
||||
<div id=results class=\"hidden blood\"></div>
|
||||
|
||||
<div id=progressdiv class=hidden>
|
||||
Cropping: <div id=progressbar></div>
|
||||
@ -109,6 +146,5 @@ Cropping: <div id=progressbar></div>
|
||||
|
||||
<div id=output class=\"hidden pre\" style=\"margin-top: 10px\"></div>
|
||||
</fieldset>
|
||||
|
||||
"
|
||||
|
||||
|
@ -1,18 +1,29 @@
|
||||
var handle = 0;
|
||||
|
||||
function escapestring(str)
|
||||
{
|
||||
str = JSON.stringify(String(str));
|
||||
str = str.substring(1, str.length - 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
var perc = $('#params').attr('perc');
|
||||
var file = $('#params').attr('file');
|
||||
|
||||
$.get('progress.jim' + '?perc=' + perc + '&file=' + file,
|
||||
function(data) {
|
||||
$.get('progress.jim', {
|
||||
'perc': $('#params').attr('perc'),
|
||||
'file': $('#params').attr('file')
|
||||
}, function(data) {
|
||||
if (handle)
|
||||
$('#progressbar').reportprogress(data);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(function() {
|
||||
|
||||
$('[type="checkbox"]').iphoneStyle({
|
||||
checkedLabel: 'YES',
|
||||
uncheckedLabel: 'NO'
|
||||
});
|
||||
|
||||
$('#progressbar').reportprogress(0);
|
||||
|
||||
@ -20,24 +31,51 @@ $('#back').button().click(function() {
|
||||
window.location = '/go/browse?dir=' + $('#params').attr('dir');
|
||||
});
|
||||
|
||||
$('#save').button({icons: {primary: "ui-icon-disk"}})
|
||||
.on('click', function() {
|
||||
$('#progressdiv,#output,#save').hide('slow');
|
||||
$.post('../bookmarks/save.jim', {
|
||||
'file': $('#fileparams').attr('file'),
|
||||
'bookmarks': $('#bookmarks').attr('val')
|
||||
}, function(data) {
|
||||
$('#results').html(data)
|
||||
.slideDown('slow')
|
||||
.delay(6000)
|
||||
.slideUp('slow');
|
||||
$('#originalbookmarks')
|
||||
.html($('#newbookmarks').clone());
|
||||
});
|
||||
});
|
||||
|
||||
$('#cropit').button().click(function() {
|
||||
$('#cropdiv').hide('slow');
|
||||
$('#progressdiv').show('slow');
|
||||
$('#back').hide();
|
||||
handle = setInterval("update()", 1000);
|
||||
$('#output').show().text('Please do not interrupt...')
|
||||
.load('execute.jim?file=' + $('#params').attr('file') +
|
||||
'&invert=' + $('#invert').attr('invert'),
|
||||
function() {
|
||||
.load('execute.jim', {
|
||||
'file': $('#params').attr('file'),
|
||||
'invert': $('#invert').attr('invert')
|
||||
}, function() {
|
||||
clearInterval(handle);
|
||||
handle = 0;
|
||||
$('#back').show();
|
||||
$('#back,#save').show();
|
||||
$('#cutplan').html('File cropping complete');
|
||||
$('#originalbookmarks').empty();
|
||||
$('#progressbar').reportprogress(100);
|
||||
if ($('#saveit').prop('checked'))
|
||||
{
|
||||
$('#save').trigger('click');
|
||||
$('#progressdiv')
|
||||
.delay(3000)
|
||||
.text('Cropping complete.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#invert').button().on('click', function() {
|
||||
window.location = 'crop.jim?file=' + $('#params').attr('file') +
|
||||
window.location = 'crop.jim?file=' +
|
||||
escapestring($('#params').attr('file')) +
|
||||
'&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
|
||||
});
|
||||
|
||||
|
@ -68,6 +68,7 @@ system endop $token
|
||||
|
||||
set newname "$shname-[clock seconds]"
|
||||
puts "Renaming file group to $newname"
|
||||
puts "<span class=hidden id=fileparams file=\"$dir/$newname.ts\"></span>"
|
||||
ts renamegroup "$dir/$shname.ts" $newname
|
||||
exec /mod/bin/hmt "+setfilename=$newname" "$dir/$newname.hmt"
|
||||
# New nicesplice shrinks whilst cropping.
|
||||
|
13
webif/html/browse/crop/style.css
Normal file
13
webif/html/browse/crop/style.css
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
div.switchlabel
|
||||
{
|
||||
height: 27px;
|
||||
line-height: 27px;
|
||||
}
|
||||
|
||||
div.sliderlabel
|
||||
{
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user