diff --git a/Changelog b/Changelog index 2a8dcaa0565507b1615959c6fdc629e8befb2e61..c29d15ac7de2aed141c4a41cbcc335ed2b24d34b 100644 --- a/Changelog +++ b/Changelog @@ -37,6 +37,7 @@ version : - R10k video decoder - ocv_smooth filter - frei0r wrapper filter +- change crop filter syntax to width:height:x:y version 0.6: diff --git a/doc/ffmpeg-doc.texi b/doc/ffmpeg-doc.texi index d9c5c14242519193a49adce8684b136ded0fa66e..e43e87ea0ace5d77371b46b0baffc8c9b2fc04a9 100644 --- a/doc/ffmpeg-doc.texi +++ b/doc/ffmpeg-doc.texi @@ -226,13 +226,13 @@ The following abbreviations are recognized: @item -aspect @var{aspect} Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777). -@item -croptop @var{size} (deprecated - use -vf crop=x:y:width:height instead) +@item -croptop @var{size} (deprecated - use the crop filter instead) Set top crop band size (in pixels). -@item -cropbottom @var{size} (deprecated - use -vf crop=x:y:width:height instead) +@item -cropbottom @var{size} (deprecated - use the crop filter instead) Set bottom crop band size (in pixels). -@item -cropleft @var{size} (deprecated - use -vf crop=x:y:width:height instead) +@item -cropleft @var{size} (deprecated - use the crop filter instead) Set left crop band size (in pixels). -@item -cropright @var{size} (deprecated - use -vf crop=x:y:width:height instead) +@item -cropright @var{size} (deprecated - use the crop filter instead) Set right crop band size (in pixels). @item -padtop @var{size} @item -padbottom @var{size} diff --git a/doc/filters.texi b/doc/filters.texi index 2309c56ac63a8ef0f47f43b572e9b1e900405f62..f934082d9a008dae9a66a5bc2326e862137485e3 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -26,27 +26,27 @@ Below is a description of the currently available video filters. @section crop -Crop the input video to @var{x}:@var{y}:@var{width}:@var{height}. +Crop the input video to @var{width}:@var{height}:@var{x}:@var{y}. @example -./ffmpeg -i in.avi -vf "crop=0:0:0:240" out.avi +./ffmpeg -i in.avi -vf "crop=0:240:0:0" out.avi @end example -@var{x} and @var{y} specify the position of the top-left corner of the -output (non-cropped) area. - -The default value of @var{x} and @var{y} is 0. - The @var{width} and @var{height} parameters specify the width and height of the output (non-cropped) area. A value of 0 is interpreted as the maximum possible size contained in the area delimited by the top-left corner at position x:y. +@var{x} and @var{y} specify the position of the top-left corner of the +output (non-cropped) area. + +The default value of @var{x} and @var{y} is 0. + For example the parameters: @example -"crop=100:100:0:0" +"crop=0:0:100:100" @end example will delimit the rectangle with the top-left corner placed at position diff --git a/ffmpeg.c b/ffmpeg.c index 7fdf57b3d5909a5b2f2b6cf49e768881ff175402..df9a99bca186beab76a8dac3cb6d5ff7b61ccc6c 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -432,9 +432,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) last_filter = ist->input_video_filter; if (ost->video_crop) { - snprintf(args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand, - codec->width, - codec->height); + snprintf(args, 255, "%d:%d:%d:%d", + codec->width, codec->height, + ost->leftBand, ost->topBand); if ((ret = avfilter_open(&filter, avfilter_get_by_name("crop"), NULL)) < 0) return ret; if ((ret = avfilter_init_filter(filter, args, NULL)) < 0) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 32f75bdc573f8cb092e87fbc099a52669f09e0a0..6fe6fa16ff19e0d519027f8e940ed99c78a3dfe8 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -25,7 +25,7 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 1 -#define LIBAVFILTER_VERSION_MINOR 40 +#define LIBAVFILTER_VERSION_MINOR 41 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 4f8a382fa2147ec81ec40016e4bed70fb41e207d..dfbc223483f825989eea248c49ef10bd2932938f 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -73,7 +73,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) CropContext *crop = ctx->priv; if (args) - sscanf(args, "%d:%d:%d:%d", &crop->x, &crop->y, &crop->w, &crop->h); + sscanf(args, "%d:%d:%d:%d", &crop->w, &crop->h, &crop->x, &crop->y); return 0; } @@ -96,8 +96,8 @@ static int config_input(AVFilterLink *link) crop->x &= ~((1 << crop->hsub) - 1); crop->y &= ~((1 << crop->vsub) - 1); - av_log(link->dst, AV_LOG_INFO, "x:%d y:%d w:%d h:%d\n", - crop->x, crop->y, crop->w, crop->h); + av_log(link->dst, AV_LOG_INFO, "w:%d h:%d x:%d y:%d\n", + crop->w, crop->h, crop->x, crop->y); if (crop->x < 0 || crop->y < 0 || crop->w <= 0 || crop->h <= 0 || @@ -172,7 +172,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) AVFilter avfilter_vf_crop = { .name = "crop", - .description = NULL_IF_CONFIG_SMALL("Crop the input video to x:y:width:height."), + .description = NULL_IF_CONFIG_SMALL("Crop the input video to width:height:x:y."), .priv_size = sizeof(CropContext), diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index 511e0aec2522e5d9b8c02f29cb20ef25dced4be7..112dda880a9f0bf9750f76121121922d716fbf15 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -22,15 +22,15 @@ do_lavfi() { fi } -do_lavfi "crop" "crop=100:100" -do_lavfi "crop_scale" "crop=100:100,scale=400:-1" -do_lavfi "crop_scale_vflip" "null,null,crop=200:200,crop=20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=100:100,vflip,scale=200:200,null,vflip,crop=100:100,null" -do_lavfi "crop_vflip" "crop=100:100,vflip" +do_lavfi "crop" "crop=0:0:100:100" +do_lavfi "crop_scale" "crop=0:0:100:100,scale=400:-1" +do_lavfi "crop_scale_vflip" "null,null,crop=0:0:200:200,crop=0:0:20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=0:0:100:100,vflip,scale=200:200,null,vflip,crop=0:0:100:100,null" +do_lavfi "crop_vflip" "crop=0:0:100:100,vflip" do_lavfi "null" "null" do_lavfi "scale200" "scale=200:200" do_lavfi "scale500" "scale=500:500" do_lavfi "vflip" "vflip" -do_lavfi "vflip_crop" "vflip,crop=100:100" +do_lavfi "vflip_crop" "vflip,crop=0:0:100:100" do_lavfi "vflip_vflip" "vflip,vflip" do_lavfi_pixfmts(){