diff mbox series

[FFmpeg-devel] fftools/ffmpeg_filter: set keep_aspect to true for the crop filter

Message ID 20240709190626.41550-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] fftools/ffmpeg_filter: set keep_aspect to true for the crop filter | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer July 9, 2024, 7:06 p.m. UTC
The input sample aspect ratio applies to the pre-cropping dimensions, so update it.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/ffmpeg_filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anton Khirnov July 10, 2024, 8:29 a.m. UTC | #1
Quoting James Almer (2024-07-09 21:06:26)
> The input sample aspect ratio applies to the pre-cropping dimensions, so update it.

I don't understand this reasoning, why should cropping a video change
pixel aspect ratio?
James Almer July 10, 2024, 11:20 a.m. UTC | #2
On 7/10/2024 5:29 AM, Anton Khirnov wrote:
> Quoting James Almer (2024-07-09 21:06:26)
>> The input sample aspect ratio applies to the pre-cropping dimensions, so update it.
> 
> I don't understand this reasoning, why should cropping a video change
> pixel aspect ratio?

You're right, this patch is not ok. I noticed the display aspect ratio 
was preserved with this option, but this is not intended by the container.
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 097bd2ed48..0d85c30aba 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1703,7 +1703,7 @@  static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
 
     if ((ifp->opts.flags & IFILTER_FLAG_CROP)) {
         char crop_buf[64];
-        snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d:x=%d:y=%d",
+        snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d:x=%d:y=%d:keep_aspect=1",
                  ifp->opts.crop_left, ifp->opts.crop_right,
                  ifp->opts.crop_top, ifp->opts.crop_bottom,
                  ifp->opts.crop_left, ifp->opts.crop_top);