Capture and send frames captured from video recorded by an android application to server

359 views Asked by At

I wrote an android application to capture video and stored it in the phone's file system using the Directory.DCIM and then tried to use MediaMetaDataRetriever to capture the frames but it results into IllegalStateException.

// Snippet to capture video

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),CAPTURE_TITLE);
        Uri outputFileUri = Uri.fromFile( file );
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, outputFileUri);
        startActivityForResult(intent, ACTION_TAKE_VIDEO);

// Snippet to capture frames

MediaMetadataRetriever retriever = new MediaMetadataRetriever();
            retriever.setDataSource(path);
            ArrayList<Object> al = new ArrayList<Object>();
            System.out.println(retriever.getFrameAtTime().toString());
            Log.d("Frame Capture", retriever.getFrameAtTime().toString());
            al.add(retriever.getFrameAtTime());

Is there a better way to directly capture the frames from the video being recorded and directly send it to the server without storing the video on the mobile's filesystem ? If not, how can I get the above snippet working without running into the illegal state exception.

0

There are 0 answers