Video Compression using ffpmeg - android

I am using ffmeg for video compression. I have used ffpmeg library
Use command "ffmpeg -i " + filein.trim() + " -vcodec h264 -acodec mp2 " + fileout.trim() but i doesn't respond anything.
I have used any ndk library for first time.

Use this command will work for you. This works for me .
String cmd = "-y -i " + currentInputVideoPath + " -strict -2 -vcodec libx264 -preset ultrafast " + "-crf 24 -acodec aac -ar 44100 -ac 2 -b:a 96k -s 320x240 -aspect 4:3 " + currentOutputVideoPath;

Related

Add fade effect between video and png image FFMPEG android

By using below command we can merge video and image together. I not an expert to build ffmpeg commands.
String cmd = "-t 5 -i " + videoPath +
" -loop 1 -t 5 -i " + imagePath +
" -f lavfi -t 5 -i anullsrc" +
" -filter_complex [1][0]scale2ref[2nd][ref];[ref][0:a][2nd][2:a]concat=n=2:v=1:a=1[v][a]" +
" -c:v libx264 -c:a aac -strict -2 -map [v] -map [a] -preset veryfast " + outputPath;
Any one who have idea to add a transition effect between video and image.
Please help me.
Thanks in advance.

How to reduce video compression process time?

I have used FFMPEG for video compression but it is taking too much time. Is there any solution to reduce video compression process time?
I have used below command,
String cmd = "-i " + inputFile + " -c:v libx264 -crf 23 -c:a aac -b:a 128k -movflags +faststart -preset ultrafast " + outputFile;

add mp3 sound using ffmpeg on android

I'm trying to make a mp4 from an app on Android, to do so i added the FFmpeg binary.
to create the mp3 i use a command :
ffmpegBinaryPath + " -r 24 -i " + inputImgPath + " -c:v libx264 -crf 23 -pix_fmt yuv420p -s 640x480 " + outputVideoPath;
But i want to add sound on this mp4 i use :
ffmpegBinaryPath + " -r 24 -i " + inputImgPath + " -i " + mp3Path + " -c:v libx264 -crf 23 -pix_fmt yuv420p -s 640x480 " + outputVideoPath;
But it does not work i have no error message and FFmpeg stop at the beginning.
I think i need a mp3 code or something like but i can't fin a way to make it works.
So any help will be appreciated.
Thank you.

Android ffmpeg apply video effects take log time

I am using below command to apply effect,its take 6-8 minutes to apply effect for 2 min video. Please help me to improve effective time for ffmpeg commands.
String commandStr = "ffmpeg -y -i "
+ mVideoData.getPath()
+ " -strict experimental -vf curves=vintage -s 640x480 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k -vcodec mpeg4 /sdcard/videokit/curve.mp4";

Add path to ffmpeg

I am playing with video compression by using ffmpeg. I can compress the video e.g. with this line:
String commandStr = "ffmpeg -y -i /sdcard/videokit3/Dani.mp4 -strict experimental -s 320x240-r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 512k /sdcard/videokit3/Dani2.mp4";
In this line the path is hardcoded, so I did
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "videokit3/Dani.mp4";
which results in /mnt/sdcard/videokit3/Dani.mp4
This seems to be different from /sdcard/videokit3/Dani.mp4 so this line runs to error (I see the difference, I just don't get it):
String commandStr = "ffmpeg -y -i " + path + " -strict experimental -s 320x240 -r 30 -ab 48000 -ac 2 -ar 22050 -b 512k /sdcard/videokit3/Dani4.mp4";
Can you help?
The easiest way to get around would be replace the string and trim "/mnt" out before inserting into the statement. The reason why the external SDcard absolute path returns as "mounted" drive is available here on SO: stackoverflow.com/a/5695129/2777098

Categories

Resources