tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

Using -filter_complex in ffmpeg command video quality is bad of generated output. #530

Closed nihkilft123 closed 3 years ago

nihkilft123 commented 4 years ago

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!

jatinder42 commented 4 years ago

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"

divyamsoftwares commented 3 years ago

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

jatinder42 commented 3 years ago

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

tanersener commented 3 years ago

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.

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.

gbhargavv commented 3 years ago

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

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.