Kevin P
Kevin P

Reputation: 189

Trim / Cut video on Android using FFMpeg's Copy

We're trying to replicate the functionality of this command line ffmpeg directive using the FFMpeg c api through JNI calls on Android.

ffmpeg -ss 2 -t 120 -vcodec copy -acodec copy -i input.file output.file

Basically, given a start and end time, we wish to copy (not re-encode) a small(er) segment of video from the larger (input) video source.

We've been using the wonderful JavaCv wrapper to openCv and FFMpeg, but we just cannot figure out how to do this simple bit of work. We've been scouring the ffmpeg.c and related sources and while I now understand that it switches to stream_copy and remuxing rather than re-encoding when the codec is specified as copy I cannot for the life of me identify what series of method calls to make to replicate this through the C api. Does anyone have an example JNI file for doing this ? Or are there rockstar C types that can explain how I get from that command line to api calls? We've spent the better part of two weeks working on this (we're not native C guys) and we're at the point where we just need to ship some code. Any example code, especially JNI code or method call maps etc. would be greatly appreciated!

Upvotes: 3

Views: 3565

Answers (1)

Álvaro
Álvaro

Reputation: 2870

You have to include a JNI wrapper method in your Java code.

Maybe these two link are useful: Link 1 Link 2

Upvotes: 1

Related Questions