2021年1月27日星期三

How to run a high quality video file above 100MB, convert to encoding code?

// Converting File to Base64.encode String type using Method fun getStringFile(f: File): String? { var inputStream: InputStream? = null var encodedFile = "" val lastVal: String try { inputStream = FileInputStream(f.absolutePath) val buffer = ByteArray(8192) //specify the size to allow var bytesRead: Int val output = ByteArrayOutputStream() val output64 = Base64OutputStream(output, Base64.DEFAULT) while (inputStream.read(buffer).also { bytesRead = it } != -1) { output64.write(buffer, 0, bytesRead) } output64.close() encodedFile = output.toString() } catch (e1: FileNotFoundException) { e1.printStackTrace() } catch (e: IOException) { e.printStackTrace() } lastVal = encodedFile return lastVal }

https://stackoverflow.com/questions/65923168/how-to-run-a-high-quality-video-file-above-100mb-convert-to-encoding-code January 28, 2021 at 12:21AM

没有评论:

发表评论