Kalpesh Kumawat
Kalpesh Kumawat

Reputation: 49

FFMPEG command execution taking too much time in android

When i run any command of FFMPEG, It taking too much time in execution. I am using FFMPEG command for reverse video, audio video merge, create GIF images and changing speed of video. Please tell me how to run FFMPEG command fast. Please Help me

Upvotes: 3

Views: 5944

Answers (4)

Vinesh Chauhan
Vinesh Chauhan

Reputation: 1378

add below code in ffmpeg command to increase little bit speed of processing

-c:v libx264 -preset ultrafast

for audio trimming

int minutes = (int) Math.floor(start_sec / 1000 / 60);
        int seconds =(int)Math.ceil(start_sec / 1000) - (minutes * 60);
        int endSeconds=(int) ((end_sec / 1000) - (minutes * 60));
        int duration=endSeconds-seconds;
        Log.d("start_point_seconds",""+seconds);
        Log.d("start minutes",""+minutes);
        String[] complexCommand = {"-i", src + "", "-ss", "00:"+minutes+":"+seconds, "-t",""+duration ,"-acodec","copy","/storage/emulated/0/Music/"+app_name+"/music_" + number + ".mp3"};

Upvotes: 6

alijandro
alijandro

Reputation: 12147

Yes, it's very slow on Android devices. FFMPEG don't have hardware speed on most of the Android devices. It means all the computation is done in CPU. How fast for a FFMPEG command largely depends on devices' CPU speed.

For audio for video processing via FFMPEG, it has to handle the data one sample by one sample or one frame by one frame.

You might think other solutions which has hardware acceleration, e.g MediaCodec, RenderScript, Open GLES, Open CL, to do the intensive computing to speed up.

Upvotes: 0

android
android

Reputation: 3090

you should use "-preset", "ultrafast" in your ffmpeg command to speedup execution time but it only works if video is less than 15 seconds otherwise it speedup execution time but delay on startup time of video play and it might look like your audio and video not matched with frames

Upvotes: 1

Rakyesh Kadadas
Rakyesh Kadadas

Reputation: 941

Execution time of ffmpeg is depend on size of file. so however big files take long time for conversion, but it also depend on what type operation you are performing.

Upvotes: 0

Related Questions