Automatic edit point bookmarks following crop

Does the New Bookmarks entry show?
No

Which browser, have you cleared the cache.
Win7/Chrome / No, but it's worked before

Does the progress bar disappear on completion?
No - what does that tell us?

If your browser has an inspect option click on inspect over the back button, is <button id="back" class="ui-button ui-corner-all ui-widget" style="display: inline-block;">Back to media list</button> followed by: <button id="save" class="hidden ui-button ui-corner-all ui-widget" style="display: inline-block;"><span class="ui-button-icon ui-icon ui-icon-disk"></span><span class="ui-button-icon-space"> </span>Save New Bookmarks</button>
Code:
<button id="back" class="ui-button ui-corner-all ui-widget" style="display: inline-block;">Back to media list</button>
No button id="save" at all.
 
Now I'm baffled. On inspection, it looks for all the world like the crop.jim file does not contain the mods... and yet I tested it when first installed. Later...
 
are your recordings actually being cropped
Yes.

I am very pressed for fiddling time these days ( :( / :) ), but I must go around this loop again to figure out what is going on. However, I kept a log of my Telnet session when I originally performed the patches, which I will post below for anyone with the time to examine and comment. Like I said, at the time it worked.

What might be useful (when I get around to looking at it) is the checksums of the original files and the patched files. Is there any easy way to get a checksum or hash on the HDR command line? What are the checksums/hashes for your versions of the files? I think in future it would be good for patch threads to include a downloadable mods file, and publish checksums to verify the patches have been incorporated correctly.

Introduction: Prior to the following log, I copied crop/ to crop.bak, and copied save.jim from (wherever) into crop using FTP. I also created file mods containing all the diff stuff appended together (listed below). Note that I found the patch command failed with the -b switch, so ran it without. I don't understand why ls lists the mods file with an initial capital. Is it the case that "*" denotes files with executable permission?

Code:
HDRFOX1# cd mod/webif/html/browse/crop
HDRFOX1# ls
Mods          crop.jim*     crop.js*      execute.jim*  progress.jim* save.jim
HDRFOX1# ls -l
-rwxrw-rw-    1 root     root        2.3K Sep 28 14:09 crop.jim*
-rwxrw-rw-    1 root     root        1.1K Sep 28 14:09 crop.js*
-rwxrw-rw-    1 root     root        1.8K Sep 28 14:09 execute.jim*
-rw-r--r--    1 root     root        6.0K Oct  5 14:55 mods
-rwxrw-rw-    1 root     root         492 Sep 28 14:09 progress.jim*
-rw-r--r--    1 root     root         366 Jun 16  2014 save.jim
HDRFOX1# chmod 766 save.jim
HDRFOX1# ls -l
-rwxrw-rw-    1 root     root        2.3K Sep 28 14:09 crop.jim*
-rwxrw-rw-    1 root     root        1.1K Sep 28 14:09 crop.js*
-rwxrw-rw-    1 root     root        1.8K Sep 28 14:09 execute.jim*
-rw-r--r--    1 root     root        6.0K Oct  5 14:55 mods
-rwxrw-rw-    1 root     root         492 Sep 28 14:09 progress.jim*
-rwxrw-rw-    1 root     root         366 Jun 16  2014 save.jim*
HDRFOX1# patch < mods
patching file crop.jim
patching file crop.js
patching file execute.jim
HDRFOX1#


Listing of file mods
Code:
--- /mod/webif/html/browse/crop/crop_orig.jim
+++ /mod/webif/html/browse/crop/crop.jim
@@ -23,13 +23,13 @@
<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>File</th><td id=cutplan>"

puts "<div style=\"position: relative; top: -10px\">"

@@ -86,7 +86,42 @@
</td></tr>
<tr><th>Keeping:</th><td>
[clock format $keeping -format "%T"] ([format "%.2f" $keepperc]%)
-</td></tr>
+</td></tr>"
+
+set end -1
+set removing 0
+set i 0
+set newbookmark ""
+foreach b $bookmarks {
+    if {$i == 0} {
+        set removing $b
+        append newbookmark "0 "
+        incr i 1
+        continue
+    }
+    if {$end == -1} {
+        set start $($b - $removing)
+        append newbookmark "$($start +3) "
+        set end 0
+    } else {
+        set end $($b - $removing)
+        incr removing $($end - $start)
+        set end -1
+    }
+}
+ set i $([llength $newbookmark] - 1)
+ if {[lindex $newbookmark end] > [expr $keeping - 8] && [expr $keeping - 8] > 0} {
+    set newbookmark [lreplace $newbookmark $i $i]
+    append newbookmark " $($keeping - 8)"
+ }
+
+puts "<tr><th title=\"Calculated bookmarks for edit points following crop.\">New Bookmarks:</th><td id=newbookmarks>"
+puts "<span id=\"bookmarks\" val=\"$newbookmark\">$newbookmark</span>&nbsp;&nbsp;&nbsp;&nbsp;( "
+puts [join [lmap i $newbookmark {
+    clock format $i -format "%T"
+}] ", "]
+
+puts " )</td></tr>
<tr><th>Time:</th>
<td>Cropping will take around [clock format $esttime -format "%T"]</td></tr>
</table>
@@ -100,9 +135,11 @@
<div id=cropdiv style=\"padding: 1em\">
<button id=invert invert=$invert>Invert selection</button>
<button id=cropit>Perform crop operation</button>
+<input id=saveIt type=checkbox name=saveIt checked /> Then Save New Bookmarks?
+<label id=saveItLabel for=saveIt>&nbsp;</label>

