10 Jul 2017, 5:12pm
linux:

leave a comment




  • Anzeige
  • Rendering problem with Kdenlive

    I really enjoy using the Kden­live video edi­tor. I think it’s a sim­ple, straight for­ward, and yet pow­er­ful tool.

    But just dur­ing the last few days, I had trou­bles for the first time and could not find a solu­tion. When ren­der­ing my project, it kept fail­ing with max_analyze_duration 5000000 reached at 5000000. I searched online, the error might be related to the size of the audio (>1h) Still, the project ren­dered at first, but after the final cut — with lots and lots of cuts — I started get­ting this error, thus, out of a sud­den, I was not able to get my final video file out any­more. Was I threat­ened to hav­ing to do the entire work again or what??

    Finally, today I found a solu­tion! Bet­ter, a workaround.

    I split up the file by adding guides — in my case three, but the num­ber might depend on the project size — and then used the ren­der fea­ture “Guide zone” (at the bot­tom of the ren­der dia­log). So, I ren­dered three parts and used melt to put them together like this:

    melt input*.mp4 -consumer avformat:result.mp4 acodec=aac ab=160k vcodec=libx264 vb=3000k
    

    I’m using x.264 and AAC here — but you can also drop all those para­me­ters and let melt fig­ure every­thing out — it’s pretty capa­ble, give it a try.

    melt input*.mp4 -consumer avformat:result.mp4
    

    If you have ffmpeg on your sys­tem, you can merge the files using the copy mode, so no qual­ity gets lost — see details here. But even when using melt and thus re-encoding the video, you will not notice that it has been ren­dered in three parts and “melted” later. So I’m happy! Still a bit sur­pris­ing that I could not find a solu­tion online. So hey, hope this approach works for you too! :)

    15 Nov 2012, 5:37pm
    gwt:

    1 comment




  • Anzeige
  • GWTBridge Not Found in GWT2.5

    Just updated the GWT SDK and ended up with a bro­ken app:

    java.lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:169)
    	at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
    	at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
    

    After some searching/experimenting and a cup of cof­fee it finally occurred to me: the pack­age name says client! So all the time I have been using a client-package class in my server-side code. Kinda sur­pris­ing that it did work nicely all the while.

    Solu­tion: replace all com.google.gwt.core.client.GWT with com.google.gwt.core.shared.GWT in shared and server-side code.

    20 Sep 2012, 1:32pm
    gwt java:

    13 comments




  • Anzeige
  • Using GWT’s DateTimeFormat in Server-Side Code

    I was work­ing on some util­ity class to for­mat dates. As the for­mat­ting is the same on server and client the same class should be used on both, server and client. Within the GWT frame­work there is the DateTimeFormat class which seems to be sup­posed to do exactly that.

    But despite being in the shared pack­age (com.google.gwt.i18n.shared.DateTimeFormat) using it in the server-side code causes

    java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.

    Hav­ing a look into the code of the DateTimeFormat class (which is part of the shared pack­age of the GWT frame­work, thus can be used on server and client) reveals there is an import of com.google.gwt.i18n.client.LocaleInfo. But this class is part of the client pack­age — thus, it can not be used in the server-side code. It’s unclear to me why this was done like that because it sim­ply can not work by definition…

    Going down a bit fur­ther in the code of the DateTimeFormat class shows that the client pack­age class LocaleInfo is used only once like this:

    private static DateTimeFormatInfo getDefaultDateTimeFormatInfo() {
      // MUSTFIX(jat): implement
      return LocaleInfo.getCurrentLocale().getDateTimeFormatInfo();
    }

    The line is marked as “MUSTFIX” but for some rea­son it has not been fixed yet.
    There is a way to fix this issue that worked for me:

    • Copy the con­tent of DateTimeFormat to a new file in your own code
    • Remove the import of LocaleInfo
    • Chang­ing the fol­low­ing method (start­ing in line 656) like this:
    private static DateTimeFormatInfo getDefaultDateTimeFormatInfo() {
      return new DefaultDateTimeFormatInfo();
    }
    • And use this newly cre­ated class from now on in all your code.

    The fix does not seem to cause any major harm, but as John A. Tam­plin (cf. his com­ment below) clearly pointed out, apply­ing this fix will ren­der all dates using the default locale instead of using the user’s locale. Thus, this fix should be con­sid­ered a hack rather than a patch — but it does the trick until the bug has been fixed officially.

    The hack can be applied quickly — or sim­ply down­load the fixed class here.

    p.s. Unfor­tu­nately, it is not pos­si­ble to just over­write the method in a derived class because it’s a sta­tic method and pri­vate any­way.
    p.p.s. As sug­gested in the com­ments, you might also ini­tial­ize the DateTimeFormat with a new DefaultDateTimeFormatInfo() as the sec­ond para­menter. (Please note that I did not ver­ify this sug­ges­tion) In gen­eral, both ways of fix­ing this issue will cause that the date and time to be for­mated using the default locale rather than the user’s cur­rent locale, unfortunately.

    31 Jan 2012, 10:53am
    gwt java javascript:

    leave a comment




  • Anzeige
  • An invalid or illegal string was specified” Exception in GWT

    While work­ing with can­vas (draw­ing stuff on it) in GWT, sud­denly and in a seem­ingly unpre­dictable man­ner I got fol­low­ing error mes­sage now and then from within the GWT frame­work code:

    com.google.gwt.core.client.JavaScriptException: (NS_ERROR_DOM_SYNTAX_ERR): An invalid or illegal string was specified;

    Again, GWT tricked me into think­ing I am writ­ing Java code and made me for­get about that it is going to be com­piled into Javascript. And because of the lat­ter, a divi­sion by zero does not throw an Devi­sion­ByZe­roEx­cep­tion, no, it returns NaN even for native data types (there is no dif­fer­en­ti­a­tion between dou­ble and Dou­ble in Javascript — there is only the object-version of dou­ble, which can be of value Double.NaN).

    But also GWT was not pre­pared to han­dle Double.NaN. When call­ing canvas.getContext().drawImage(image,x,y) and one of x and y or both were Double.NaN I got the error mes­sage shown above. If you got the same… you know what to do now: check all devi­sions in your code for poten­tial devi­sions by zero!!

    18 Feb 2011, 1:27pm
    gwt:

    1 comment




  • Anzeige
  • Disable an Anchor in GWT

    Unex­pect­edly, call­ing setEnabled(false) does not pre­vent a link/anchor from being clicked. That means, the click events still get trig­gered.
    The rea­son is more or less a bug in GWT as it updates the list of events that are going to be trig­gered only at the moment when it gets attached to the DOM (Btw, in GWT, this process is called to sink and to unsink events, where the for­mer enables a spe­cific event to be trig­gered and the lat­ter dis­ables it).
    I found a workaround by cre­at­ing my own Anchor class and forc­ing the under­ly­ing GWT Anchor to update the list of events to be sunk.

    ...
    import com.google.gwt.event.dom.client.ClickHandler;
    import com.google.gwt.user.client.Event;
    
    public class Anchor extends com.google.gwt.user.client.ui.Anchor {
    
    	@Override public void setEnabled(boolean enabled) {
    		super.setEnabled(enabled);
    		if (isAttached()) {
    			onDetach();
    			if (enabled) {
    				sinkEvents(Event.ONCLICK);
    			} else {
    				unsinkEvents(Event.ONCLICK);
    			}
    			onAttach();
    		}
    	}
    
    	@Override protected void onLoad() {
    		super.onLoad();
    		if (isEnabled()) {
    			sinkEvents(Event.ONCLICK);
    		} else {
    			unsinkEvents(Event.ONCLICK);
    		}
    	}
    }

    Note the onLoad method, it sets up the state when the wid­get gets attached to the DOM the first time. It is required because setEnabled() could have been called before the anchor got attached.

    If you encoun­tered the same issue, please vote for this bug report.

    14 Feb 2011, 9:48pm
    linux:

    leave a comment




  • Anzeige
  • Flickering Screen with ATI Radeon X1400 and Ubuntu

    EDIT: ATI Radeon X1400 seems to work fine again since Ubuntu 11.04.

    There is another fix to the “well known” issues with the ATI Radeon X1400 and Ubuntu 10.04 to 10.10 besides the one posted about one year ago (see here).
    The pre­vi­ous fix kept the graph­ics card work­ing nor­mally but harmed the over­all oper­at­ing system’s sta­bil­ity, so here is another fix based on dis­abling all 3D fea­tures of the device to get rid of the flick­er­ing screen.

    It’s up to you to choose what you are able to live with­out
    a) The desk­top set­tings panel and “Seg­men­ta­tion fault” errors now and then, or
    b) 3D accel­er­a­tion (does not harm video play­back or any other basic OS functionalities)

    For solu­tion a) see this.
    For b) cre­ate this file: /etc/modprobe.d/radeon-kms.conf — and add fol­low­ing content

    options radeon modeset=0

    Solu­tion found here (in German).

    14 Dec 2010, 11:49am
    java:

    leave a comment




  • Anzeige
  • Casting collections in Java

    Assum­ing two classes A and B as

    class A {}
    class B extends A {}

    It is just log­i­cal that cast­ing B to A works fine:

    A anObjectOfClassA = new B();

    But when it comes to col­lec­tions of As and Bs, a strange phe­nom­e­non appears in Java:

    Collection<B> collectionOfBs = new LinkedList<B>();
    Collection<A> collectionOfAs = (Collection<A>)collectionOfBs; // this line does not compile!

    That is, though the col­lec­tion wrap­per (the java.util.Collection class) is the same and B extends A, cast­ing a col­lec­tion of objects of class B to a col­lec­tion of objects of class A throws an compile-time error.

    But it works using gener­ics (the whole class for the sake of com­plete­ness and reusability):

    import java.util.Collection;
    import java.util.LinkedList;
    
    public class CollectionCastingExample {
    
      class A {}
      class B extends A {}
    	
      Collection<B> collectionOfBs = new LinkedList<B>();
    //  Collection<A> collectionOfAs = (Collection<A>)collectionOfBs;
    	
      Collection<A> collectionOfAs = downCastCollection(collectionOfBs, A.class);
    	
      /**
       * Casts a collection of objects of class B where B extends A to a collection of objects of class A.
       * 
       * @param <T> Base class
       * @param collection Collection of objects of a class extending T 
       * @param aClass Representation of T
       * @return Collection of objects of T casted from given collection of objects of a class extending T.
       */
      @SuppressWarnings("unchecked")
      public static <T> Collection<T> downCastCollection(Collection<? extends T> collection,
          Class<T> aClass) {
        return (Collection<T>) collection;
      }
    }

    Despite the fact that a @SuppressWarnings("unchecked") is required, it avoids iter­at­ing over the whole col­lec­tion of Bs and cast­ing each of them from B to A plus adding them to a new col­lec­tion of As.

    17 Sep 2010, 3:49pm
    gwt java:

    leave a comment




  • Anzeige
  • Uploading File to Server: Access Denied

    Sim­ple task: upload a file to the server. Achieved so far: upload form works and the file gets trans­ferred to the server.
    But as soon as the file is writ­ten, I get one of that:
    “java.security.AccessControlException: access denied (java.io.FilePermission /some/folder/upload__71c20601_12b1b66bc39__7ffa_00000000.tmp write)“
    I am amazed how much search­ing is required to find some infor­ma­tion about how to mod­ify the file per­mis­sions for the local app engine! And in the end, it turns out that there is an issue with the GAE on Mac but with­out a way to con­fig­ure the local Jetty server to allow write access. :(
    As soon as I deploy the app to a Tom­cat on Linux, it works like a charm!

    16 Sep 2010, 6:02pm
    jobs projects:

    3 comments




  • Anzeige
  • GWT FileUpload: Adding Widgets to a FormPanel

    If you build your first GWT form, for exam­ple some­thing like that:

    <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
    <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
    xmlns:g="urn:import:com.google.gwt.user.client.ui">
    <g:HTMLPanel>
    <g:FormPanel ui:field="form"> 
    <g:FileUpload ui:field="uploadField" name="file"/>
    <g:SubmitButton ui:field="submitButton">Upload</g:SubmitButton>
    </g:FormPanel>
    </g:HTMLPanel>
    </ui:UiBinder>

    And your con­sole keeps telling you dur­ing run­time some­thing like this: “java.lang.IllegalStateException: Sim­plePanel can only con­tain one child wid­get”. Instead of writ­ing a long page of expla­na­tions and com­plaints like I did before, it’s sim­ply like that:

    Just put all your wid­gets in a panel (like Hor­i­zon­tal­Panel) and add that panel to the Form­Panel.” (Jake − cf. com­ment below)

    Thanks Jake! :)