I am trying to overlay multiple images to the video at certain time interval...
but the processing time is too much for a video length of 1 minute.
I used VideoKit Library for it.
Here is my code for adding multiple images to Video.
String[] command = {"-i", inputPath,
"-i", imagePath1,"-i", imagePath2,"-i",imagePath3,
"-filter_complex",
"[0][1]overlay=y=H-h:enable='between(t,2,10)'[v1];
[v1][2]overlay=y=H-h:enable='between(t,10,20)'[v2];
[v2][3]overlay=y=H-h:enable='between(t,20,30)'[v3]",
"-map", "[v3]", outputPath};
Is there any faster processing library for video processing.
I just added two more tags to make processing faster.
String[] command = {"-i", inputPath,
\"-i", imagePath1,"-i", imagePath2,"-i",imagePath3,
"-filter_complex",
"[0][1]overlay=y=H-h:enable='between(t,2,10)'[v1];
[v1][2]overlay=y=H-h:enable='between(t,10,20)'[v2];
[v2][3]overlay=y=H-h:enable='between(t,20,30)'[v3]",
"-map", "[v3]",
**"-preset", "ultrafast",** outputPath};
Related
Used concat demuxer in FFMPEG code to concat videos :-
cmd = arrayOf("-y", "-f", "concat", "-safe", "0", "-i", textFile!!.path, "-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", "-c:a", "copy", outputFile.path)
After concatenate finished, the video one played correctly has both audio & video but video two - video is missing has only audio. Output file has size & time duration including two videos.
The textFile contains :-
file '/path/to/file1'
file '/path/to/file2'
Used absolutePath for two mp4 video files.
Tryed this FFMPEG concat video finished but the video missing. But no solution to my problem.
Anything I am missing in the command.
I am using ffmpeg for adding text over video and add overlay image over video in android everything works for me but it takes too long to execute command mostly in long video that more than or equals to 10 sec
String imgcmd[]=new String[]{"-i", inputpath ,"-i",imagepath ,"-filter_complex", "[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10", "-codec:a", "copy",output};
String[] txtcmd = new String[]{"-i",""+inputpath, "-filter_complex", "drawtext=text=Vikram Dulagach:fontcolor=#000000:fontsize=54:x=533:y=503:fontfile="+"/sdcard/retro.ttf", "-y" ,""+output};
I want reduce execution time in ffmpeg
I am using MediaMuxer and MediaExtractor to transcode video. Now i want to add text on video at certain position. How can i achieve this? Basically i am recording video and transcode it in lower resolution now i want to add text overlay without using ffmpeg. I tried to add watermark by using ffmpeg but it takes too much time. I am using this library.This is my command:
String[] complexCommand = {"-y" ,"-i", "/storage/emulated/0/Download/VID.mp4","-strict",
"experimental", "-vf", "movie="
+"/storage/emulated/0/Download/iqm_logo.png [watermark]; [in][watermark] overlay=main_w/2-overlay_w/2:450 [out]",
"-b:v", "1540k", "-c:v", "libx264","-threads","30","-preset","ultrafast","-r", "30","-s", "1080x1920","-c:a", "copy",
"/storage/emulated/0/Download/watermark.mp4"};
I want to create a video from multiple images without using FFMPEG in Android. Also i have to multiple audios over it. And at last there should be some animation within each images. I have tried this using FFMPEG, but it is taking hell lot of time, let say , 4-5 min for 10 photos. Is there any other way for this or any efficient way?
There is 3 way process.
First i create video from each image with audio and added text.
Then i concatenate all the videos into a single video.
At last, i add a background audio to the concatenated video.
I am sharing the commands here:
1.
String[] cmds = {"-y"
, "-r", "1", "-vcodec", "mjpeg" ,"-loop", "1", "-t", "1"
, "-i", image
, "-i", audio
, "-vf"
, "zoompan=z='if(lte(zoom,1),1.1,max(1.001,zoom-0.0015))':d=125,drawbox=y=ih/PHI:color=black#0.4:width=iw:height=120:t=max,drawtext=fontfile=/storage/emulated/0/ffmpeg/font.ttf:text="+text+":fontcolor=white:fontsize=60:x=(w-tw)/2:y=(h/PHI)+th"
, "-c:v", "libx264"
, "-preset", "ultrafast", "-t", "5", "-c:a", "aac", "-b:a", "128k", "-pix_fmt", "yuv420p"
, "video1.mp4"};
2.
String cmd = "-y -i video1.mp4 -i video2.mp4 -i video3.mp4 -filter_complex concat=n=3:v=1:a=1 -preset ultrafast concat_video.mp4;
3.
cmd = "-y -i bg_audio.mp3 -i concat_video.mp4 -shortest -preset ultrafast -filter_complex [a1][a2]amerge,pan=stereo:c0
I am using FFmpeg for video editing in android. I am able to trim, crop and add overlay using below commands:
For trim:
command = new String[]{"-i",inputVideoFilePath,"-ss","00:00:30.0","-c","copy","-t","00:00:10.0",outputVideoFilePath};
For crop:
command = new String[]{"-i",inputVideoFilePath,"-preset", "ultrafast","-filter:v","crop=400:400:0:0","-c:a","copy", outputVideoFilePath};
For overlay:
command = new String[]{"-i",inputVideoFilePath, "-i",overlayImagePath,"-preset", "ultrafast","-filter_complex", "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2", "-codec:a", "copy", outputVideoFilePath};
but I'm unable to merge these commands into a single command.
Please help me.
Use
command = new String[]{"-ss", "00:00:30.0", "-t", "00:00:10.0", "-i",inputVideoFilePath,
"-i",overlayImagePath, "-filter_complex",
"[0]crop=400:400:0:0[a];[a][1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2",
"-preset", "ultrafast", "-codec:a", "copy", outputVideoFilePath};
A filter_complex allows one to perform multiple filtering operations on different inputs in series or in parallel.