#9851: cropdetect: add ability to change option like limit at runtime
-------------------------------------+-------------------------------------
Reporter: Ashyni | Type:
| enhancement
Status: new | Priority: normal
Component: avfilter | Version: git-
Keywords: crop | master
cropdetect | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Hello,
I have been working on a dynamic-crop.lua script for the player mpv for a
while.
[https://github.com/Ashyni/mpv-scripts#dynamic-croplua]
The script auto adjusts the limit option of the cropdetect filter every
time a metadata show sign of dark scene to try to find a coherent crop if
any.
Every limit change re-init cropdetect filter and cause an impact in
performance depending on the gpu-api used by mpv from 50% in fps drop
(opengl, more impact with gpu-context=angle) to almost no visible impact
(vulkan/d3d11).
Maybe something can be done on mpv side, but i wonder if it's possible to
make changing options like limit/reset at runtime a better solution for
this use case when cropdetect filter is always active from start to end of
the video.
mpv 0.34.0-384-gd2467f61be
built on Sun Jul 24 12:31:39 2022
FFmpeg version: git-2022-07-23-1cb7fd317
FFmpeg library versions:
libavutil 57.30.100
libavcodec 59.39.100
libavformat 59.29.100
libswscale 6.8.101
libavfilter 8.46.100
libswresample 4.8.100
Some logs:
{{{
[ 477.682][v][ffmpeg] filter: x1:0 x2:1919 y1:0 y2:1079 w:1920 h:1080 x:0
y:0 pts:107941000 t:107.941000 crop=1920:1080:0:0
[ 477.724][v][ffmpeg] filter: x1:0 x2:1919 y1:0 y2:1079 w:1920 h:1080 x:0
y:0 pts:107983000 t:107.983000 crop=1920:1080:0:0
[ 477.767][v][ffmpeg] filter: x1:1919 x2:0 y1:1079 y2:0 w:-1918 h:-1078
x:1920 y:1080 pts:108025000 t:108.025000 crop=-1918:-1078:1920:1080
[ 477.808][v][ffmpeg] filter: x1:1919 x2:0 y1:1079 y2:0 w:-1918 h:-1078
x:1920 y:1080 pts:108066000 t:108.066000 crop=-1918:-1078:1920:1080
[ 477.808][d][cplayer] Run command: vf, flags=72, args=[operation="pre",
value="@dynamic_crop-cropdetect:lavfi-
cropdetect=limit=24/255:round=2:reset=1:skip=1"]
[ 477.809][d][ffmpeg] filter: limit:0.094118 round:2 skip:1 reset_count:1
[ 477.809][v][vf] User filter list:
[ 477.809][v][vf] lavfi-cropdetect (dynamic_crop-cropdetect)
[ 477.809][v][vf] lavfi-crop (dynamic_crop-crop)
[ 477.849][v][vf] [lavfi-cropdetect] 1920x1080 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 477.849][d][ffmpeg] mpv_src_default_in: w:1920 h:1080 pixfmt:yuv420p
tb:1/1000000 fr:992008/41375 sar:1/1
[ 477.892][v][ffmpeg] filter: x1:1919 x2:0 y1:741 y2:759 w:-1918 h:18
x:1920 y:742 pts:108150000 t:108.150000 crop=-1918:18:1920:742
[ 477.933][v][ffmpeg] filter: x1:1919 x2:0 y1:741 y2:758 w:-1918 h:16
x:1920 y:742 pts:108191000 t:108.191000 crop=-1918:16:1920:742
[ 477.933][d][cplayer] Run command: vf, flags=72, args=[operation="pre",
value="@dynamic_crop-cropdetect:lavfi-
cropdetect=limit=22/255:round=2:reset=1:skip=1"]
[ 477.934][d][ffmpeg] filter: limit:0.086275 round:2 skip:1 reset_count:1
[ 477.935][v][vf] User filter list:
[ 477.935][v][vf] lavfi-cropdetect (dynamic_crop-cropdetect)
[ 477.935][v][vf] lavfi-crop (dynamic_crop-crop)
[ 477.974][v][vf] [lavfi-cropdetect] 1920x1080 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 477.974][d][ffmpeg] mpv_src_default_in: w:1920 h:1080 pixfmt:yuv420p
tb:1/1000000 fr:992008/41375 sar:1/1
[ 478.017][v][ffmpeg] filter: x1:885 x2:1510 y1:437 y2:784 w:624 h:346
x:886 y:438 pts:108275000 t:108.275000 crop=624:346:886:438
[ 478.058][v][ffmpeg] filter: x1:884 x2:1509 y1:438 y2:784 w:626 h:346
x:884 y:438 pts:108317000 t:108.317000 crop=626:346:884:438
[ 478.058][d][cplayer] Run command: vf, flags=72, args=[operation="pre",
value="@dynamic_crop-cropdetect:lavfi-
cropdetect=limit=20/255:round=2:reset=1:skip=1"]
[ 478.059][d][ffmpeg] filter: limit:0.078431 round:2 skip:1 reset_count:1
[ 478.060][v][vf] User filter list:
[ 478.060][v][vf] lavfi-cropdetect (dynamic_crop-cropdetect)
[ 478.060][v][vf] lavfi-crop (dynamic_crop-crop)
[ 478.099][v][vf] [lavfi-cropdetect] 1920x1080 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 478.099][d][ffmpeg] mpv_src_default_in: w:1920 h:1080 pixfmt:yuv420p
tb:1/1000000 fr:992008/41375 sar:1/1
[ 478.141][v][ffmpeg] filter: x1:820 x2:1673 y1:139 y2:940 w:854 h:800
x:820 y:140 pts:108400000 t:108.400000 crop=854:800:820:140
[ 478.184][v][ffmpeg] filter: x1:818 x2:1672 y1:139 y2:940 w:854 h:800
x:818 y:140 pts:108442000 t:108.442000 crop=854:800:818:140
[ 478.184][d][cplayer] Run command: vf, flags=72, args=[operation="pre",
value="@dynamic_crop-cropdetect:lavfi-
cropdetect=limit=18/255:round=2:reset=1:skip=1"]
[ 478.185][d][ffmpeg] filter: limit:0.070588 round:2 skip:1 reset_count:1
[ 478.185][v][vf] User filter list:
[ 478.185][v][vf] lavfi-cropdetect (dynamic_crop-cropdetect)
[ 478.185][v][vf] lavfi-crop (dynamic_crop-crop)
[ 478.224][v][vf] [lavfi-cropdetect] 1920x1080 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 478.224][d][ffmpeg] mpv_src_default_in: w:1920 h:1080 pixfmt:yuv420p
tb:1/1000000 fr:992008/41375 sar:1/1
[ 478.265][v][ffmpeg] filter: x1:0 x2:1919 y1:138 y2:941 w:1920 h:804 x:0
y:138 pts:108525000 t:108.525000 crop=1920:804:0:138
[ 478.308][v][ffmpeg] filter: x1:0 x2:1919 y1:138 y2:941 w:1920 h:804 x:0
y:138 pts:108567000 t:108.567000 crop=1920:804:0:138
[ 478.348][v][ffmpeg] filter: x1:0 x2:1919 y1:138 y2:941 w:1920 h:804 x:0
y:138 pts:108608000 t:108.608000 crop=1920:804:0:138
[ 478.391][v][ffmpeg] filter: x1:0 x2:1919 y1:138 y2:941 w:1920 h:804 x:0
y:138 pts:108650000 t:108.650000 crop=1920:804:0:138
[ 478.391][v][cplayer] Set property: geometry="1920" -> 1
[ 478.391][d][cplayer] Run command: vf, flags=72,
args=[operation="append", value="@dynamic_crop-crop:lavfi-
crop=w=1920:h=804:x=0:y=138"]
[ 478.393][v][vf] User filter list:
[ 478.393][v][vf] lavfi-cropdetect (dynamic_crop-cropdetect)
[ 478.393][v][vf] lavfi-crop (dynamic_crop-crop)
[ 478.433][v][ffmpeg] filter: x1:0 x2:1919 y1:138 y2:941 w:1920 h:804 x:0
y:138 pts:108692000 t:108.692000 crop=1920:804:0:138
[ 478.433][v][vf] [lavfi-crop] 1920x1080 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 478.433][d][ffmpeg] mpv_src_default_in: w:1920 h:1080 pixfmt:yuv420p
tb:1/1000000 fr:992008/41375 sar:1/1
[ 478.433][d][ffmpeg] filter: w:1920 h:1080 sar:1/1 -> w:1920 h:804
sar:1/1
[ 478.433][v][vf] [autorotate] 1920x804 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 478.433][v][vf] [convert] 1920x804 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[ 478.433][v][vf] [out] 1920x804 yuv420p
bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9851>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac
To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".