简体   繁体   中英

FFmpeg scaling error

I'm trying to convert video on Android using FFmpeg Android Java library My method takes input and output file pathes and dimentions of output file (for instance 640x480). Video should fit crop these bounds. As video might be in landscape or portrait orientation I'm next params:

String.format("-i %s \"scale='if(gt(a,1),-1,%d)':'if(gt(1,a),%d,-1)'\" %s", in, h, w, out);

see this article

according to official doc a is aspect ration (w/h) of input file.

So a > 1 gt(a,1) means w > h so video is landscape, and 1 > a gt(1,a) means h > w so video is portrait.

But I'm getting next error:

Unable to find a suitable output format for "scale='if(gt(a,1),-1,480)':'if(gt(1,a),640,-1'"
'"scale='if(gt(a,1),-1,480)':'if(gt(1,a),640,-1'" : Invalid argument

What am I doing wrong ? Thanks.

You need -vf before the scale filter. It parses the scale filter as an output file. So:

-i %s -vf \"scale='if(gt(a,1),-1,%d)':'if(gt(1,a),%d,-1)'\" %s

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM