From b42bc25c4ce9419229080ff6bbebf8f4d541e8f3 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 26 Aug 2020 17:05:48 +0200 Subject: [PATCH] Improves video quality + save at better directory --- .../handhistory/replayer/ReplayExportService.kt | 12 +++++++++--- .../modules/handhistory/replayer/ReplayerAnimator.kt | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayExportService.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayExportService.kt index 1267f764..7db59bb0 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayExportService.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayExportService.kt @@ -145,13 +145,19 @@ class ReplayExportService : Service() { val tmpDir = animator.generateVideoContent(drawer, this@ReplayExportService) val dpath = "${tmpDir.path}/$FFMPEG_DESCRIPTOR_FILE" - val directory = context.getExternalFilesDir(null) ?: throw PAIllegalStateException("File is invalid") - val output = "${directory.path}/video_${Date().dateTimeFileFormatted}.mp4" +// val directory = context.getExternalFilesDir(null) ?: throw PAIllegalStateException("File is invalid") +// val output = "${directory.path}/video_${Date().dateTimeFileFormatted}.mp4" + + val formattedDate = Date().dateTimeFileFormatted + val output = File( + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), + "video_${formattedDate}.mp4" + ).path Environment.getExternalStorageState(tmpDir) Timber.d("Assembling images for video...") - FFmpeg.executeAsync("-f concat -safe 0 -i $dpath -vsync vfr -s ${width}x${height} -pix_fmt yuv420p $output") { id, rc -> + FFmpeg.executeAsync("-f concat -safe 0 -i $dpath -vb 20M -vsync vfr -s ${width}x${height} -pix_fmt yuv420p $output") { id, rc -> if (rc == RETURN_CODE_SUCCESS) { Timber.d("FFMPEG command execution completed successfully") diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerAnimator.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerAnimator.kt index b2fe1596..b8c59fb6 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerAnimator.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerAnimator.kt @@ -504,7 +504,7 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { imagePath = File(directory, "img_$count.png").path FileUtils.writeBitmapToPNG(bitmap, imagePath) -// bitmap.recycle() + bitmap.recycle() ffmpegImageDescriptor = ffmpegImageDescriptor.plus("file '$imagePath'\n") ffmpegImageDescriptor = ffmpegImageDescriptor.plus("duration $vo\n")