Last active
October 16, 2020 13:00
-
-
Save skl-songkiat/841f85be8913fa35f81f20d4a9d47149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String fileName = Environment.getExternalStorageDirectory().toString() + "/DCIM/videosample/sample.mp4"; | |
Log.i(TAG, "fileName="+fileName); | |
String aviFileName = Environment.getExternalStorageDirectory().toString() + "/DCIM/videosample/video_out.avi"; | |
Log.i(TAG, "aviFileName="+aviFileName); | |
int rc = FFmpeg.execute("-i " + fileName + " -vcodec mjpeg " + aviFileName); | |
if(rc == RETURN_CODE_SUCCESS){ | |
Log.i(TAG,"Success"); | |
}else if(rc == RETURN_CODE_CANCEL){ | |
Log.i(TAG, "CANCEL"); | |
}else { | |
Log.i(TAG,String.format("Command execute failed with rc=%d and the output below.", rc)); | |
} | |
VideoCapture cap = new VideoCapture(); | |
cap.open(aviFileName); | |
Mat frame = new Mat(); | |
int frameCount = 0; | |
if(cap.isOpened()){ | |
Log.d(TAG,"Video Open"); | |
while (true){ | |
Log.d(TAG,"frameCount = " + frameCount); | |
cap.read(frame); | |
Imgcodecs.imwrite( Environment.getExternalStorageDirectory().toString() + "/DCIM/videosample/image_output_"+ frameCount + ".jpeg",frame); | |
frameCount++; | |
if(frameCount == 25){ | |
break; | |
} | |
} | |
}else { | |
Log.d("VIDEOCAPTURE","Video Open FAILED"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment