Hello, i tried both Handbrake and Staxrip and these two has a auto crop option for black borders, now i am using x264 itself with a cmd batch script for encoding but i couldnt crop black borders, i dont know how to get crop values for using them in avs script, pleae help me, is there any way to auto crop video or getting crop values.
thanks a lot
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 18 of 18
Thread
-
-
Open your script in VirtualDub, Add Null Transform filter, Select Crop tool. Get values.
Or export a frame as an image. Open it in an image editor, get coordinates.
Or open your video in Handbrake, use the values its autocrop gives you.Last edited by jagabo; 14th May 2019 at 13:10.
-
Thanks, but i wrote a script in cmd to encode movies with my settings automatically so i need to get just crop values, i need a tool like mediainfo that i use this to get bitrate or width or ... for getting just crop values and then storing them into variables then importing them in avs script
-
If you have avisynth installed you can create a AVSfile (video.avs) and play it in many on the players that support avisynth script (Potplayer, WMP, MPC-BE, etc)
Code:LoadPlugin("C:\Users\Bud\Desktop\MEGA_Trimmed_Tabbed_2_2\bin\Debug\AutoCrop.dll") DirectShowSource(("C:\Users\Bud\Desktop\250_red.mp4"), Pixel_Type="yuy2").AutoCrop(mode=1, threshold=30)
;Result:
[Attachment 49052 - Click to enlarge] -
-
Avisynth autocrop will show, automatically crop. Save in autocrop.log or combination of these.
https://avisynth.org.ru/docs/english/externalfilters/autocrop.htm -
-
-
-
Code:
LoadPlugin(".\ffms2\ffms2.dll") LoadPlugin(".\autocrop\autocrop.dll") LoadPlugin(".\VSFilterMod\VSFilterMod.dll") FFVideoSource("video.mkv", colorspace = "YV12", \ cachefile = "video.ffindex") AutoCrop(mode=1, threshold=30)
-
-
You can resize first and then autocrop, because having nice legit source most likely. Using legit DVD or BD I use automatic batch script like that and never had a problem. You can use something like :
Code:LoadPlugin(".\ffms2\ffms2.dll") LoadPlugin(".\autocrop\autocrop.dll") LoadPlugin(".\VSFilterMod\VSFilterMod.dll") FFVideoSource("video.mkv", colorspace = "YV12", \ cachefile = "video.ffindex") Spline36Resize(1280,720) AutoCrop(2, 4, 4,) #this is mode 4
I have a script that does it all at once, it is quite long because it takes care of other things...
EDIT: to run a script and do nothing, just to get that log with crop line, you can load it into VirtualDub2 or if using command line only, you just load it into avsmeter for example:
"AVSMeter.exe" "your.avs" -log -range=0,1 2>nulLast edited by _Al_; 15th May 2019 at 15:09.
-
-
Sure, just try it, I never used it, but it might just work.
With mode 2 I checked what it would do, to not crop couple of pixels for example if DVD, or some BD animation could have some two, four pixels bands, that I'd certainly left alone. This is for example autocrop where it would leave 10 pixels alone, not cropping it, only blacks more than 10 pixels would be cropped, and some other stuff, like checking width, height, etc, don't do it, it is too complicated:
Code::autocrop <avisynth script> <video input> <%title%_%stream%> rem getting horizontal and vertical resolution coming out of avisynth script copy "%~1" "write_image.avs" >nul echo converttorgb() >> "write_image.avs" echo ImageWriter(file = "%temp_folder%\", start = 0, end = 0, type = "jpeg") >> "write_image.avs" echo return(last) >> "write_image.avs" %virtualdub% /s %load_script_vcf% /p "write_image.avs",NUL /r >NUL for %%i in ("*.jpeg") do set frame=%%~ni.jpeg rem run mediainfo to return w and h (width and height) coming out of avisynth script before autocrop is applied call :run_mediainfo "%frame%" "noprint" echo avisynth output resolution before autocrop is %w%x%h%, getting cropping values ... REM AutoCrop.dll identifies black borders in video and then generates avisynth crop line in AutoCrop.log REM The way it is done, Avisynth script has to load AutoCrop.dll followed by Autocrop(2,width_integer,height_integer) line and that generates crop line into AutoCrop.log copy "%~1" "autocrop.avs" > nul echo LoadPlugin("%autocrop_dll%") >> "autocrop.avs" echo autocrop(2,%w_integer%,%h_integer%) >> "autocrop.avs" if /i "%indexing%"=="ffvideosource" if not exist "%~dpn2.ffindex" echo ffvideosource is indexing video, it might take a little while ... %virtualdub% /s %load_script_vcf% /p "autocrop.avs",NUL /r >NUL set /p autocrop_avisynth_line= < "AutoCrop.log" if not exist AutoCrop.log ( echo WARNING, Autocrop failed, autocrop dll did not create AutoCrop.log, so no cropping was processed goto :eof ) echo AutoCrop.dll generated this avisynth crop line: %autocrop_avisynth_line% rem parsing values from that line for /f "tokens=2,3,4,5 delims=,()" %%m in ("%autocrop_avisynth_line%") do (set cropleft=%%m& set croptop=%%n& set w_autocrop=%%o& set h_autocrop=%%p) if %w% EQU %w_autocrop% if %h% EQU %h_autocrop% ( echo No letterbox or pillarbox detected, no cropping was applied echo #No letterbox or pillarbox detected from autocrop.avs, no cropping was applied >> "%~1" goto :eof ) echo loaded integers for cropping were: wMultOf=%w_integer%, hMultOf=%h_integer% REM do not crop if just tiny borders are present (basically if it is not letterbox or pillarbox) to not screw up resolutions set /a cropright=%w%-%w_autocrop%-%cropleft% if not %cropleft% EQU 0 if %cropleft% LEQ 10 ( set /a w_autocrop=%cropleft%+%w_autocrop% set cropleft=0 echo Negligent padding on the left, %cropleft% pixels, will be ignored echo # Negligent padding on the left, %cropleft% pixels, will be ignored >> "%~1" ) if not %cropright% EQU 0 if %cropright% LEQ 10 ( set /a w_autocrop=%cropright%+%w_autocrop% echo Negligent padding on the right, %cropright% pixels, will be ignored echo # Negligent padding on the right, %cropright% pixels, will be ignored >> "%~1" ) set /a cropbottom=%h%-%h_autocrop%-%croptop% if not %croptop% EQU 0 if %croptop% LEQ 10 ( set /a h_autocrop=%croptop%+%h_autocrop% set croptop=0 echo Negligent padding on the top, %croptop% pixels, will be ignored echo # Negligent padding on the top, %croptop% pixels, will be ignored >> "%~1" ) if not %cropbottom% EQU 0 if %cropbottom% LEQ 10 ( set /a h_autocrop=%cropbottom%+%h_autocrop% echo Negligent padding on the bottom, %cropbottom% pixels, will be ignored echo # Negligent padding on the bottom, %cropbottom% pixels, will be ignored >> "%~1" ) echo Crop(%cropleft%,%croptop%,%w_autocrop%,%h_autocrop%) >> "%~1" set w=%w_autocrop% set h=%h_autocrop% echo generated avisynth crop line: Crop^(%cropleft%,%croptop%,%w_autocrop%,%h_autocrop%^), video resolution changes to: %w%x%h% goto :eof
-
@echo off
set ffmpeg64="C:\Progra~1\converti_bat\ffmpegN1025.exe "
set sett=-c:v libx264 -crf 23 -c:a aac -b:a 160k
rem set sett=-c:v libx265 -crf 25 -c:a aac -b:a 160k
%ffmpeg64% -ss 90 -i "%~1" -vframes 10 -vf cropdetect -f null -
%ffmpeg64% -ss 90 -i "%~1" -vframes 10 -vf cropdetect -f null - 2>"%temp%\null.txt"
findstr /ic:Parsed_cropdetect "%temp%\null.txt">"%temp%\nu.txt"
for /f "usebackq tokens=*" %%A in ("%temp%\nu.txt") do (
for /f "tokens=1-2 delims==" %%a in ("%%~A") do (
set "cr=%%b"
))
del "%temp%\nu.txt"
del "%temp%\null.txt"
set cro=-vf crop=%cr%
choice /C "sn" /t 15 /D "n" /M "setting manuale ?"
SET ort=%ERRORLEVEL%
if "%ort%" equ "1" set /p "cr=crop=w:h:y:"
if "%ort%" equ "1" set cro=-vf crop=%cr%
IF "%ort%" EQU "2" echo no
if "%ort%" equ "2" goto fin
:fin
%ffmpeg64% -i "%~1" %cro% -y %sett% "%~n1_.mp4"
exit
Similar Threads
-
FFMPEG - Black Borders - [Please help]
By 21dresden21 in forum Video Streaming DownloadingReplies: 2Last Post: 12th Feb 2019, 08:51 -
Auto crop black bars in PotPlayer?
By deepblue-9 in forum Software PlayingReplies: 2Last Post: 24th Aug 2016, 13:21 -
Remove Black Borders From Movie Video
By anime12345 in forum Video ConversionReplies: 11Last Post: 27th Jan 2015, 21:40 -
auto-crop with subtitles in ffdshow doesn't work
By arthurm in forum SubtitleReplies: 0Last Post: 10th Aug 2014, 12:10 -
Fixing Black Borders
By Elegant in forum EditingReplies: 0Last Post: 30th May 2014, 23:12