2016-04-29 192 views
1

我的代码:FFmpeg.execute.FFmpegExecuteResponseHandler对空对象引用

submit.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      execFFmpegBinary(" -i" + newFile.getAbsolutePath() + " -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -pass 2 -codec:a libfdk_aac -b:a 128k -f mp4 " + dest1.getAbsolutePath()); 

     } 
    }); 


public void execFFmpegBinary(final String command) { 
    try { 
     Log.d("path....",command); 
     ffmpeg.execute(command, new ExecuteBinaryResponseHandler() { 
      @Override 
      public void onFailure(String s) { 
       Log.d(TAG, "FAILED with output : " + s); 
      } 

      @Override 
      public void onSuccess(String s) { 
       Log.d(TAG, "SUCCESS with output : "+s); 
      } 

      @Override 
      public void onProgress(String s) { 
       Log.d(TAG, "Started command : ffmpeg "+command); 
       Log.d(TAG, "progress : " + s); 
      } 

      @Override 
      public void onStart() { 
       Log.d(TAG, "Started command : ffmpeg " + command); 
       progressDialog.setMessage("Processing..."); 
       progressDialog.show(); 
      } 

      @Override 
      public void onFinish() { 
       Log.d(TAG, "Finished command : ffmpeg " + command); 
       progressDialog.dismiss(); 
      } 
     }); 
    } catch (FFmpegCommandAlreadyRunningException e) { 
     // do nothing for now 
    } 
} 

显示此错误:

FATAL EXCEPTION: main 
Process: com.example.mypc.videocut, PID: 26910 
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.hiteshsondhi88.libffmpeg.FFmpeg.execute(java.lang.String, com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteResponseHandler)' on a null object reference 

回答

1

ffmpeg目前不instancied

您必须先拨打:

ffmpeg = FFmpeg.getInstance(this); 

并尝试加载库:

try { 
     ffmpeg.loadBinary(new LoadBinaryResponseHandler() { 
      @Override 
      public void onFailure() { 
       Log.e(TAG,""); 
      } 
     }); 
    } catch (FFmpegNotSupportedException e) { 
     Log.e(TAG,""); 
    } 

所以之后,你可以使用execute方法

相关问题