[FFmpeg-trac] #732(undetermined:new): Storing variables not working in expressions

FFmpeg trac at avcodec.org
Sat Dec 10 22:12:59 CET 2011

#732: Storing variables not working in expressions
             Reporter:  jworrall     |                    Owner:
                 Type:  enhancement  |                   Status:  new
             Priority:  normal       |                Component:
              Version:  unspecified  |  undetermined
             Keywords:  expression   |               Resolution:
  evaluation                         |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |

Comment (by jworrall):

 Oh, well, that explains a lot.  It seems the variables would be more
 powerful if they could be shared between expressions.  For example, I am
 trying to write a scale filter that will scale a video of any size and
 aspect ratio down (but not up) to fit inside an iPhone display, while
 preserving aspect ratio.  I've written a script that gets variables for
 the display/frame size depending on which iPhone it is (FW, FH and the
 aspect ratio FA).

 I was eventually able to do it without variables; it looks like this:
 -vf "scale = min(1\,gt(iw\,$FW)+gt(ih\,$FH)) * (gte(a\,$FA)*$FW +
 lt(a\,$FA)*(($FH*iw)/ih)) + not(min(1\,gt(iw\,$FW)+gt(ih\,$FH)))*iw : \
 min(1\,gt(iw\,$FW)+gt(ih\,$FH)) * (lte(a\,$FA)*$FH +
 gt(a\,$FA)*(($FW*ih)/iw)) + not(min(1\,gt(iw\,$FW)+gt(ih\,$FH)))*ih" \

 If the variables were preserved between the width and height expressions,
 it would be somewhat shorter and easier to follow:
 -vf "scale = st(0\,min(1\,gt(iw\,$FW)+gt(ih\,$FH) ) ) * (gte(a\,$FA)*$FW +
 lt(a\,$FA)*(($FH*iw)/ih) ) + not(ld(0))*iw : \
 ld(0) * ( lte(a\,$FA)*$FH + gt(a\,$FA)*(($FW*ih)/iw) ) + not(ld(0))*ih " \

 Maybe it's not that important, but I'm sure more 'global' variables would
 have other uses as well.  In any case, unless and until such a feature is
 developed, it would be good to put in the manual that the variables are
 not preserved between expressions.  Might save someone else several days
 of tearing their hair out!  Thanks

Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/732#comment:3>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list