output video has black..whats wrong in this command? - android

i want add text over video and i am using ffmpeg android lib but edited successfully but output video shows me black screen only
String addtextcommand[] = {
"-i",
inputpath,
"-strict",
"-2",
"-vf",
"drawtext=text=\'onLine1\': fontcolor=white", "-map", "0:a",
"-codec:v", "libx264", "-codec:a", "copy",
output
};

I am not going to give you and solution I prefer to figure out your command and find a solution by your self I m going to explain you command here
-i inputpath --> for Input (Video/GIF/IMAGES/MUSIC)
-strict -2 --> strictly conform to all the things in the spec no matter what consequences -2 for experimental
-vf --> for videofilter alternativaly you can use -filter_complex
drawtext=text='onLine1': fontcolor=white --> for draw text over on any med file like image or video
-map 0:a --> to map out with 1'st input auido 0:a stands for 1'st input audio
-codec:v --> for video codec
libx264 ---> specify video codec
-codec:a copy --> for audio codec , here you get audio codec from input copy stand s fro get codc from input
output --> final Output
try below code:
-i video.mp4 -filter_complex "drawtext=text=Vinesh Chauhan:fontcolor=#000000:fontsize=14:x=43:y=103:fontfile=FACEBOLF.OTF" -y output.mp4
for android your command should be
String[] cmd = new String[]{"-i",""+inputpath, "-filter_complex", "drawtext=text=Vinesh Chauhan:fontcolor=#000000:fontsize=14:x=43:y=103:fontfile="+fontPATH, "-y" ,""+outputpath};
now i think you can find your solution by your self if any query comment below will surely help you

The problem is in "-map", "0:a" you are ignoring video from inputpath. Try command without that.

Related

How to make a video which can play/loop infinite times using FFMPEG command in Android?

Here are some details: I have a main video and I want a view (gif or video) on it which plays infinite times till video ends. Here is my current code snippet which executes successfully which plays my overlay video one time only.
cmd = new String[]{"-y", "-i", String.valueOf(mVideoPath), "-i", tempVideoPath, "-filter_complex", overlay.toString(), "-codec:a", "copy", "-preset", "ultrafast", String.valueOf(file)};
Where tempVideoPath is the path of my overlay video.
Use the -stream_loop input option:
ffmpeg -i main.mp4 -stream_loop -1 -i loop.mp4 -filter_complex "[0][1]overlay=shortest=1:format=auto,format=yuv420p[v]" -map "[v]" -map 0:a? -preset ultrafast -c:a copy -movflags +faststart output.mp4

how to convert video in format 1:1 and 9:16 using ffmpeg in android?

I have used the below command.
strings = new String[]{"-y", "-i", tempOriginalVideoPath, "-r", "15", "-aspect", "1:1", "-strict", "-2", tempEditVideoPath}
it's not working default system camera recorded video.
You can use the FFmpeg library (http://Writingminds.github.io/ffmpeg-android-java)
The command needs to be splitted using .split(" ");
final String[] cmd = "-i /storage/emulated/0/Your.mp4 -vf crop=640:256:0:400 -threads 5 -preset ultrafast -strict -2 /storage/emulated/0/YourCroppedMovie.mp4".split(" ");
Example use -vf crop=1080:1080:0:0 to crop the video to a square. (Without messing up the ratio)
Hope it helps you

FFMpeg Text Animation

How to add text with animation on video in ffmpeg?
Now I am trying to add video management function on android app.
If you have a experiences on it, please help me.
I added the visible, marquee,several text lines animation on video in ffmpeg.
It works well.
Here is my code.
ffmpeg -i input.mp4 -vf "[in]drawtext=fontfile=/path/to/font.ttf: text='First Line': fontcolor=red: fontsize=40: x=(w-text_w)/2: y=if(lt(t\,3)\,(-h+((3*h-200)*t/6))\,(h-200)/2):enable='between(t,2.9,50)',drawtext=fontfile=/path/to/font.ttf: text='Second Line': fontcolor=yellow: fontsize=30: x=if(lt(t\,4)\,(-w+((3*w-tw)*t/8))\,(w-tw)/2): y=(h-100)/2:enable='between(t,3.5,50)',drawtext=fontfile=/path/to/font.ttf: text='Third Line': fontcolor=blue: fontsize=50: x=if(lt(t\,5)\,(2*w-((3*w+tw)*t/10))\,(w-tw)/2): y=h/2:enable='between(t,4.5,50)',drawtext=fontfile=/path/to/font.ttf: text='Fourth Line': fontcolor=black: fontsize=20: x=(w-text_w)/2: y=if(lt(t\,6)\,(2*h-((3*h-100)*t/12))\,(h+100)/2):enable='between(t,5.5,50)'[out]" out.mp4
Here "input.mp4" is your input video file and it will output with the name "out.mp4"

Create video from images, add audio and animation within images without FFMPEG in Android

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

ffmpeg overlay issue with rotation

I want to execute a command using ffmpeg so it performs three tasks for me at once:
croping the video (OK)
rotate the video for 90° (OK) and
add an overlay
Unfortunately, the tasks 1 and 2 are performed, but the overlay isn't. Please help me.. Here's the command I'm using:
ffmpeg -i " + path + " -i /storage/emulated/0/image.png -filter_complex [0]crop=" + cut + ":" + cut + ":0:0 -metadata:s:v:0 rotate=90 -c:a [a];[a][1]overlay=10:10 -preset ultrafast -codec:a copy /storage/emulated/0/Nitin/" + videoFile;
By using the options -metadata:s:v:0 rotate=90, you were settings the rotate matrix in your video stream.
It seems your filters are not chained in your filter graph. You could achieve all your goals in a filter chain.
[in] ---> crop ---> transpose ---> overlay ---> [out]
^
|
---> movie -----------------|
The filter graph showed above can be specified with -vf option like below.
ffmpeg -i input.mp4 -vf "crop=200:200:12:34,transpose=1 [ct];movie=/path/to/the/overlay/image.png [movie];[ct] [movie]overlay=(W-w)/2:(H-h)/2" -c:a copy -c:v libx264 output.mp4
You should change crop parameters to yours, the transpose filter with 1 parameter will rotate clock wise by 90 degree, see here for more information.
Also change the movie filter parameter to the path of your image.
At last, these two outputs will centred overlay to generate final output.

Categories

Resources