Opened 8 years ago

Closed 8 years ago

#1627 closed enhancement (fixed)

Allow resetting cropdetect after a number of frames.

Reported by: quetschke@… Owned by: reimar
Priority: normal Component: vf
Version: HEAD Severity: minor
Keywords: Cc:
Blocked By: Blocking:
Reproduced by developer: Analyzed by developer:

Description

I found that cropdetect sometimes fails to detect the black areas correctly. The following (9MB) sample is part of a recording with black letterbox bars.

http://www.scytek.de/cropbug.mpg

I noticed that in the original recording (45min) the detection of the lower letterbox bar started to fail in the second half of the file and I cut this short sample out of the recording to demonstrate the effect. In the first 5 seconds there is a channel logo in the lower left corner, so cropdetect is right in not detecting the lower bar, but for the remaining 7 seconds it should work.

Version: svn 30322, downloaded here: http://oss.netfarm.it/mplayer-win32.php , but the problem is reproducible with all earlier versions that I tried.

Recipe: The following command generates about one [crop] value every second:
$ mplayer.exe cropbug.mpg -sstep 1 -vf cropdetect=24:16,scale -nosound -noaspect

[swscaler @ 011613D4]BICUBIC scaler, from yuv420p to yuyv422 using MMX2
VO: [directx] 720x480 => 720x480 Packed YUY2
[CROP] Crop area: X: 6..699 Y: 57..476 (-vf crop=688:416:10:60).
[CROP] Crop area: X: 6..699 Y: 57..476 (-vf crop=688:416:10:60).
[CROP] Crop area: X: 6..699 Y: 57..476 (-vf crop=688:416:10:60).
[CROP] Crop area: X: 6..699 Y: 57..476 (-vf crop=688:416:10:60).
[CROP] Crop area: X: 6..700 Y: 57..476 (-vf crop=688:416:10:60).
[CROP] Crop area: X: 6..700 Y: 57..476 (-vf crop=688:416:10:60).
[CROP] Crop area: X: 6..700 Y: 57..476 (-vf crop=688:416:10:60).

I tried various values for the threshold value, but it does not help.

If I cut away the first part with the channel logo, then the cropdetection
correctly recognizes
[CROP] Crop area: X: 6..700 Y: 57..420 (-vf crop=688:352:10:64).
for the second part of that clip.

Attachments (1)

bug1627.diff (2.3 KB) - added by quetschke@… 8 years ago.
Patch to enhance cropdetect

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by reimar

  • Resolution set to invalid
  • Status changed from new to closed

That is the intended behaviour of cropdetect, it will detect the largest area that was used by the video at any time during playback.

comment:2 Changed 8 years ago by quetschke@…

That makes the feature pretty useless and it is not mentioned in the man page.

The idea behind the -sstep 1 was to get a crop area every minute. I use a script that collects all [CROP] lines and then chooses the most common value - exactly to work around the placement of channel logos and advertisements.

Is there any way to disable the history keeping part of this feature? That would be very useful.

comment:3 Changed 8 years ago by reimar

The feature is meant for manual use, not automated like you want to do.
Except waiting for someone to implement the feature you want (or do it yourself) you could also start MPlayer multiple times giving a -ss value a second apart each time.

comment:4 Changed 8 years ago by reimar

  • Resolution invalid deleted
  • Severity changed from normal to enhancement
  • Status changed from closed to reopened
  • Summary changed from cropdetect fails to detect lower letterbox bar to Allow resetting cropdetect after a number of frames.

Keep this as feature request.
The code is in libmpcodecs/vf_cropdetect.c and is about as simple as it gets in MPlayer.

Changed 8 years ago by quetschke@…

Patch to enhance cropdetect

comment:5 Changed 8 years ago by quetschke@…

Indeed, it's pretty simple to implement. What do you think of the attached patch?

comment:6 Changed 8 years ago by reimar

  • Resolution set to fixed
  • Status changed from reopened to closed

Close. Your patch added trailing whitespace, which can't be committed to SVN, the static variable would have caused chaos if someone used more than one cropdetect filter and we already had a frame counter anyway.
Applied with modifications to fix these.

Note: See TracTickets for help on using tickets.