diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1794249..bac30e0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,11 +3,8 @@ xmlns:tools="http://schemas.android.com/tools" package="com.example.myapplication"> - - - if (result.resultCode == RESULT_OK) { + // There are no request codes val data: Uri? = result.data?.data - val contentResolver: ContentResolver = contentResolver - val fileDescriptor = contentResolver.openFileDescriptor(data!!, "r") - val fd = fileDescriptor?.fileDescriptor - val inputStream = FileInputStream(fd) - - val file = File(data.toString()) - Log.i("Tag", file.absolutePath) - - val fu = com.example.myapplication.utils.FileUtils(this) - - val test = "-i " + fu.getPath(data) + " -c:v libx264 -preset ultrafast -crf 28 -c:a aac -b:a 128k -movflags +faststart " + fu.getPath(data) + "_converted.mp4" - FFmpegKit.execute(test) + val inUri = FFmpegKitConfig.getSafParameterForRead(this, data) - val cursor = contentResolver.query(data, null, null, null, null) + + + val outputFile = File(this.filesDir, "output.mp4") + + if(outputFile.createNewFile()) { + Log.i("Tag", "File created") + } else { + Log.i("Tag", "File not created") + } + + + val outUri = FFmpegKitConfig.getSafParameter(this, outputFile.toUri(), "rw") + + val command = "-i $inUri -c:v mpeg4 $outUri -y" + val session = FFmpegKit.execute(command) + + Log.i("Tag", Arrays.deepToString(session.arguments)) + Log.i("Tag", session.output) + + + val cursor = contentResolver.query(data!!, null, null, null, null) cursor?.moveToFirst() @@ -118,8 +140,6 @@ class MainActivity : AppCompatActivity() { compressingItems.add(CompressingItem(fileName!!, 0.0, fileDate)) adapter.notifyDataSetChanged() - - Toast.makeText(applicationContext, data.toString(), Toast.LENGTH_LONG).show() } }