ffmpeg-android-java icon indicating copy to clipboard operation
ffmpeg-android-java copied to clipboard

Video conversion/compression is too slow.

Open momersaleem opened this issue 8 years ago • 18 comments

Hi, I am compressing .mp4 (3 minutes video) of size 368.2MB using following command: ffmpeg -y -i /storage/emulated/0/DCIM/Camera/20151119_200558.mp4 -strict experimental -vcodec libx264 -r 30 -acodec aac -ar 44100 -ac 1 -b:a 64k -b:v 790k /storage/emulated/0/output.mp4

It takes too long (I waited for 1 hour and more but still it's still compressing and I closed app). Please help me out how can I speed it up but I want better quality.

Thanks, momersaleem

momersaleem avatar Nov 20 '15 15:11 momersaleem

I ran into same issue here. I suspect making up a service may help since main thread is in charge of UI drawing, etc.

It's only a guess, in fact I'll try this option and then share my discoveries.

joshuamzm avatar Nov 30 '15 06:11 joshuamzm

* Overlaying two videos of around max 15 seconds** I am also facing same issue. Even for a 5 second video the processing time is around 1 minute. We are using service with a handlerthread, but still we are facing the issue. Please Help.

gupta-vikash avatar Jan 06 '16 15:01 gupta-vikash

Hello All, I was facing the same problem. and i found one solution.

add following before output -c:v libx264 -preset ultrafast

it will help to decrease processing time.

gupta-vikash avatar Jan 11 '16 13:01 gupta-vikash

Hi.. I am using

-y -i /sdcard/videokit/in.mp4 -strict experimental -vcodec libx264 -preset ultrafast -crf 24 -acodec aac -ar 44100 -ac 2 -b 36000k -s 1280x720 -aspect 16:9 -metadata:s:v:0 rotate=0 /sdcard/videokit/out3.mp4 command. It reduce the compression time little.

Vijayadhas avatar Jan 29 '16 13:01 Vijayadhas

Also noticed that, conversion is very slow. Fortunately "-preset ultrafast" helped a lot.

mateusgrb avatar Jan 30 '16 11:01 mateusgrb

This command make video processing really fast -c:v libx264 -preset ultrafast I am working on slowing video playback.

amna-mirza avatar Jun 02 '16 07:06 amna-mirza

Hi I have used below command but right now its display '-preset' Unrecognized option. -y -i /sdcard/videokit/in.mp4 -strict experimental -vcodec libx264 -preset ultrafast -crf 24 -acodec aac -ar 44100 -ac 2 -b 36000k -s 1280x720 -aspect 16:9 -metadata:s:v : 0 rotate=0 /sdcard/videokit/out3.mp4

sanjaysiliconithub avatar Jul 20 '16 09:07 sanjaysiliconithub

Hi, I too had the same issue with "-preset ultrafast" command. Here is the error from log:

Reading option '-preset' ...Unrecognized option 'preset'. Error splitting the argument list: Option not found ffmpeg4android: ffmpeg_parse_options not passed exit_program: 1

rt1909 avatar Jul 28 '16 06:07 rt1909

Hi rt1909 i think in android library there are "-preset ultrafast " not supported if you found than please replay hear.

sanjaysiliconithub avatar Jul 28 '16 07:07 sanjaysiliconithub

Hi Sanjay,

I have checked it. In the blog post they mentioned about using the "-preset ultrafast" in combination with mpeg4 codec. But it seems it works only with libx264.

On Thu, Jul 28, 2016 at 12:49 PM, Sanjay Bhalani [email protected] wrote:

Hi rt1909 i think in android library there are "-preset ultrafast " not supported if you found than please replay hear.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WritingMinds/ffmpeg-android-java/issues/54#issuecomment-235818729, or mute the thread https://github.com/notifications/unsubscribe-auth/ATeQKl0yAV5dTveyIav9K4I3tyZrpHOgks5qaFgHgaJpZM4Gmb_F .

rt1909 avatar Jul 29 '16 08:07 rt1909

Hi rt1909 Yes but in my case it's seem to taken to much time for compressed video also decries video quality. Below command is working fine with same quality, but it's also take 30 to 50 second for compressing any video.

"ffmpeg -y -i in.mp4 -strict experimental -r 30 -ab 48000 -ac 2 -ar 48000 -vcodec mpeg4 -b 2097152 out.mp4"

sanjaysiliconithub avatar Jul 29 '16 12:07 sanjaysiliconithub

Hello All, I was facing the same problem. and my video is 12 second and it will take long time to compress , i need it will complete within 12-15 second .

i am using below command with video size 45mb and 12 second.

"ffmpeg -y -i /sdcard/videokit/input.mp4 -s 320x240 -r 20 -c:v libx264 -preset ultrafast -c:a copy -me_method zero -tune fastdecode -tune zerolatency -strict -2 -b:v 1000k -pix_fmt yuv420p /sdcard/videokit/123out.mp4";

Please help me to complete this compressor in 12-15 second.

anilpthummar avatar Aug 23 '16 05:08 anilpthummar

anyone please help me to solve the issue.

Unable to find a suitable output format for 'ffmpeg' ffmpeg: Invalid argument

tried many ways and also change commands but still the same issue

"ffmpeg -y -i "+path+" -s 320x240 -r 20 -c:v libx264 -preset ultrafast -c:a copy -me_method zero -tune fastdecode -tune zerolatency -strict -2 -b:v 1000k -pix_fmt yuv420p "+outputFilePath;

input and output format is mp4.i want to compress the video

lakkad-amish avatar Aug 08 '17 04:08 lakkad-amish

try this

ffmpeg -i /storage/emulated/0/Movies/Instagram/VID_219920217_214928_732.mp4 -vf scale=-1:480.0 -threads 16 -c:v libx264 -maxrate 1984k -bufsize 3968k -ac 2 -vf format=yuv420p -g 60 -c:a aac -b:a 128k -ar 44100 -movflags +faststart -profile:v baseline -level 3.1 -crf 28 -preset ultrafast -strict -2 /storage/emulated/0/Android/data/com.staze/cache/1514433292621.mp4

Working fine for me using compile 'com.writingminds:FFmpegAndroid:0.3.2'

vikrammittal avatar Dec 28 '17 03:12 vikrammittal

What is -b:v stands for if bitrate how setting -b:v 1000k decrease the process time

mwshubham avatar Aug 02 '18 16:08 mwshubham

What is -b:v stands for if bitrate how setting -b:v 1000k decrease the process time

-b:v means you want to alter bitrate of the video stream. -v:b 1000k means that in the output video, the bitrate of video stream will be 1000 bps. It should decrease processing time becuase the bitrate is low.

Nasib555 avatar Apr 15 '20 13:04 Nasib555

/usr/bin/ffmpeg -y -i /var/www/vod/storage/app/public/temp/GIbSMv9DcueO2maksuvZ6ZeWvGcSiDI4RMtn4qzB.mp4 -map 0 -flags -global_header -f segment -segment_format mpeg_ts -segment_list /var/www/vod/storage/app/public/movies/lopl//nonenc/l69enpRRLtbJuO3wBSbM_1500.m3u8 -segment_time 6 -threads 12 -vcodec libx264 -acodec aac -b:v 1500k -refs 6 -coder 1 -sc_threshold 40 -flags +loop -me_range 16 -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -trellis 1 -b:a 128k -pass 1 -passlogfile /tmp/ffmpeg-passes5f73880a9868fmowmp/pass-5f73880a9881a /var/www/vod/storage/app/public/movies/lopl//nonenc/l69enpRRLtbJuO3wBSbM_1500_%05d.ts

this is my command

but very slow!! i am using php and laravel-ffmpeg

i change thread from 12 to 16 but not effective!

this command use very cpu but not effective ram is very low usage please help me

mehrdadhosseinzadeh avatar Sep 29 '20 19:09 mehrdadhosseinzadeh

Did anyone got the command which is fast for video compression in android. i have been trying to reduce the compression time but nothing seems to be working. if anyone have the way please reply

sahileducateapp avatar Mar 15 '24 12:03 sahileducateapp