Tell the result when finishing

pull/209/head
xufulong 4 years ago
parent e84cc97108
commit a59cee3de6
  1. 6
      app/CMakeLists.txt
  2. 55
      app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt
  3. 3
      app/src/main/java/com/frank/ffmpeg/activity/BaseActivity.kt
  4. 13
      app/src/main/java/com/frank/ffmpeg/activity/MediaHandleActivity.kt
  5. 92
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
  6. 3
      app/src/main/java/com/frank/ffmpeg/util/ThreadPoolUtil.kt

@ -50,8 +50,8 @@ set_target_properties( ffmpeg
../../../../libs/${CMAKE_ANDROID_ARCH_ABI}/libffmpeg.so ) ../../../../libs/${CMAKE_ANDROID_ARCH_ABI}/libffmpeg.so )
# third-party library: sox # third-party library: sox
add_subdirectory(src/main/cpp/sox) #add_subdirectory(src/main/cpp/sox)
include_directories(src/main/cpp/sox) #include_directories(src/main/cpp/sox)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
@ -72,7 +72,7 @@ find_library( # Sets the name of the path variable.
target_link_libraries( # Specifies the target library. target_link_libraries( # Specifies the target library.
media-handle media-handle
ffmpeg ffmpeg
sox # sox
-landroid #native_window -landroid #native_window
-ljnigraphics #bitmap -ljnigraphics #bitmap
-lOpenSLES #openSLES -lOpenSLES #openSLES

@ -73,10 +73,13 @@ class AudioHandleActivity : BaseActivity() {
infoBuilder.toString(), Toast.LENGTH_LONG).show() infoBuilder.toString(), Toast.LENGTH_LONG).show()
infoBuilder = null infoBuilder = null
} }
if (!outputPath.isNullOrEmpty() && !this@AudioHandleActivity.isDestroyed) {
showToast("Save to:$outputPath")
outputPath = ""
}
} }
MSG_PROGRESS -> { MSG_PROGRESS -> {
val progress = msg.arg1 val progress = msg.arg1
val duration = msg.arg2
if (progress > 0) { if (progress > 0) {
txtProgress!!.visibility = View.VISIBLE txtProgress!!.visibility = View.VISIBLE
txtProgress!!.text = String.format(Locale.getDefault(), "%d%%", progress) txtProgress!!.text = String.format(Locale.getDefault(), "%d%%", progress)
@ -161,17 +164,17 @@ class AudioHandleActivity : BaseActivity() {
} }
when (currentPosition) { when (currentPosition) {
0 -> if (useFFmpeg) { //use FFmpeg to transform 0 -> if (useFFmpeg) { //use FFmpeg to transform
val transformFile = PATH + File.separator + "transformAudio.mp3" outputPath = PATH + File.separator + "transformAudio.mp3"
commandLine = FFmpegUtil.transformAudio(srcFile, transformFile) commandLine = FFmpegUtil.transformAudio(srcFile, outputPath)
} else { //use MediaCodec and libmp3lame to transform } else { //use MediaCodec and libmp3lame to transform
Thread { Thread {
val transformPath = PATH + File.separator + "transformAudio.mp3" outputPath = PATH + File.separator + "transformAudio.mp3"
try { try {
mHandler.obtainMessage(MSG_BEGIN).sendToTarget() mHandler.obtainMessage(MSG_BEGIN).sendToTarget()
val clazz = Class.forName("com.frank.mp3.Mp3Converter") val clazz = Class.forName("com.frank.mp3.Mp3Converter")
val instance = clazz.newInstance() val instance = clazz.newInstance()
val method = clazz.getDeclaredMethod("convertToMp3", String::class.java, String::class.java) val method = clazz.getDeclaredMethod("convertToMp3", String::class.java, String::class.java)
method.invoke(instance, srcFile, transformPath) method.invoke(instance, srcFile, outputPath)
mHandler.obtainMessage(MSG_FINISH).sendToTarget() mHandler.obtainMessage(MSG_FINISH).sendToTarget()
} catch (e: Exception) { } catch (e: Exception) {
Log.e("AudioHandleActivity", "convert mp3 error=" + e.message) Log.e("AudioHandleActivity", "convert mp3 error=" + e.message)
@ -184,8 +187,8 @@ class AudioHandleActivity : BaseActivity() {
if (suffix == null || suffix.isEmpty()) { if (suffix == null || suffix.isEmpty()) {
return return
} }
val cutFile = PATH + File.separator + "cutAudio" + suffix outputPath = PATH + File.separator + "cutAudio" + suffix
commandLine = FFmpegUtil.cutAudio(srcFile, 10.5f, 15.0f, cutFile) commandLine = FFmpegUtil.cutAudio(srcFile, 10.5f, 15.0f, outputPath)
} }
2 //concat audio 2 //concat audio
-> { -> {
@ -205,11 +208,11 @@ class AudioHandleActivity : BaseActivity() {
return return
} }
commandLine = if (mixAudio) { commandLine = if (mixAudio) {
val mixAudio = PATH + File.separator + "mix" + mixSuffix outputPath = PATH + File.separator + "mix" + mixSuffix
FFmpegUtil.mixAudio(srcFile, appendFile, mixAudio) FFmpegUtil.mixAudio(srcFile, appendFile, outputPath)
} else { } else {
val mergeAudio = PATH + File.separator + "merge" + mixSuffix outputPath = PATH + File.separator + "merge" + mixSuffix
FFmpegUtil.mergeAudio(srcFile, appendFile, mergeAudio) FFmpegUtil.mergeAudio(srcFile, appendFile, outputPath)
} }
} }
4 //use AudioTrack to play audio 4 //use AudioTrack to play audio
@ -222,26 +225,26 @@ class AudioHandleActivity : BaseActivity() {
5 //change audio speed 5 //change audio speed
-> { -> {
val speed = 2.0f // funny effect, range from 0.5 to 100.0 val speed = 2.0f // funny effect, range from 0.5 to 100.0
val speedPath = PATH + File.separator + "speed.mp3" outputPath = PATH + File.separator + "speed.mp3"
commandLine = FFmpegUtil.changeAudioSpeed(srcFile, speedPath, speed) commandLine = FFmpegUtil.changeAudioSpeed(srcFile, outputPath, speed)
} }
6 // setting echo effect 6 // setting echo effect
-> { -> {
val echo = 1000 // echo effect, range from 0 to 90000 val echo = 1000 // echo effect, range from 0 to 90000
val echoPath = PATH + File.separator + "echo.mp3" outputPath = PATH + File.separator + "echo.mp3"
commandLine = FFmpegUtil.audioEcho(srcFile, echo, echoPath) commandLine = FFmpegUtil.audioEcho(srcFile, echo, outputPath)
} }
7 //tremolo effect 7 //tremolo effect
-> { -> {
val frequency = 5 // range from 0.1 to 20000.0 val frequency = 5 // range from 0.1 to 20000.0
val depth = 0.9f // range from 0 to 1 val depth = 0.9f // range from 0 to 1
val tremoloPath = PATH + File.separator + "tremolo.mp3" outputPath = PATH + File.separator + "tremolo.mp3"
commandLine = FFmpegUtil.audioTremolo(srcFile, frequency, depth, tremoloPath) commandLine = FFmpegUtil.audioTremolo(srcFile, frequency, depth, outputPath)
} }
8 //audio denoise 8 //audio denoise
-> { -> {
val noisePath = PATH + File.separator + "denoise.mp3" outputPath = PATH + File.separator + "denoise.mp3"
commandLine = FFmpegUtil.audioDenoise(srcFile, noisePath) commandLine = FFmpegUtil.audioDenoise(srcFile, outputPath)
} }
9 // equalizer plus 9 // equalizer plus
-> { -> {
@ -253,8 +256,8 @@ class AudioHandleActivity : BaseActivity() {
bandList.add("12b=2") bandList.add("12b=2")
bandList.add("14b=1") bandList.add("14b=1")
bandList.add("16b=0") bandList.add("16b=0")
val equalizePath = PATH + File.separator + "equalize.mp3" outputPath = PATH + File.separator + "equalize.mp3"
commandLine = FFmpegUtil.audioEqualizer(srcFile, bandList, equalizePath) commandLine = FFmpegUtil.audioEqualizer(srcFile, bandList, outputPath)
} }
10 //silence detect 10 //silence detect
-> { -> {
@ -263,18 +266,18 @@ class AudioHandleActivity : BaseActivity() {
11 // modify volume 11 // modify volume
-> { -> {
val volume = 0.5f // 0.0-1.0 val volume = 0.5f // 0.0-1.0
val volumePath = PATH + File.separator + "volume.mp3" outputPath = PATH + File.separator + "volume.mp3"
commandLine = FFmpegUtil.audioVolume(srcFile, volume, volumePath) commandLine = FFmpegUtil.audioVolume(srcFile, volume, outputPath)
} }
12 //audio encode 12 //audio encode
-> { -> {
val pcmFile = PATH + File.separator + "raw.pcm" val pcmFile = PATH + File.separator + "raw.pcm"
val wavFile = PATH + File.separator + "convert.mp3" outputPath= PATH + File.separator + "convert.mp3"
//sample rate, normal is 8000/16000/44100 //sample rate, normal is 8000/16000/44100
val sampleRate = 44100 val sampleRate = 44100
//channel num of pcm //channel num of pcm
val channel = 2 val channel = 2
commandLine = FFmpegUtil.encodeAudio(pcmFile, wavFile, sampleRate, channel) commandLine = FFmpegUtil.encodeAudio(pcmFile, outputPath, sampleRate, channel)
} }
13 //concat PCM streams 13 //concat PCM streams
-> { -> {
@ -329,6 +332,8 @@ class AudioHandleActivity : BaseActivity() {
private const val useFFmpeg = true private const val useFFmpeg = true
private const val mixAudio = true private const val mixAudio = true
private var outputPath :String ?= null
} }
} }

@ -13,6 +13,7 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
import com.frank.ffmpeg.FFmpegApplication
import com.frank.ffmpeg.R import com.frank.ffmpeg.R
import com.frank.ffmpeg.util.ContentUtil import com.frank.ffmpeg.util.ContentUtil
@ -104,7 +105,7 @@ abstract class BaseActivity : AppCompatActivity(), View.OnClickListener {
if (TextUtils.isEmpty(msg)) { if (TextUtils.isEmpty(msg)) {
return return
} }
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() Toast.makeText(FFmpegApplication.getInstance(), msg, Toast.LENGTH_SHORT).show()
} }
protected fun showSelectFile() { protected fun showSelectFile() {

@ -49,6 +49,10 @@ class MediaHandleActivity : BaseActivity() {
MSG_FINISH -> { MSG_FINISH -> {
layoutProgress!!.visibility = View.GONE layoutProgress!!.visibility = View.GONE
layoutMediaHandle!!.visibility = View.VISIBLE layoutMediaHandle!!.visibility = View.VISIBLE
if (!outputPath.isNullOrEmpty() && !this@MediaHandleActivity.isDestroyed) {
showToast("Save to:$outputPath")
outputPath = ""
}
} }
MSG_PROGRESS -> { MSG_PROGRESS -> {
val progress = msg.arg1 val progress = msg.arg1
@ -120,13 +124,13 @@ class MediaHandleActivity : BaseActivity() {
} }
R.id.btn_extract_audio//extract audio R.id.btn_extract_audio//extract audio
-> { -> {
val extractAudio = PATH + File.separator + "extractAudio.aac" outputPath = PATH + File.separator + "extractAudio.aac"
commandLine = FFmpegUtil.extractAudio(srcFile, extractAudio) commandLine = FFmpegUtil.extractAudio(srcFile, outputPath)
} }
R.id.btn_extract_video//extract video R.id.btn_extract_video//extract video
-> { -> {
val extractVideo = PATH + File.separator + "extractVideo.mp4" outputPath = PATH + File.separator + "extractVideo.mp4"
commandLine = FFmpegUtil.extractVideo(srcFile, extractVideo) commandLine = FFmpegUtil.extractVideo(srcFile, outputPath)
} }
R.id.btn_dubbing//dubbing R.id.btn_dubbing//dubbing
-> { -> {
@ -185,5 +189,6 @@ class MediaHandleActivity : BaseActivity() {
private val TAG = MediaHandleActivity::class.java.simpleName private val TAG = MediaHandleActivity::class.java.simpleName
private val PATH = Environment.getExternalStorageDirectory().path private val PATH = Environment.getExternalStorageDirectory().path
private var outputPath :String ?= null
} }
} }

@ -70,6 +70,10 @@ class VideoHandleActivity : BaseActivity() {
FileUtil.deleteFile(outputPath2) FileUtil.deleteFile(outputPath2)
FileUtil.deleteFile(listPath) FileUtil.deleteFile(listPath)
} }
if (!outputPath.isNullOrEmpty() && !this@VideoHandleActivity.isDestroyed) {
showToast("Save to:$outputPath")
outputPath = ""
}
} }
MSG_PROGRESS -> { MSG_PROGRESS -> {
val progress = msg.arg1 val progress = msg.arg1
@ -172,23 +176,23 @@ class VideoHandleActivity : BaseActivity() {
when (currentPosition) { when (currentPosition) {
0 //transform format 0 //transform format
-> { -> {
val transformVideo = PATH + File.separator + "transformVideo.mp4" outputPath = PATH + File.separator + "transformVideo.mp4"
commandLine = FFmpegUtil.transformVideo(srcFile, transformVideo) commandLine = FFmpegUtil.transformVideo(srcFile, outputPath)
} }
1 //cut video 1 //cut video
-> { -> {
val cutVideo = PATH + File.separator + "cutVideo" + suffix outputPath = PATH + File.separator + "cutVideo" + suffix
val startTime = 5.5f val startTime = 5.5f
val duration = 20.0f val duration = 20.0f
commandLine = FFmpegUtil.cutVideo(srcFile, startTime, duration, cutVideo) commandLine = FFmpegUtil.cutVideo(srcFile, startTime, duration, outputPath)
} }
2 //concat video together 2 //concat video together
-> concatVideo(srcFile) -> concatVideo(srcFile)
3 //video snapshot 3 //video snapshot
-> { -> {
val screenShot = PATH + File.separator + "screenShot.jpg" outputPath = PATH + File.separator + "screenShot.jpg"
val time = 10.5f val time = 10.5f
commandLine = FFmpegUtil.screenShot(srcFile, time, screenShot) commandLine = FFmpegUtil.screenShot(srcFile, time, outputPath)
} }
4 //add watermark to video 4 //add watermark to video
-> { -> {
@ -208,23 +212,22 @@ class VideoHandleActivity : BaseActivity() {
TYPE_IMAGE// image TYPE_IMAGE// image
-> { -> {
val photo = PATH + File.separator + "hello.png" val photo = PATH + File.separator + "hello.png"
val photoMark = PATH + File.separator + "photoMark.mp4" outputPath = PATH + File.separator + "photoMark.mp4"
commandLine = FFmpegUtil.addWaterMarkImg(srcFile, photo, location, bitRate, offsetXY, photoMark) commandLine = FFmpegUtil.addWaterMarkImg(srcFile, photo, location, bitRate, offsetXY, outputPath)
} }
TYPE_GIF// gif TYPE_GIF// gif
-> { -> {
val gifPath = PATH + File.separator + "ok.gif" val gifPath = PATH + File.separator + "ok.gif"
val gifWaterMark = PATH + File.separator + "gifWaterMark.mp4" outputPath = PATH + File.separator + "gifWaterMark.mp4"
commandLine = FFmpegUtil.addWaterMarkGif(srcFile, gifPath, location, bitRate, offsetXY, gifWaterMark) commandLine = FFmpegUtil.addWaterMarkGif(srcFile, gifPath, location, bitRate, offsetXY, outputPath)
} }
TYPE_TEXT// text TYPE_TEXT// text
-> { -> {
val text = "Hello,FFmpeg" val text = "Hello,FFmpeg"
val textPath = PATH + File.separator + "text.png" val textPath = PATH + File.separator + "text.png"
val result = BitmapUtil.textToPicture(textPath, text, Color.BLUE, 20) val result = BitmapUtil.textToPicture(textPath, text, Color.BLUE, 20)
Log.i(TAG, "text to picture result=$result") outputPath = PATH + File.separator + "textMark.mp4"
val textMark = PATH + File.separator + "textMark.mp4" commandLine = FFmpegUtil.addWaterMarkImg(srcFile, textPath, location, bitRate, offsetXY, outputPath)
commandLine = FFmpegUtil.addWaterMarkImg(srcFile, textPath, location, bitRate, offsetXY, textMark)
} }
else -> { else -> {
} }
@ -232,14 +235,14 @@ class VideoHandleActivity : BaseActivity() {
} }
5 //Remove logo from video, or use to mosaic video 5 //Remove logo from video, or use to mosaic video
-> { -> {
val removeLogoPath = PATH + File.separator + "removeLogo" + suffix outputPath = PATH + File.separator + "removeLogo" + suffix
val widthL = 64 val widthL = 64
val heightL = 40 val heightL = 40
commandLine = FFmpegUtil.removeLogo(srcFile, 10, 10, widthL, heightL, removeLogoPath) commandLine = FFmpegUtil.removeLogo(srcFile, 10, 10, widthL, heightL, outputPath)
} }
7 //convert video into gif 7 //convert video into gif
-> { -> {
val video2Gif = PATH + File.separator + "video2Gif.gif" outputPath = PATH + File.separator + "video2Gif.gif"
val gifStart = 10 val gifStart = 10
val gifDuration = 3 val gifDuration = 3
val width = 320 val width = 320
@ -251,39 +254,39 @@ class VideoHandleActivity : BaseActivity() {
val paletteCmd = FFmpegUtil.generatePalette(srcFile, gifStart, gifDuration, val paletteCmd = FFmpegUtil.generatePalette(srcFile, gifStart, gifDuration,
frameRate, width, palettePath) frameRate, width, palettePath)
val gifCmd = FFmpegUtil.generateGifByPalette(srcFile, palettePath, gifStart, gifDuration, val gifCmd = FFmpegUtil.generateGifByPalette(srcFile, palettePath, gifStart, gifDuration,
frameRate, width, video2Gif) frameRate, width, outputPath)
val cmdList = ArrayList<Array<String>>() val cmdList = ArrayList<Array<String>>()
cmdList.add(paletteCmd) cmdList.add(paletteCmd)
cmdList.add(gifCmd) cmdList.add(gifCmd)
ffmpegHandler!!.executeFFmpegCmds(cmdList) ffmpegHandler!!.executeFFmpegCmds(cmdList)
} else { } else {
convertGifInHighQuality(video2Gif, srcFile, gifStart, gifDuration, frameRate) convertGifInHighQuality(outputPath!!, srcFile, gifStart, gifDuration, frameRate)
} }
} }
8 //combine video which layout could be horizontal of vertical 8 //combine video which layout could be horizontal of vertical
-> { -> {
val input1 = PATH + File.separator + "input1.mp4" val input1 = PATH + File.separator + "input1.mp4"
val input2 = PATH + File.separator + "input2.mp4" val input2 = PATH + File.separator + "input2.mp4"
val outputFile = PATH + File.separator + "multi.mp4" outputPath = PATH + File.separator + "multi.mp4"
if (!FileUtil.checkFileExist(input1) || !FileUtil.checkFileExist(input2)) { if (!FileUtil.checkFileExist(input1) || !FileUtil.checkFileExist(input2)) {
return return
} }
commandLine = FFmpegUtil.multiVideo(input1, input2, outputFile, VideoLayout.LAYOUT_HORIZONTAL) commandLine = FFmpegUtil.multiVideo(input1, input2, outputPath, VideoLayout.LAYOUT_HORIZONTAL)
} }
9 //video reverse 9 //video reverse
-> { -> {
val output = PATH + File.separator + "reverse.mp4" outputPath = PATH + File.separator + "reverse.mp4"
commandLine = FFmpegUtil.reverseVideo(srcFile, output) commandLine = FFmpegUtil.reverseVideo(srcFile, outputPath)
} }
10 //noise reduction of video 10 //noise reduction of video
-> { -> {
val denoise = PATH + File.separator + "denoise.mp4" outputPath = PATH + File.separator + "denoise.mp4"
commandLine = FFmpegUtil.denoiseVideo(srcFile, denoise) commandLine = FFmpegUtil.denoiseVideo(srcFile, outputPath)
} }
11 //convert video to picture 11 //convert video to picture
-> { -> {
val imagePath = PATH + File.separator + "Video2Image/" outputPath = PATH + File.separator + "Video2Image/"
val imageFile = File(imagePath) val imageFile = File(outputPath)
if (!imageFile.exists()) { if (!imageFile.exists()) {
if (!imageFile.mkdir()) { if (!imageFile.mkdir()) {
return return
@ -292,7 +295,7 @@ class VideoHandleActivity : BaseActivity() {
val mStartTime = 10//start time val mStartTime = 10//start time
val mDuration = 5//duration val mDuration = 5//duration
val mFrameRate = 10//frameRate val mFrameRate = 10//frameRate
commandLine = FFmpegUtil.videoToImage(srcFile, mStartTime, mDuration, mFrameRate, imagePath) commandLine = FFmpegUtil.videoToImage(srcFile, mStartTime, mDuration, mFrameRate, outputPath)
} }
12 //combine into picture-in-picture video 12 //combine into picture-in-picture video
-> { -> {
@ -305,8 +308,8 @@ class VideoHandleActivity : BaseActivity() {
//For example: full video is 320x240, small video is 120x90, so x=200 y=150 //For example: full video is 320x240, small video is 120x90, so x=200 y=150
val x = 200 val x = 200
val y = 150 val y = 150
val picInPic = PATH + File.separator + "PicInPic.mp4" outputPath = PATH + File.separator + "PicInPic.mp4"
commandLine = FFmpegUtil.picInPicVideo(inputFile1, inputFile2, x, y, picInPic) commandLine = FFmpegUtil.picInPicVideo(inputFile1, inputFile2, x, y, outputPath)
} }
13 //moov box moves ahead, which is behind mdat box of mp4 video 13 //moov box moves ahead, which is behind mdat box of mp4 video
-> { -> {
@ -317,48 +320,48 @@ class VideoHandleActivity : BaseActivity() {
val filePath = FileUtil.getFilePath(srcFile) val filePath = FileUtil.getFilePath(srcFile)
var fileName = FileUtil.getFileName(srcFile) var fileName = FileUtil.getFileName(srcFile)
fileName = "moov_" + fileName!! fileName = "moov_" + fileName!!
val moovPath = filePath + File.separator + fileName outputPath = filePath + File.separator + fileName
if (useFFmpegCmd) { if (useFFmpegCmd) {
commandLine = FFmpegUtil.moveMoovAhead(srcFile, moovPath) commandLine = FFmpegUtil.moveMoovAhead(srcFile, outputPath)
} else { } else {
val ffmpegCmd = FFmpegCmd() val ffmpegCmd = FFmpegCmd()
val result = ffmpegCmd.moveMoovAhead(srcFile, moovPath) val result = ffmpegCmd.moveMoovAhead(srcFile, outputPath)
Log.e(TAG, "result=" + (result == 0)) Log.e(TAG, "result=" + (result == 0))
} }
} }
14 //playing speed of video 14 //playing speed of video
-> { -> {
val speed = PATH + File.separator + "speed.mp4" outputPath = PATH + File.separator + "speed.mp4"
commandLine = FFmpegUtil.changeSpeed(srcFile, speed, 2f, false) commandLine = FFmpegUtil.changeSpeed(srcFile, outputPath, 2f, false)
} }
15 // insert thumbnail into video 15 // insert thumbnail into video
-> { -> {
val thumbnailPath = PATH + File.separator + "thumb.jpg" val thumbnailPath = PATH + File.separator + "thumb.jpg"
val thumbVideoPath = PATH + File.separator + "thumbnailVideo" + suffix outputPath = PATH + File.separator + "thumbnailVideo" + suffix
commandLine = FFmpegUtil.insertPicIntoVideo(srcFile, thumbnailPath, thumbVideoPath) commandLine = FFmpegUtil.insertPicIntoVideo(srcFile, thumbnailPath, outputPath)
} }
16 //add subtitle into video 16 //add subtitle into video
-> { -> {
val subtitlePath = PATH + File.separator + "test.ass" val subtitlePath = PATH + File.separator + "test.ass"
val addSubtitlePath = PATH + File.separator + "subtitle.mkv" outputPath = PATH + File.separator + "subtitle.mkv"
commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, addSubtitlePath) commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, outputPath)
} }
17 // set the rotate degree of video 17 // set the rotate degree of video
-> { -> {
val rotateDegree = 90 val rotateDegree = 90
val addSubtitlePath = PATH + File.separator + "rotate" + rotateDegree + suffix outputPath = PATH + File.separator + "rotate" + rotateDegree + suffix
commandLine = FFmpegUtil.rotateVideo(srcFile, rotateDegree, addSubtitlePath) commandLine = FFmpegUtil.rotateVideo(srcFile, rotateDegree, outputPath)
} }
18 // change the gop(key frame interval) of video 18 // change the gop(key frame interval) of video
-> { -> {
val gop = 30 val gop = 30
val gopPath = PATH + File.separator + "gop" + gop + suffix outputPath = PATH + File.separator + "gop" + gop + suffix
commandLine = FFmpegUtil.changeGOP(srcFile, gop, gopPath) commandLine = FFmpegUtil.changeGOP(srcFile, gop, outputPath)
} }
19 // change video from RGB to gray 19 // change video from RGB to gray
-> { -> {
val grayPath = PATH + File.separator + "gray" + suffix outputPath = PATH + File.separator + "gray" + suffix
commandLine = FFmpegUtil.toGrayVideo(srcFile, grayPath) commandLine = FFmpegUtil.toGrayVideo(srcFile, outputPath)
} }
else -> { else -> {
} }
@ -472,6 +475,7 @@ class VideoHandleActivity : BaseActivity() {
private val TAG = VideoHandleActivity::class.java.simpleName private val TAG = VideoHandleActivity::class.java.simpleName
private val PATH = Environment.getExternalStorageDirectory().path private val PATH = Environment.getExternalStorageDirectory().path
private var outputPath :String ?= null
private const val useFFmpegCmd = true private const val useFFmpegCmd = true
private const val TYPE_IMAGE = 1 private const val TYPE_IMAGE = 1

@ -5,8 +5,9 @@ import java.util.concurrent.Executors
object ThreadPoolUtil { object ThreadPoolUtil {
private val executor = Executors.newSingleThreadExecutor()
fun executeSingleThreadPool(runnable: Runnable): ExecutorService { fun executeSingleThreadPool(runnable: Runnable): ExecutorService {
val executor = Executors.newSingleThreadExecutor()
executor.submit(runnable) executor.submit(runnable)
return executor return executor
} }

Loading…
Cancel
Save