把图片转成mp4节目
核心代码
private void performJcodec() {
try {
Log.e("performJcodec: ", "执行开始");
SequenceEncoderMp4 se = null;
File file = new File(Constants.FILE_PICTRUES_FLODER);
File out = new File(Constants.FILE_FOLDER, "jcodec_enc.mp4");
se = new SequenceEncoderMp4(out);
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if (!files[i].exists()) { break; }
Bitmap frame = BitmapUtil.decodeSampledBitmapFromFile(files[i].getAbsolutePath() , 480 , 320);
se.encodeImage(frame);
Log.e("performJcodec: ", "执行到的图片是 " + i);
}
se.finish();
Log.e("performJcodec: ", "执行完成");
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(out)));
} catch (IOException e) {
Log.e("performJcodec: ", "执行异常 " + e.toString());
}
}
1