Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Aug 2006
Location: USA
Posts: 59
|
Customizing cropdetect?
I am typically using the cropdetect filter, generally with ffmpeg or mplayer, to define the crop parameters of my TV recordings.
Some of those have two logos in the top right and left corners, generally above the useful area of the frame. As a result, when I crop the image, the logos are removed, but those logos prevent cropdetect from automatically finding the good crop parameters. Is there a way to customize cropdetect and tell it to avoid looking at the logo areas, for example the top left and right corners? For example, the correct cropping parameters are: [712, 360, 4, 58]. The two logos sit above the top line (Y = 58) in the two corners. When finding the top border (at Y = 58) , cropdetect should look only between X = 180 and X = 640. This would be the only restrictions, as the left, right and bottom borders don't present any problem. It would almost be possible (but not convenient) to obtain that result in two passes. One pass to find the right, left and bottom lines, and a second pass where the logos would be cropped so that cropdetect could find the top line (Y=58). I am just wondering if cropdetect could be modified to be told not to look in a small area of the picture. Last edited by JeanMarc; 5th June 2013 at 19:13. Reason: Accuracy |
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Aug 2006
Location: USA
Posts: 59
|
Well, since I don't find the source code, and I doubt I have the knowledge to customize it, I think I found the workaround.
For whoever is interested, here it is: First run a normal cropdetect command, for example: Code:
ffmpeg -y -ss 1000 -i my_clip -vf cropdetect=30:8:0 -vframes 100 -f rawvideo -an null I then run a second pass where I pipe the cropped clip into an ffmpeg process that runs cropdetect: Code:
ffmpeg -y -ss 1000 -i my_clip -vf crop=460:480:180:0 -vframes 120 -an -f image2pipe \ -vcodec ppm - | ffmpeg -f image2pipe -vcodec ppm -i - -vf cropdetect=30:8:0 -y null.avi The final cropping parameters are then [w0, h1, x0, y1] or [712, 360, 4, 58] Not too difficult to do in a script after all. |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Mar 2005
Location: Finland
Posts: 2,641
|
How about simply chaining the crop and cropdetect filters together for the vertical cropdetect pass. You also don't need to specify pixel dimensions if you use a fraction and in_w and in_h:
Code:
ffmpeg -y -ss 1000 -i my_clip -vf crop=1/3*in_w:in_h,cropdetect=30:8:0 -vframes 100 -f rawvideo -an null |
![]() |
![]() |
![]() |
#7 | Link | |
Registered User
Join Date: Aug 2006
Location: USA
Posts: 59
|
Quote:
|
|
![]() |
![]() |
![]() |
#8 | Link | |
Registered User
Join Date: Mar 2005
Location: Finland
Posts: 2,641
|
Quote:
My command suggestion was only intended to replace your second pass with a shorter and simpler variation. It determines top and bottom cropping amounts. |
|
![]() |
![]() |
![]() |
#9 | Link | |
Registered User
Join Date: Aug 2006
Location: USA
Posts: 59
|
Quote:
Thanks a lot. |
|
![]() |
![]() |
![]() |
Tags |
cropdetect, filters, mplayer |
Thread Tools | Search this Thread |
Display Modes | |
|
|