Improves video quality + save at better directory

bs
Laurent 5 years ago
parent fa9fe132ea
commit b42bc25c4c
  1. 12
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayExportService.kt
  2. 2
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerAnimator.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")

@ -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")

Loading…
Cancel
Save