Glam Prestige Journal

Bright entertainment trends with youth appeal.

I have some .wmv files that have black borders around and I would like to crop them. Here's a powershell script I got from web that I'm using to crop .mp4 files, which it does just beautifully.

Get-ChildItem .\ -Filter *.mp4| ForEach-Object { $exportPath="..\$($_.Name)" #Know where to cut $results=ffmpeg -ss 10 -i $($_.Name) -vframes 10 -vf "cropdetect=24:16:0" -f null - 2>&1 #Cut if(($results | ? {$_ -match 'crop=\d[0-9]{1,4}:\d[0-9]{1,4}:\d[0-9]{0,4}:\d[0-9]{0,4}'})){ Write-Host "The regular expression was matched, value $($Matches[0])." ffmpeg -i $($_.Name) -crf 18 -vf ($Matches[0]) -c:a copy $exportPath }else{ Write-Host "The regular expression was NOT matched. The line was '$($resultsParsed[0])'" $results | Out-File .\resultsFromCropDetect.txt }
}

Needless to say it produces horrible quality for the .wmv files cropped with it.

So, my question is what set of commands should I use for lossy or even lossless output?

EDIT: @Rotem I used FFprobe,

 Stream #0:0: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, 2 channels, fltp, 192 kb/s Stream #0:1: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1440x1080, 24000 kb/s, 29.97 fps, 29.97 tbr, 1k tbn

I'm using cropdetect because it is really easy to find dimensions and automatically crop the video

4 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy