Mobile-ffmpeg: Using -filter_complex in ffmpeg command video quality is bad of generated output.

Created on 20 Aug 2020  ·  5Comments  ·  Source: tanersener/mobile-ffmpeg

I am currently try to use your implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.4.LTS' library in my app. Well you mentioned that in this version of library all third party library available in full-gpl version, but video quality is very bad after generating output using -filter_complex in command!
Here is sample command may help you:

ffmpeg -t 25 -i image1.jpg -i image2.jpg -i image3.jpg -i image4.jpg -i image5.jpg -i alpha_video.mp4 -filter_complex "[5]split=2[color][alpha]; [color]crop=iw/2:ih:0:0[color]; [alpha]crop=iw/2:ih:iw/2:ih[alpha]; [color][alpha]alphamerge[v1]; [0]scale=540:960, setsar=1[v2]; [v2]zoompan=z='if(lte(zoom,1.0),1.2,max(1.001,zoom-0.0025))':d=25*5:s=540x960, fade=t=out:st=5:d=1, format=yuv444p[v2]; [1]scale=540:960, setsar=1[v3]; [v3]zoompan=z='if(gte(zoom,1.2),1.0,min(zoom+0.0015,1.2))':d=25*5:s=540x960, fade=t=in:st=0:d=1, fade=t=out:st=10:d=1, format=yuv444p[v3]; [2]scale=540:960, setsar=1[v4]; [v4]zoompan=z='if(lte(zoom,1.0),1.2,max(1.001,zoom-0.0025))':d=25*5:x='540':s=540x960, fade=t=in:st=0:d=1, fade=t=out:st=15:d=1, format=yuv444p[v4]; [3]scale=540:960, setsar=1[v5]; [v5]zoompan=z='if(gte(zoom,1.2),1.0,min(zoom+0.0015,1.2))':d=25*5:x='540':s=540x960, fade=t=in:st=0:d=1, fade=t=out:st=20:d=1, format=yuv444p[v5]; [4]scale=540:960, setsar=1[v6]; [v6]zoompan=z='if(lte(zoom,1.0),1.2,max(1.001,zoom-0.0025))':d=25*5:x='540':s=540x960, fade=t=in:st=0:d=1, format=yuv444p[v6]; [v2][v3][v4][v5][v6]concat=n=5:v=1:a=0, format=yuv444p[comb_vd]; [comb_vd][v1] overlay=1" output_video.mp4 -y

After seen this command you may ask me to why are you using such a complex ever command, but I may told you we are using currently bravobit's library and which is execute this command and generated video quality is good! So, is there other version to compatible with this command or there is something problem in library which
is giving poor quality of video? We are moving to your library because bravobit's library is no more in android target 10 & 11. So, we need to solve this issue in this library!

ffmpeg-question missing-issue-template

Most helpful comment

@nihkilft123 @divyamsoftwares @jatinder42
You can improve video quality by add "-vb" and "20M" Before outputpath in command.

All 5 comments

Hi, i am also facing same issue, please help.
I was using http://writingminds.github.io/ffmpeg-android-java/ earliar, same command is working in this library, but output quality is low.

Command : "-y -i /storage/emulated/0/Merge/Segment1.mp4 -i /storage/emulated/0/Merge/Segment2.mp4 -filter_complex [1:v]fade=type=in:duration=1[v1];[0:v][0:a][v1][1:a] concat=n=2:v=1:a=1 [outv][outa] -map [outv] -map [outa] -ab 48000 -ac 2 -ar 22050 -preset ultrafast /storage/emulated/0/Merge/1598531169.mp4"

Facing same issue @nihkilft123 @jatinder42 could you please help me to find solution of this

I didn't find any solution So I used MP4Parser to join videos and scaling is done at server end after uploading.

See #132. Issues with missing issue template fields are ignored. This is why this issue was ignored before and why similar issues will be ignored in the future.

Regarding this question.

  • Console output explains everything, including why there is a quality drop in your videos.
  • Try to understand what console output tells. See my comment at one of my side projects. https://github.com/tanersener/react-native-ffmpeg/issues/158#issuecomment-626560548.
  • Most of the time, the problem is:

    • You don't specify an output video codec using -c:v, so ffmpeg chooses the codec for your output video itself

    • mobile-ffmpeg package you use does not include libx264 inside and ffmpeg chooses mpeg4 for your output video

    • Since mpeg4 has worse quality than h264, your output video has poor quality compared to your input video

The solution is to use one of the GPL licensed packages. They include libx264 inside and can encode h264 videos. Also, specify the output video codec using -c:v to ensure that your output video is always encoded in h264.

But I don't know whether this is the case for each of the incidents reported here. Because none of them includes console output. This is why we have #132.

@nihkilft123 @divyamsoftwares @jatinder42
You can improve video quality by add "-vb" and "20M" Before outputpath in command.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tim162 picture tim162  ·  5Comments

khacchungory picture khacchungory  ·  7Comments

shaheercs picture shaheercs  ·  6Comments

chitrang200889 picture chitrang200889  ·  5Comments

krislyy picture krislyy  ·  5Comments