</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>
</div>

--- /mod/webif/html/browse/crop/crop_orig.js
+++ /mod/webif/html/browse/crop/crop.js
@@ -3,8 +3,8 @@
function update()
{
     var perc = $('#params').attr('perc');
-    var file = $('#params').attr('file');
-
+    var file = escapestring($('#params').attr('file'));
+
     $.get('progress.jim' + '?perc=' + perc + '&file=' + file,
         function(data) {
         if (handle)
@@ -12,15 +12,28 @@
     });
}

+function escapestring (str) {
+  str = JSON.stringify(String(str));
+  str = str.substring(1, str.length-1);
+  return str;
+}
+
$(document).ready(function() {
+
+  $('#saveIt').hide();
+  $('#progressbar').reportprogress(0);
+  $('#saveItLabel').css({'height':'22px','width':'70px','background-image':'url("/img/on.png")',
+    'display':'inline-block','background-size':'cover'});
+  $("#saveIt").change(function(){
+    if($(this).is(":checked")) $(this).next("label").css('background-image','url("/img/on.png")');
+    else $(this).next("label").css('background-image','url("/img/off.png")');
+  });

-$('#progressbar').reportprogress(0);
+  $('#back').button().click(function() {
+    window.location = '/go/browse?dir=' + $('#params').attr('dir');
+  });

-$('#back').button().click(function() {
-    window.location = '/go/browse?dir=' + $('#params').attr('dir');
-});
-
-$('#cropit').button().click(function() {
+  $('#cropit').button().click(function() {
     $('#cropdiv').hide('slow');
     $('#progressdiv').show('slow');
     $('#back').hide();
@@ -31,15 +44,43 @@
         function() {
         clearInterval(handle);
         handle = 0;
-        $('#back').show();
+        $('#back').show('slow');
+        $('#save').show('slow');
+        $('#cutplan').html('File cropping complete');
+        $('#originalbookmarks').html('Empty');
         $('#progressbar').reportprogress(100);
+        if($('#saveIt').prop('checked')){
+            $.post('save.jim', {
+              file: $('#fileparams').attr('file'),
+              bookmarks: $('#bookmarks').attr('val')
+              }, function(data) {
+                $('#results').html(data)
+                .slideDown('slow').delay(6000).slideUp('slow')
+                .css('color','green');
+                $('#originalbookmarks').html($('#newbookmarks').clone());
+                $('#progressdiv').delay(3000).text('Cropping complete.');
+             });
+        }
     });
+  });
+
+  $('#invert').button().on('click', function() {
+    window.location = 'crop.jim?file=' + $('#params').attr('file') +
+       '&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
+  });
+
+  $('#save').button({icons: {primary: "ui-icon-disk"}})
+    .on('click', function() {
+    $('#progressdiv').hide();
+    $('#output').hide();
+    $.post('save.jim', {
+        file: $('#fileparams').attr('file'),
+        bookmarks: $('#bookmarks').attr('val')
+    }, function(data) {
+        $('#results').html(data)
+            .slideDown('slow').delay(6000).slideUp('slow')
+            .css('color','green');
+        $('#originalbookmarks').html($('#newbookmarks').clone());
+    });
+  });
});

-$('#invert').button().on('click', function() {
-    window.location = 'crop.jim?file=' + $('#params').attr('file') +
-       '&invert=' + ($(this).attr('invert') == '1' ? '0' : '1');
-});
-
-});
-

--- /mod/webif/html/browse/crop/execute_orig.jim
+++ /mod/webif/html/browse/crop/execute.jim
@@ -68,6 +68,10 @@

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.
 
Last edited:
Have you checked whether the current version of crop.jim and crop.js and execute.jim still contain the expected updates yet?

The x in the permissions string -rwxrw-rw- indicates execute permission, check it is still present
 
Okay, so I had to find out about the cksum command myself (tsk). What about my other questions?

