|
|
|
@ -6,6 +6,7 @@ import android.media.MediaMuxer;
|
|
|
|
|
|
|
|
|
|
import com.common.commonlib.db.DBUtils;
|
|
|
|
|
import com.common.commonlib.db.entity.Video;
|
|
|
|
|
import com.yinuo.library.vlc.utils.LogUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -28,8 +29,8 @@ public class AndroidMuxer {
|
|
|
|
|
private volatile int mNumReleases;
|
|
|
|
|
|
|
|
|
|
private long mStartRecordTime = 0L;
|
|
|
|
|
// private static final long DEFAULT_RECORD_DURATION = 30 * 60 * 1000;
|
|
|
|
|
private static final long DEFAULT_RECORD_DURATION = 10 * 1000;
|
|
|
|
|
private static final long DEFAULT_RECORD_DURATION = 30 * 60 * 1000;
|
|
|
|
|
// private static final long DEFAULT_RECORD_DURATION = 10 * 1000;
|
|
|
|
|
|
|
|
|
|
public AndroidMuxer() {
|
|
|
|
|
createMediaMuxer();
|
|
|
|
@ -37,19 +38,21 @@ public class AndroidMuxer {
|
|
|
|
|
|
|
|
|
|
private void createMediaMuxer() {
|
|
|
|
|
try {
|
|
|
|
|
File output = CameraHelper.getOutputMediaFile(CameraHelper.MEDIA_TYPE_VIDEO, "");
|
|
|
|
|
long timeMillis = System.currentTimeMillis();
|
|
|
|
|
File output = CameraHelper.getOutputMediaFile(CameraHelper.MEDIA_TYPE_VIDEO, timeMillis, DEFAULT_RECORD_DURATION);
|
|
|
|
|
String filePath = output.getAbsolutePath();
|
|
|
|
|
LogUtils.v(String.format("startRecording: %s", output));
|
|
|
|
|
mMuxer = new MediaMuxer(filePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
|
|
|
|
|
mStarted = false;
|
|
|
|
|
insertToDB(filePath);
|
|
|
|
|
insertToDB(timeMillis, filePath);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void insertToDB(String filePath) {
|
|
|
|
|
private void insertToDB(long timeMillis, String filePath) {
|
|
|
|
|
String[] splits = filePath.split("/");
|
|
|
|
|
Video cacheVideo = new Video(System.currentTimeMillis(), splits[splits.length - 1], false, filePath);
|
|
|
|
|
Video cacheVideo = new Video(timeMillis, splits[splits.length - 1], false, filePath);
|
|
|
|
|
DBUtils.INSTANCE.insertCacheVideo(cacheVideo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|