Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to trim video in android #27

Closed
umesh-qainfotech opened this issue Apr 20, 2021 · 2 comments
Closed

Not able to trim video in android #27

umesh-qainfotech opened this issue Apr 20, 2021 · 2 comments
Assignees
Labels
android Affect Android platform ffmpeg-question Question about using ffmpeg library Affects the library question Further information is requested v4.4 Affects v4.4 release

Comments

@umesh-qainfotech
Copy link

Hi
I posted my code below, which I used to trim the video but every time it goes to the else block.
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

@umesh-qainfotech umesh-qainfotech changed the title Not able to trim video in android version: 9,11 Not able to trim video in android Apr 20, 2021
@tanersener tanersener added the question Further information is requested label Apr 20, 2021
@tanersener
Copy link
Collaborator

See tanersener/mobile-ffmpeg#560

@tanersener tanersener added the android Affect Android platform label Apr 20, 2021
@umesh-qainfotech
Copy link
Author

umesh-qainfotech commented Apr 20, 2021

Can you please provide me the command that needs to be passed as a parameter in FFmpeg.execute() for trim the video.

Existing command:
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)

Thanks in advance

@tanersener tanersener assigned tanersener and unassigned tanersener Apr 21, 2021
@tanersener tanersener self-assigned this May 1, 2021
@tanersener tanersener added library Affects the library v4.4 Affects v4.4 release ffmpeg-question Question about using ffmpeg labels May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Affect Android platform ffmpeg-question Question about using ffmpeg library Affects the library question Further information is requested v4.4 Affects v4.4 release
Projects
None yet
Development

No branches or pull requests

2 participants