Zoom out/scale down dynamically

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Zoom out/scale down dynamically

astian
Hello,

I want to dynamically (per frame) zoom out/scale down a video below 100% size.
It seems that the zoompan filter would be ideal for this case, but
unfortunately it clamps the zoom ratio to [1,10], that is, it only zooms
in/scales up.  Why?  And what can I use instead?

Thanks.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

Gyan Doshi
On Mon, Sep 10, 2018 at 9:34 AM astian <[hidden email]> wrote:

>
> I want to dynamically (per frame) zoom out/scale down a video below 100%
> size.
> It seems that the zoompan filter would be ideal for this case, but
> unfortunately it clamps the zoom ratio to [1,10], that is, it only zooms
> in/scales up.  Why?  And what can I use instead?
>

What's the intended use of the image after dynamic scaling?

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

Carl Eugen Hoyos-2
In reply to this post by astian
2018-09-10 6:04 GMT+02:00, astian <[hidden email]>:

> I want to dynamically (per frame) zoom out/scale down
> a video below 100% size.

Isn't it sufficient to pad first, and use zoompan in a later
filter?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

astian
In reply to this post by Gyan Doshi
Gyan:

> On Mon, Sep 10, 2018 at 9:34 AM astian <[hidden email]> wrote:
>
>>
>> I want to dynamically (per frame) zoom out/scale down a video below 100%
>> size.
>> It seems that the zoompan filter would be ideal for this case, but
>> unfortunately it clamps the zoom ratio to [1,10], that is, it only zooms
>> in/scales up.  Why?  And what can I use instead?
>>
>
> What's the intended use of the image after dynamic scaling?

In this particular case, blend/concat to another video stream.

Cheers.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

astian
In reply to this post by Carl Eugen Hoyos-2
Carl Eugen Hoyos:> 2018-09-10 6:04 GMT+02:00, astian <[hidden email]>:
>
>> I want to dynamically (per frame) zoom out/scale down
>> a video below 100% size.
>
> Isn't it sufficient to pad first, and use zoompan in a later
> filter?

Do you mean work in reverse? Scale down, pad, zoompan in reverse, then reverse
the frames??

If that's what you mean, then there are 2 problems:
  1. It would have bad quality because it starts from a smaller video, the
     smallest in fact.
  2. It's a Rube Goldberg machine.

Cheers.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

Carl Eugen Hoyos-2
2018-09-13 3:28 GMT+02:00, astian <[hidden email]>:

> Carl Eugen Hoyos:> 2018-09-10 6:04 GMT+02:00, astian <[hidden email]>:
>>
>>> I want to dynamically (per frame) zoom out/scale down
>>> a video below 100% size.
>>
>> Isn't it sufficient to pad first, and use zoompan in a later
>> filter?
>
> Do you mean work in reverse? Scale down, pad, zoompan
> in reverse, then reverse the frames??

No, only pad and zoompan.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

astian
Carl Eugen Hoyos:

> 2018-09-13 3:28 GMT+02:00, astian <[hidden email]>:
>> Carl Eugen Hoyos:> 2018-09-10 6:04 GMT+02:00, astian <[hidden email]>:
>>>
>>>> I want to dynamically (per frame) zoom out/scale down
>>>> a video below 100% size.
>>>
>>> Isn't it sufficient to pad first, and use zoompan in a later
>>> filter?
>>
>> Do you mean work in reverse? Scale down, pad, zoompan
>> in reverse, then reverse the frames??
>
> No, only pad and zoompan.

Well, I'm not sure what you mean. Pad doesn't seem very dynamic to me, I
know that it has an eval=frame option, but according to the manual there
is no frame-number variable that I could exploit.

Do elaborate, please.

Cheers.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

Gyan Doshi
On Fri, Sep 14, 2018 at 9:29 AM astian <[hidden email]> wrote:

>
>
> Well, I'm not sure what you mean. Pad doesn't seem very dynamic to me, I
> know that it has an eval=frame option, but according to the manual there
> is no frame-number variable that I could exploit.
>

Pad the video beforehand, usually with a transparent colour, then use
zoompan. Since your new frame is much larger, you can simulate a zoom-out
of the image, since with the padding, your zoom value doesn't need to drop
below 1.

However, you can't output these frames of differing sizes, as ffmpeg will
resize them to a fixed size prior to encoding. However, you can use them in
overlay, where the transparent padding gets hidden and you get the
effective result.

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

astian
Gyan:

> On Fri, Sep 14, 2018 at 9:29 AM astian <[hidden email]> wrote:
>
>> Well, I'm not sure what you mean. Pad doesn't seem very dynamic to
>> me, I know that it has an eval=frame option, but according to the
>> manual there is no frame-number variable that I could exploit.
>
> Pad the video beforehand, usually with a transparent colour, then use
> zoompan. Since your new frame is much larger, you can simulate a
> zoom-out of the image, since with the padding, your zoom value doesn't
> need to drop below 1.
>
> However, you can't output these frames of differing sizes, as ffmpeg
> will resize them to a fixed size prior to encoding. However, you can
> use them in overlay, where the transparent padding gets hidden and you
> get the effective result.

After RTFM carefully, noticing the size parameter on zoompan, and
experimenting a bit, I think I understand you (except for the part about
'differing sizes').  I can zoom out of a video of dimensions D_i up to a
ratio R < 1 by first padding each dimension to D_i/R and then choosing a
zoom value of 1 and setting the size to D_i, zoompan will crop/scale the
video appropriately.

For example, this should progressively zoom out the test video to 20% of
the original size.

s=800x600
r=25
t=10
minz=0.2
padr=$(bc <<<"scale=4; 1/$minz")
ffmpeg -f lavfi -i "testsrc=r=$r:s=$s" -filter_complex  \
       "[0:v] pad= w=$padr*iw : h=$padr*ih : x=(ow-iw)/2 : y=(oh-ih)/2,
              zoompan= z=$padr-($padr-1)*(on-2)/($r*$t-1) :
                       x=(iw-iw/zoom)/2 :
                       y=(ih-ih/zoom)/2 :
                       d=1 : s=$s : fps=$r [vo]"  \
       -map '[vo]' -t 10 -c:v libx264 -crf 22 -y foo.mkv

One issue I discovered with this method is that the more I need to zoom
out, the more I need to increase the size of the original video, which
makes ffmpeg slower.

Still, my original 'why' question remains.  Why not directly allowing
zoom ratios < 1?  Do I have to ask in ffmpeg-devel?

Thanks.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Zoom out/scale down dynamically

Carl Eugen Hoyos-2
2018-09-17 16:37 GMT+02:00, astian <[hidden email]>:

> Still, my original 'why' question remains.  Why not directly
> allowing zoom ratios < 1?

padding is free compared to zoompan and zoompan wouldn't
know what to show outside of the original video.
(Paul may correct me here.)

> Do I have to ask in ffmpeg-devel?

Only if you plan to send a patch.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".