Android – How to increase video encoding speed in ffmpeg

androidffmpegvideo

I am recording video clips and then joining all the clips in a final video.
Everything goes fine but the joining process takes too long.

Tried to using some ffmpeg filters from here:
https://trac.ffmpeg.org/wiki/Encode/H.264

And here is my ffmpeg command that I am using to increase the speed (which seems to be wrong):

command = new String[]{"-y",
                "-f",
                "concat",
                "-safe",
                "0",
                "-i",
                "/storage/emulated/0/DCIM/my_file.txt",
                "-c:v",
                "-preset",
                "fast",
                "-crf",
                "22",
                "copy",
                "-flags",
                "+global_header",
                "/storage/emulated/0/DCIM/SampleApp/" + videoOutputPath
        };

Please help! Thanks much.

Best Answer

Got the solution:

I missed some options as I am a newbie with ffmpeg:

Final command:

command = new String[]{"-y",
                "-f",
                "concat",
                "-safe",
                "0",
                "-i",
                "/storage/emulated/0/DCIM/my_file.txt",
                "-c:v",
                "libx264",
                "-preset",
                "ultrafast",
                "-crf",
                "28",
                "-c:a",
                "copy",
                "-flags",
                "+global_header",
                "/storage/emulated/0/DCIM/SampleApp/" + videoOutputPath
        };

Where "-preset ultrafast is one option to increase the encoding speed, along with CRF 28".