I record video using the inbuilt camera of android,but when I send to server via Retrofit2,the video cannot seen in browser.So after long time of searching,I know that the video that I record by android,the codec is MP42
so I need to convert it to H.264
codec in order to make it playable in browser.
Here is how I capture the video
private void recordVideo() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
fileUri = getOutputMediaFileUri();
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY,1);
intent.putExtra(MediaStore.EXTRA_OUTPUT,fileUri);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,15);
startActivityForResult(intent, REQUEST_VIDEO_CAPTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == RECORD_VIDEO_PERMISSION && resultCode == RESULT_OK){
Uri uri =data.getData(); //so the video file I get it here
Log.d("videoData",data.getData().toString());
videoView.setVideoURI(uri);
videoView.start();
}
}
I get the uri of the video in onActivityResult
,the video is in MP42
codec,how can I convert it to H.264
?
I tried to use MediaCodec Documentation,but I didnt know where to input my Uri
(mp42) to get the output in H.264 codec video(which I want to play in browser).
Somebody please give me some guidance..