Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 341
Kalpesh Kumawat Avatar asked Dec 19 '25 06:12

Kalpesh Kumawat


2 Answers

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"};
like image 60
Vinesh Chauhan Avatar answered Dec 21 '25 18:12

Vinesh Chauhan


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

like image 27
android Avatar answered Dec 21 '25 18:12

android