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
-
add some sample commands you are using, maybe if they are not optimized people cab help you optimize them and speed up the process. – Pavan K Jan 19 '17 at 15:26
-
GIF create command : String[] cmd = {"-y", "-i",path, "-vf", "scale=720:-1", "-t", "10", "-r", "10", pathForSave}; – Kalpesh Kumawat Jan 20 '17 at 07:01
-
Speed up and Slow video command: String[] cmd = {"-y", "-i", videopath, "-filter_complex","[0:v]setpts=1.0*PTS[v];[0:a]atempo=1.0[a],"-map","[v]","-map","[a]",pathForSave}; – Kalpesh Kumawat Jan 20 '17 at 07:03
-
You need to show your full `ffmpeg` command and the resulting complete console output/log. – llogan Jan 23 '17 at 07:10
4 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"};

- 1,288
- 11
- 27
-
Sorry, this is not working. It doesnot edit my audio file. Thats why so fast – Neela Oct 23 '17 at 17:26
-
Sorry, this is not working. It doesnot edit my audio file. Thats why so fast – Neela Oct 23 '17 at 17:28
-
I have need of trimming the audio file for some 1 min when the duration of the audio is more than 1 min. But trimming takes around 30 - 35 seconds. I have used this option, but the output file is the same file as original. – Neela Oct 24 '17 at 17:43
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

- 2,942
- 1
- 15
- 20
-
-
if you want to merge audio taken from same video then to keep resolution and frames safe try to add "-q:v", "1" and for larger videos you can try to set "-framerate" or -fps" by yourself and also use "acodec", "copy", "-vcodec", "copy" for better merged output – android Jan 17 '17 at 06:38
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.

- 851
- 9
- 11
-
Sir , i just use 10 second video for gif create and 15 second for video reverse and 60 second for video audio merge but It taking too much time – Kalpesh Kumawat Jan 17 '17 at 05:37
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.

- 11,627
- 2
- 58
- 74