Not Able to trim my video using "mobile-ffmpeg" / "ffmpeg-kit"

627 views Asked by At

I am using 'com.arthenica:ffmpeg-kit-full:4.4.LTS' for trimming my video.

I posted my code below, which I used to trim the video but every time it goes to the else block(every time my trimming fails) . Please help me out

val cmd = arrayOf("-i", trimmerData.srcPath, "-ss", startTime, "-t", endTime,
"-s", "320x240", "-r", "25", "-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050",
"-c", "copy", trimmerData.dstPath)
val session = FFmpegKit.execute(cmd)
if (ReturnCode.isSuccess(session.returnCode)) {
Log.i("ffmpeg","Success")
scanTrimFile(trimmerData)
// SUCCESS
} 
else if (ReturnCode.isCancel(session.returnCode)) {
Log.i("ffmpeg","Cancel")
// CANCEL
} 
else {
showTrimmingError()
// FAILURE
Log.d("ffmpeg", String.format("Command failed with state %s and rc %s.%s", session.state, session.returnCode, session.failStackTrace))
}
private fun scanTrimFile(trimmerData: TrimmerData) {
mediaScannerConnection = MediaScannerConnection(this,
object : MediaScannerConnection.MediaScannerConnectionClient {
override fun onMediaScannerConnected() {
mediaScannerConnection.scanFile(trimmerData.dstPath, "video/*")
}
                override fun onScanCompleted(path: String?, uri: Uri?) {
                    mediaScannerConnection.disconnect()
                    dismissWaitingDialog()
                    getResult(Uri.parse(trimmerData.dstPath))
                }
            })
    mediaScannerConnection.connect()
}

Error:

2021-04-20 09:39:09.448 20346-20706/org.xyz.ts W/ffmpeg-kit: Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option '-c copy' will be used.
2021-04-20 09:39:09.449 20346-20706/org.xyz.ts E/ffmpeg-kit: [mp4 @ 0xe6b84800] Could not find tag for codec amr_nb in stream #1, codec not currently supported in container
2021-04-20 09:39:09.449 20346-20706/org.xyz.ts E/ffmpeg-kit: Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
2021-04-20 09:39:09.451 20346-20706/org.xyz.ts E/ffmpeg-kit: Error initializing output stream 0:1 --
2021-04-20 09:39:09.451 20346-20706/org.xyz.ts I/ffmpeg-kit: Stream mapping:
2021-04-20 09:39:09.451 20346-20706/org.xyz.ts I/ffmpeg-kit: Stream #0:0 -> #0:0
2021-04-20 09:39:09.451 20346-20706/org.xyz.ts I/ffmpeg-kit: (copy)
2021-04-20 09:39:09.451 20346-20706/org.xyz.ts I/ffmpeg-kit: Stream #0:1 -> #0:1
2021-04-20 09:39:09.451 20346-20706/org.xyz.ts I/ffmpeg-kit: (copy)
2021-04-20 09:39:09.541 20346-20346/org.xyz.ts D/ffmpeg: Command failed with state COMPLETED and rc 1.null

LOG: https://docs.google.com/document/d/1yua-QLiu38LztN2frNWFHUVvl1YEedScmY4XDA2z5XU/edit?usp=sharing

0

There are 0 answers