Code:
HDRFOX1# cd mod/webif/html/browse/crop                                                                                
HDRFOX1# ls -l                                                                                                        
-rwxrw-rw-    1 root     root        2.3K Oct 27 15:37 crop.jim*                                                      
-rwxrw-rw-    1 root     root        1.1K Oct 27 15:37 crop.js*                                                      
-rwxrw-rw-    1 root     root        1.8K Oct 27 15:37 execute.jim*                                                  
-rw-r--r--    1 root     root        6.0K Oct  5 14:55 mods                                                          
-rwxrw-rw-    1 root     root         492 Sep 28 14:09 progress.jim*                                                  
-rwxrw-rw-    1 root     root         366 Jun 16  2014 save.jim*                                                      
-rw-r--r--    1 root     root        3.0K Oct  5 15:08 telnet.txt                                                    
HDRFOX1# cksum *                                                                                                      
3347949094 2366 crop.jim                                                                                              
107235942 1083 crop.js                                                                                                
2386013374 1803 execute.jim                                                                                          
880548162 6135 mods                                                                                                  
1159930503 492 progress.jim                                                                                          
2825685166 366 save.jim                                                                                              
991945617 3107 telnet.txt                                                                                            
HDRFOX1# cd ../crop.bak                                                                                              
HDRFOX1# cksum *                                                                                                      
3347949094 2366 crop.jim                                                                                              
107235942 1083 crop.js                                                                                                
2386013374 1803 execute.jim                                                                                          
1159930503 492 progress.jim                                                                                          
HDRFOX1# cd ../crop                                                                                                  
HDRFOX1# patch < mods                                                                                                
patching file crop.jim                                                                                                
patching file crop.js                                                                                                
patching file execute.jim                                                                                            
HDRFOX1# ls -l                                                                                                        
-rwxrw-rw-    1 root     root        2.3K Oct 28 22:29 crop.jim*                                                      
-rwxrw-rw-    1 root     root        1.1K Oct 28 22:29 crop.js*                                                      
-rwxrw-rw-    1 root     root        1.8K Oct 28 22:29 execute.jim*                                                  
-rw-r--r--    1 root     root        6.0K Oct  5 14:55 mods                                                          
-rwxrw-rw-    1 root     root         492 Sep 28 14:09 progress.jim*                                                  
-rwxrw-rw-    1 root     root         366 Jun 16  2014 save.jim*                                                      
-rw-r--r--    1 root     root        3.0K Oct  5 15:08 telnet.txt                                                    
HDRFOX1# cksum *                                                                                                      
3347949094 2366 crop.jim                                                                                              
107235942 1083 crop.js                                                                                                
2386013374 1803 execute.jim                                                                                          
880548162 6135 mods                                                                                                  
1159930503 492 progress.jim                                                                                          
2825685166 366 save.jim                                                                                              
991945617 3107 telnet.txt                                                                                            
HDRFOX1#

So the patch command did nothing (this time, and I'm beginning to doubt my sanity re previously).

It would be so much easier if this mod was incorporated into the base set - I can't see any reason not to.
 
Your files are clearly unmodified from the originals, which is why your not seeing the changes!

Code:
humax# cd mod/webif/html/browse/crop                                                                                                                 
humax# ls -l                                                                                                                                         
-rwxr-xr-x    1 root     root          3519 May 22 16:27 crop.jim
-rwx------    1 root     root          2643 Jun  2 12:36 crop.js
-rwxr-xr-x    1 root     root          2366 Feb  5  2016 crop_orig.jim
-rwx------    1 root     root          1083 Feb  5  2016 crop_orig.js
-rwx------    1 root     root          2034 May 22 16:27 execute.jim
-rwxr-xr-x    1 root     root           492 Dec 28  2013 progress.jim
-rwxrwxrwx    1 root     root           418 Dec 30  2018 save.jim
humax# cksum *                                                                                                                                       
3542961729 3519 crop.jim                                                                                                                             
3176875196 2643 crop.js                                                                                                                             
3347949094 2366 crop_orig.jim                                                                                                                       
107235942 1083 crop_orig.js                                                                                                                         
2719064947 2034 execute.jim                                                                                                                         
1159930503 492 progress.jim                                                                                                                         
2734003092 418 save.jim

I don't know why your file names have the * suffix!
 
...
I don't know why your file names have the * suffix!
This perhaps?
Code:
# ls --help
...
  -F, --classify             append indicator (one of */=>@|) to entries
...
# alias ls='ls -F'
...
indicatorfile type
*regular file with executable permission
/directory
=socket
>door (Solaris RPC)
@symbolic link
|FIFO (pipe)
 
Your files are clearly unmodified from the originals, which is why your not seeing the changes!
Fine, that's what I decided, but why isn't patch working? And I cannot understand why it worked before (I am sure it did, but cannot find any evidence, I recall being satisfied).
 
Last edited:
Fine, that's what I decided, but why isn't patch working?
The version of patch in Busybox is old and stupid. It doesn't complain about things it should complain about. If you copy the diffs as posted on to a sane system and attempt it, then it tells you they are all garbage.
Please would somebody zip up and post their (modified) crop folder.
Would suggest the OP does it and posts proper diffs.

FWIW, there is also a missing " here:
Code:
+puts " )</td></tr>
 <tr><th>Time:</th>
 <td>Cropping will take around [clock format $esttime -format "%T"]</td></tr>
 </table>
I gave up.
 
FWIW, there is also a missing " here:

The closing quote appears in the original file on line 113, which becomes line 151 after modification, if it was included in the diff it would break the code.

@af123
Me neither, with @Matthew's permission I can get these changes incorporated into webif.

I am happy for this, or any of my mods to be incorporated into the webif. 👍
 
Back
Top