scaling a video captured in portrait mode using FF

2019-09-05 18:08发布

问题:

I'm trying to rotate a video on my android app using FFMPEG and then uploading it to the server. The following command does the job for me:

-y -noautorotate -i inputPath -vf transpose=1,scale=360:640,setsar=1 -metadata:s:v rotate=0

The aspect ratio of the original video is 16:9. I'm trying to maintain the aspect ratio after rotation so I add padding on either side of the video to scale it properly with the following command:

-y -noautorotate -i inputPath -vf transpose=1,scale=iw*min(360/iw\,640/ih):ih*min(360/iw\,640/ih),pad=640:360:(360-iw)/2:(640-ih)/2,setsar=1 -metadata:s:v rotate=0

The video scales perfectly on the website but now the issue is that I can see the black bit when I play it on the android app which I don't want. I don't mind the black bits when I play the video on the website but on the app, it looks terrible. The container of the video on the app has height "280dp" and width of "380dp". How can I scale the video so the black sides don't show when I play a video on the app. Any solutions/suggestions?

This is what the video looks like when I play on the website:

This is what it looks like on the app