Android ffmpeg apply video effects take log time - android

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";

Related

FFmpeg stucks for few seconds on start

I'm trying to cut and resize video on Android(but it is similar on MacOS) , but when I run the ffmpeg command it returns me
frame= 0 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed=
It repeats for about 20 sec (I have 4K video with 3 sec duration).
Is there any way to improve process speed? Here is example of my ffmpeg command
ffmpeg -y -i input.mp4 -ss 00:01.82 -to 00:02.94 -vf scale=500:1024 -c:v libx264 -c:a aac -b:v 500k -b:a 96k output.mp4
Use of -ss after the input performs a decoded frame seek, which is slower. Switch to demuxer seek
ffmpeg -y -ss 00:01.82 -to 00:02.94 -i input.mp4 -vf scale=500:1024 -c:v libx264 -c:a aac -b:v 500k -b:a 96k output.mp4
-to for demuxer was only recently added, so get a current git version. Else, use -t with the calculated duration.

Video Compression using ffpmeg

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;

FFmpeg converting two videos with dynamic frame rates - dup/drop frames

I have problems with converting two videos using ffmpeg. Those videos have dynamic frame rate. I'm using this ffmpeg command:
ffmpeg -y -i /storage/emulated/0/Movies/RMR/RMR_camera_2017-10-04-20-42-56.mp4 -i /storage/emulated/0/Movies/RMR/RMR_screen_2017-10-04-20-42-56.mp4 -strict experimental -preset ultrafast -filter_complex [0]scale=iw/4:ih/4[pip];[pip]transpose=2[rotate];[1][rotate]overlay=main_w-overlay_w-30:main_h-overlay_h-10 -profile:v main -level 3.1 -ar 44100 -b:a 160k -crf 20 -s 720x1280 -vcodec h264 -vsync 2 -acodec aac -movflags +faststart /storage/emulated/0/Movies/RMR/out.mp4
I'm using -vsync to drop duplicated frames. This is not good enough, video is with freezing frames. How can I prevent freezing?
Setting a constant frame rate for the two would do
ffmpeg -i ... -i ... -lavfi '[0:v]fps=24000/1001[v1];[1:v]fps=24000/1001[v2];other_filters...' ...

ffmpeg video rotation issue

I am using ffmpeg library to compress video and upload it to server.
My problem is :
Video is saved with perfect rotation in storage but when I upload it to server it gets 90degree rotated.
Command is:
setCommand("ffmpeg -y -i /sdcard/videokit/" + NetworkStatus.OrderNo
+ ".mp4 -strict experimental -vcodec libx264 -preset ultrafast -crf 24 -acodec aac -ar 44100 -ac 2 -b:a 96k -s 320x240 /sdcard/videokit/" + NetworkStatus.OrderNo + "out.mp4");
Can you please help me to get out of this. I need to show video in portrait mode only if I have captured video in portrait.
Thanks

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