Created
March 21, 2019 03:03
-
-
Save yeshengwu/5bc9d8c30f78c9ed76a249f6d7d584a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private Context mContext; | |
public void setContext(Context context) { | |
mContext = context; | |
createfile(); | |
} | |
private BufferedOutputStream outputStream; | |
private void createfile() { | |
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + SystemClock.elapsedRealtime() + ".h264"; | |
File file = null; | |
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { | |
File file1 = mContext.getApplicationContext().getExternalCacheDir(); | |
if (file1 != null) { | |
file1 = FileUtils.getFile(file1, "test"); | |
file1.mkdirs(); | |
file = FileUtils.getFile(file1, 1 + ".h264"); | |
Log.e("evan", "filepateh=" + file.getAbsolutePath()); | |
} | |
} | |
if (file.exists()) { | |
file.delete(); | |
} | |
try { | |
outputStream = new BufferedOutputStream(new FileOutputStream(file)); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
try { | |
Log.e("evan","onVideoPacket. packet = "+packet.size); | |
outputStream.write(packet.data, 0, packet.size); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment