Compressing and saving bitmap/thumbnail

I’m recording a video then saving it to the device, I use the path of the video to create and save a thumbnail, when trying to compress the bitmap I get the following error:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference

The Video file and the thumbnail is created in the desired folder. But the thumbnail is corrupted..

Please look at my code below, I commented where the crash is pointing to (under saveThumbnail):

public class testCam extends Activity {
    CameraView cameraView;
    ImageView startRec, stopRec;
    String filename;
    File directoryToStore;
    File filePlusName;      

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_cam);
        startRec = (ImageView) findViewById(R.id.startRec);
        stopRec = (ImageView) findViewById(R.id.stopRec);

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
        Date now = new Date();
        filename = formatter.format(now) + ".mp4";

        directoryToStore = getBaseContext().getExternalFilesDir("TestCam");

        filePlusName = new File(directoryToStore, filename);


    if (startRec.getVisibility() == View.VISIBLE){
        startRec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {                  
                startCaptureVideo();
            }
        });
    }if (startRec.getVisibility() == View.VISIBLE) {
        stopRec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                stopCaptureVideo();

            }
        });

    }

    cameraView = (CameraView) findViewById(R.id.camera);
    cameraView.start();
    cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM); // Pinch to zoom!
    cameraView.mapGesture(Gesture.TAP, GestureAction.FOCUS_WITH_MARKER); // Tap to focus!
    cameraView.mapGesture(Gesture.LONG_TAP, GestureAction.CAPTURE); // Long tap to shoot!

}

    private void startCaptureVideo() {
        cameraView.startCapturingVideo(filePlusName);
    }

    private void stopCaptureVideo(){
        cameraView.stopCapturingVideo();
        saveThumbnail();
    }

    private void saveThumbnail() {
        Bitmap b = ThumbnailUtils.createVideoThumbnail(directoryToStore + "/" + filename, 3);
        File newFile = new File(directoryToStore, filename.replace(".mp4", ".jpg"));
        FileOutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(newFile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        //This is where the issue is pointing to
        b.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
        try {
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

What is strange to me is that I have done it in the same way elsewhere in my application and this error doesn’t arise. Does anybody know why this is happening?