Hi,
I'm using ffmpeg command line tool with libfdk_aac & x265 to encode HEVC 1080p 10-bit which perfectly works fine except for one thing and it is "crop".
I need to remove black borders/bars (top & bottom) and find handrake does it automatically. but I can't find such thing in ffmpeg. I tried "cropdetect" to get values but it shows many different values. IF I can get correct crop values then I can use "-filter:v "crop=A:B:X:Y" in ffmpeg while encoding.
Could anyone please suggest on how to get correct values / auto-crop?
Thanks!
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 6 of 6
Thread
-
-
unless there is something differnet with x265 codec crop should work but has a threshold setting. Below is a sample to detectcrop show, using a setting of 30% for threshold:
Code:LoadPlugin("C:\Users\Bud\Desktop\MEGA_Trimmed_Tabbed_2_2\bin\Debug\AutoCrop.dll") DirectShowSource(("C:\Users\Bud\Desktop\[dp]Manjandani-1.mp4"), Pixel_Type="yuy2").AutoCrop(mode=1, threshold=30) Subtitle("C:\Users\Bud\Desktop\[dp]Manjandani-1.mp4", x=864, y=204, font="Arial", size=24, text_color=$ff0000, align=3) Subtitle("This is Anamorphic video", font="Arial", size=24, text_color=$ff0000, align=5) ShowFrameNumber(scroll=true, x=560, y=27, font="Arial", size=24, text_color=$ffff80) ShowTime(x=622, y=44, font="Arial", size=24, text_color=$ffff80) ShowSMPTE(fps=23.976, x=618, y=61, font="Arial", size=24, text_color=$ffff80)
[Attachment 48142 - Click to enlarge]
It has a lot of extra stuff spit out from my auto program, but alter as necessary.
Crop using the following format:
Code:ffmpeg -i "C:\Users\Bud\Desktop\Manjandani unCropped.mp4" -ss 00:00:00.000 -to 99:00:00.000 -vf crop=564:228:60:60,scale=684:348,setdar=1.966 -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k "C:\Users\Bud\Desktop\Manjandani_Cropped.mp4"
[Attachment 48141 - Click to enlarge] -
If you run cropdetect, it outputs the crop values for each frame it looks at, same with the Avisynth script Budman1 posted.
-> so depending on the frames you look at you will see different values
Handbrake and other guis on the other hand analyse X frames throughout the video and only output the crop values with the largest area.
There is no direct 'autocrop' in ffmpeg, so you would need to:
a. make sure you analyse multiple sections throughout your clip
b. filter the output to only use the value with the largest resolution
-> if you don't manually select the scene to analyse and filter the output a lot can go wrong
(for example if you only analyse X frames 5min into the film and for one film those 5min are basically all black )users currently on my ignore list: deadrats, Stears555 -
Thank you Budman1 & Selur.
I'm using latest ffmpeg on Ubuntu 18.10.
My source is 1920x1080 Blu-ray Remux (35GB) and the cropdetect shows below. I'm confused as to why it shows very low values compared to 1920x1080. Please see below and clarify what values I need to use with crop for ffmpeg? THANKS!
root@ubuntu:# ffmpeg -i title_t00.mkv -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }'
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
crop=192:112:866:460
root@ubuntu:# -
Next, start with what OS you are on.
Code:ffmpeg -i title_t00.mkv -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }'
Code:ffmpeg -i title_t00.mkv -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1
Also note that you are only running the crop detection on the first second of your clip, depending on your clips that might be okay or not,.. (if your clips start will a 4:3 intro and then switch to 16:9 crop will 'fail')
Cu Selurusers currently on my ignore list: deadrats, Stears555 -
Perhaps your threshold is set too wrong for cropdetect. Interesting 2x866=1732+192=1924 and 2x460=920+112=1032 , both approximately the original size
Similar Threads
-
FFQueue (ffmpeg GUI) testing, feature request & feedback
By TorBru in forum Video ConversionReplies: 181Last Post: 19th Jul 2019, 16:54 -
(Willing to pay)ffmpeg Need help downloading live stream ffmpeg and rtmp
By grabyea in forum Video Streaming DownloadingReplies: 0Last Post: 10th Apr 2016, 16:54 -
FFMPEG QUESTION :How do I take 10bit jpeg with FFMPEG?
By Jamaika in forum Video ConversionReplies: 10Last Post: 6th Jul 2015, 13:41 -
FFmpeg resize and crop error
By z-machine95 in forum Video ConversionReplies: 4Last Post: 23rd May 2015, 18:57 -
FFMPEG: can crop 32 lines using vcodec copy?
By marcorocchini in forum Newbie / General discussionsReplies: 4Last Post: 26th Feb 2015, 14:39